Skip to content
This repository has been archived by the owner on Jan 7, 2023. It is now read-only.

Commit

Permalink
UPSTREAM: i965: fallback RGBX to RGBA in glEGLImageTargetRenderbuffer…
Browse files Browse the repository at this point in the history
…StorageOES

In the same fashion as is done for glEGLImageTextureTarget2D.

v2: share the fallback which sets baseformat and internalformat correctly
    which makes both of the tests pass (Tapani)

Fixes android.hardware.nativehardware.cts.AHardwareBufferNativeTests:

   #SingleLayer_ColorTest_GpuColorOutputCpuRead_R8G8B8X8_UNORM
   #SingleLayer_ColorTest_GpuColorOutputIsRenderable_R8G8B8X8_UNORM

Signed-off-by: Tapani Pälli <[email protected]>
Reviewed-by: Gurchetan Singh <[email protected]>
(cherry picked from commit 47e3338)
  • Loading branch information
dchysty authored and strassek committed Oct 17, 2018
1 parent 74ef6c4 commit ec21002
Showing 1 changed file with 37 additions and 26 deletions.
63 changes: 37 additions & 26 deletions src/mesa/drivers/dri/i965/intel_fbo.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,35 @@ intel_alloc_renderbuffer_storage(struct gl_context * ctx, struct gl_renderbuffer
return intel_alloc_private_renderbuffer_storage(ctx, rb, internalFormat, width, height);
}

static mesa_format
fallback_rgbx_to_rgba(struct intel_screen *screen, struct gl_renderbuffer *rb,
mesa_format original_format)
{
mesa_format format = original_format;

/* The base format and internal format must be derived from the user-visible
* format (that is, the gl_config's format), even if we internally use
* choose a different format for the renderbuffer. Otherwise, rendering may
* use incorrect channel write masks.
*/
rb->_BaseFormat = _mesa_get_format_base_format(original_format);
rb->InternalFormat = rb->_BaseFormat;

if (!screen->mesa_format_supports_render[original_format]) {
/* The glRenderbufferStorage paths in core Mesa detect if the driver
* does not support the user-requested format, and then searches for
* a fallback format. The DRI code bypasses core Mesa, though. So we do
* the fallbacks here.
*
* We must support MESA_FORMAT_R8G8B8X8 on Android because the Android
* framework requires HAL_PIXEL_FORMAT_RGBX8888 winsys surfaces.
*/
format = _mesa_format_fallback_rgbx_to_rgba(original_format);
assert(screen->mesa_format_supports_render[format]);
}
return format;
}

static void
intel_image_target_renderbuffer_storage(struct gl_context *ctx,
struct gl_renderbuffer *rb,
Expand All @@ -349,8 +378,13 @@ intel_image_target_renderbuffer_storage(struct gl_context *ctx,
return;
}

rb->Format = fallback_rgbx_to_rgba(brw->screen, rb, image->format);

mesa_format chosen_format = rb->Format == image->format ?
image->format : rb->Format;

/* __DRIimage is opaque to the core so it has to be checked here */
if (!brw->mesa_format_supports_render[image->format]) {
if (!brw->mesa_format_supports_render[chosen_format]) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glEGLImageTargetRenderbufferStorage(unsupported image format)");
return;
Expand All @@ -365,15 +399,12 @@ intel_image_target_renderbuffer_storage(struct gl_context *ctx,
* content.
*/
irb->mt = intel_miptree_create_for_dri_image(brw, image, GL_TEXTURE_2D,
image->format, false);
rb->Format, false);
if (!irb->mt)
return;

rb->InternalFormat = image->internal_format;
rb->Width = image->width;
rb->Height = image->height;
rb->Format = image->format;
rb->_BaseFormat = _mesa_get_format_base_format(image->format);
rb->NeedsFinishRenderTexture = true;
irb->layer_count = 1;
}
Expand Down Expand Up @@ -434,27 +465,7 @@ intel_create_winsys_renderbuffer(struct intel_screen *screen,
rb->ClassID = INTEL_RB_CLASS;
rb->NumSamples = num_samples;

/* The base format and internal format must be derived from the user-visible
* format (that is, the gl_config's format), even if we internally use
* choose a different format for the renderbuffer. Otherwise, rendering may
* use incorrect channel write masks.
*/
rb->_BaseFormat = _mesa_get_format_base_format(format);
rb->InternalFormat = rb->_BaseFormat;

rb->Format = format;
if (!screen->mesa_format_supports_render[rb->Format]) {
/* The glRenderbufferStorage paths in core Mesa detect if the driver
* does not support the user-requested format, and then searches for
* a falback format. The DRI code bypasses core Mesa, though. So we do
* the fallbacks here.
*
* We must support MESA_FORMAT_R8G8B8X8 on Android because the Android
* framework requires HAL_PIXEL_FORMAT_RGBX8888 winsys surfaces.
*/
rb->Format = _mesa_format_fallback_rgbx_to_rgba(rb->Format);
assert(screen->mesa_format_supports_render[rb->Format]);
}
rb->Format = fallback_rgbx_to_rgba(screen, rb, format);

/* intel-specific methods */
rb->Delete = intel_delete_renderbuffer;
Expand Down

0 comments on commit ec21002

Please sign in to comment.