Esempio n. 1
0
/**
 * Return the gallium texture of an EGLImage.
 */
static bool
st_get_egl_image(struct gl_context *ctx, GLeglImageOES image_handle,
                 unsigned usage, const char *error, struct st_egl_image *out)
{
   struct st_context *st = st_context(ctx);
   struct pipe_screen *screen = st->pipe->screen;
   struct st_manager *smapi =
      (struct st_manager *) st->iface.st_context_private;

   if (!smapi || !smapi->get_egl_image)
      return false;

   memset(out, 0, sizeof(*out));
   if (!smapi->get_egl_image(smapi, (void *) image_handle, out)) {
      /* image_handle does not refer to a valid EGL image object */
      _mesa_error(ctx, GL_INVALID_VALUE, "%s(image handle not found)", error);
      return false;
   }

   if (!is_format_supported(screen, out->format, out->texture->nr_samples, usage)) {
      /* unable to specify a texture object using the specified EGL image */
      pipe_resource_reference(&out->texture, NULL);
      _mesa_error(ctx, GL_INVALID_OPERATION, "%s(format not supported)", error);
      return false;
   }

   return true;
}
Esempio n. 2
0
enum piglit_result
piglit_display(void)
{
	enum piglit_result result = PIGLIT_PASS;
	enum piglit_result subtest;
	struct texture_format *src_format_list, *dst_format_list;
	struct texture_format *src_format, *dst_format;
	int sf, df, src_format_count, dst_format_count;

	if (src_format_arg) {
		src_format_list = src_format_arg;
		src_format_count = 1;
	} else {
		src_format_list = formats;
		src_format_count = ARRAY_LENGTH(formats);
	}

	if (dst_format_arg) {
		dst_format_list = dst_format_arg;
		dst_format_count = 1;
	} else {
		dst_format_list = formats;
		dst_format_count = ARRAY_LENGTH(formats);
	}

	for (sf = 0; sf < src_format_count; ++sf) {
		src_format = &src_format_list[sf];
		if (!is_format_supported(src_format))
			continue;

		for (df = 0; df < dst_format_count; ++df) {
			dst_format = &dst_format_list[df];
			if (!is_format_supported(dst_format))
				continue;
			if (!are_formats_compatible(src_format, dst_format))
				continue;

			setup_test_data(src_format, dst_format);
			if (samples == 1) {
				subtest = run_test(src_format,
						   dst_format);
			} else {
				if (is_format_compressed(src_format) ||
				    is_format_compressed(dst_format))
					continue;

				subtest = run_multisample_test(src_format,
							       dst_format);
			}

			if (!src_format_arg) {
				/* In this case, we're running a full suite
				 * of subtests, report accordingly.
				 */
				piglit_report_subtest_result(subtest,
					"Source: %s/Destination: %s",
					src_format->name, dst_format->name);
			} else if (!dst_format_arg) {
				/* In this case, the source format was
				 * specified but the destination was not.
				 * Report one subtest per destination.
				 */
				piglit_report_subtest_result(subtest,
					"Destination Format: %s",
					dst_format->name);
			}

			if (subtest == PIGLIT_FAIL)
				result = PIGLIT_FAIL;
			else if (subtest == PIGLIT_WARN && result == PIGLIT_PASS)
				result = PIGLIT_WARN;
		}
	}

	return result;
}
Esempio n. 3
0
static boolean
dri2_display_convert_config(struct native_display *ndpy,
                            const __GLcontextModes *mode,
                            struct native_config *nconf)
{
   enum pipe_format formats[32];
   int num_formats, i;
   int sample_count = 0;

   if (!(mode->renderType & GLX_RGBA_BIT) || !mode->rgbMode)
      return FALSE;

   /* only interested in native renderable configs */
   if (!mode->xRenderable || !mode->drawableType)
      return FALSE;

   /* fast/slow configs are probably not relevant */
   if (mode->visualRating == GLX_SLOW_CONFIG)
      return FALSE;

   nconf->buffer_mask = 1 << NATIVE_ATTACHMENT_FRONT_LEFT;
   if (mode->doubleBufferMode)
      nconf->buffer_mask |= 1 << NATIVE_ATTACHMENT_BACK_LEFT;
   if (mode->stereoMode) {
      nconf->buffer_mask |= 1 << NATIVE_ATTACHMENT_FRONT_RIGHT;
      if (mode->doubleBufferMode)
         nconf->buffer_mask |= 1 << NATIVE_ATTACHMENT_BACK_RIGHT;
   }

   /* choose color format */
   num_formats = choose_color_format(mode, formats);
   for (i = 0; i < num_formats; i++) {
      if (is_format_supported(ndpy->screen, formats[i], sample_count, TRUE)) {
         nconf->color_format = formats[i];
         break;
      }
   }
   if (nconf->color_format == PIPE_FORMAT_NONE)
      return FALSE;

   if ((mode->drawableType & GLX_WINDOW_BIT) && mode->visualID)
      nconf->window_bit = TRUE;
   if (mode->drawableType & GLX_PIXMAP_BIT)
      nconf->pixmap_bit = TRUE;

   nconf->native_visual_id = mode->visualID;
   switch (mode->visualType) {
   case GLX_TRUE_COLOR:
      nconf->native_visual_type = TrueColor;
      break;
   case GLX_DIRECT_COLOR:
      nconf->native_visual_type = DirectColor;
      break;
   case GLX_PSEUDO_COLOR:
      nconf->native_visual_type = PseudoColor;
      break;
   case GLX_STATIC_COLOR:
      nconf->native_visual_type = StaticColor;
      break;
   case GLX_GRAY_SCALE:
      nconf->native_visual_type = GrayScale;
      break;
   case GLX_STATIC_GRAY:
      nconf->native_visual_type = StaticGray;
      break;
   }
   nconf->level = mode->level;

   if (mode->transparentPixel == GLX_TRANSPARENT_RGB) {
      nconf->transparent_rgb = TRUE;
      nconf->transparent_rgb_values[0] = mode->transparentRed;
      nconf->transparent_rgb_values[1] = mode->transparentGreen;
      nconf->transparent_rgb_values[2] = mode->transparentBlue;
   }

   return TRUE;
}