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

Commit ec21002

Browse files
dchystystrassek
authored andcommitted
UPSTREAM: i965: fallback RGBX to RGBA in glEGLImageTargetRenderbufferStorageOES
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)
1 parent 74ef6c4 commit ec21002

File tree

1 file changed

+37
-26
lines changed

1 file changed

+37
-26
lines changed

src/mesa/drivers/dri/i965/intel_fbo.c

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,35 @@ intel_alloc_renderbuffer_storage(struct gl_context * ctx, struct gl_renderbuffer
327327
return intel_alloc_private_renderbuffer_storage(ctx, rb, internalFormat, width, height);
328328
}
329329

330+
static mesa_format
331+
fallback_rgbx_to_rgba(struct intel_screen *screen, struct gl_renderbuffer *rb,
332+
mesa_format original_format)
333+
{
334+
mesa_format format = original_format;
335+
336+
/* The base format and internal format must be derived from the user-visible
337+
* format (that is, the gl_config's format), even if we internally use
338+
* choose a different format for the renderbuffer. Otherwise, rendering may
339+
* use incorrect channel write masks.
340+
*/
341+
rb->_BaseFormat = _mesa_get_format_base_format(original_format);
342+
rb->InternalFormat = rb->_BaseFormat;
343+
344+
if (!screen->mesa_format_supports_render[original_format]) {
345+
/* The glRenderbufferStorage paths in core Mesa detect if the driver
346+
* does not support the user-requested format, and then searches for
347+
* a fallback format. The DRI code bypasses core Mesa, though. So we do
348+
* the fallbacks here.
349+
*
350+
* We must support MESA_FORMAT_R8G8B8X8 on Android because the Android
351+
* framework requires HAL_PIXEL_FORMAT_RGBX8888 winsys surfaces.
352+
*/
353+
format = _mesa_format_fallback_rgbx_to_rgba(original_format);
354+
assert(screen->mesa_format_supports_render[format]);
355+
}
356+
return format;
357+
}
358+
330359
static void
331360
intel_image_target_renderbuffer_storage(struct gl_context *ctx,
332361
struct gl_renderbuffer *rb,
@@ -349,8 +378,13 @@ intel_image_target_renderbuffer_storage(struct gl_context *ctx,
349378
return;
350379
}
351380

381+
rb->Format = fallback_rgbx_to_rgba(brw->screen, rb, image->format);
382+
383+
mesa_format chosen_format = rb->Format == image->format ?
384+
image->format : rb->Format;
385+
352386
/* __DRIimage is opaque to the core so it has to be checked here */
353-
if (!brw->mesa_format_supports_render[image->format]) {
387+
if (!brw->mesa_format_supports_render[chosen_format]) {
354388
_mesa_error(ctx, GL_INVALID_OPERATION,
355389
"glEGLImageTargetRenderbufferStorage(unsupported image format)");
356390
return;
@@ -365,15 +399,12 @@ intel_image_target_renderbuffer_storage(struct gl_context *ctx,
365399
* content.
366400
*/
367401
irb->mt = intel_miptree_create_for_dri_image(brw, image, GL_TEXTURE_2D,
368-
image->format, false);
402+
rb->Format, false);
369403
if (!irb->mt)
370404
return;
371405

372-
rb->InternalFormat = image->internal_format;
373406
rb->Width = image->width;
374407
rb->Height = image->height;
375-
rb->Format = image->format;
376-
rb->_BaseFormat = _mesa_get_format_base_format(image->format);
377408
rb->NeedsFinishRenderTexture = true;
378409
irb->layer_count = 1;
379410
}
@@ -434,27 +465,7 @@ intel_create_winsys_renderbuffer(struct intel_screen *screen,
434465
rb->ClassID = INTEL_RB_CLASS;
435466
rb->NumSamples = num_samples;
436467

437-
/* The base format and internal format must be derived from the user-visible
438-
* format (that is, the gl_config's format), even if we internally use
439-
* choose a different format for the renderbuffer. Otherwise, rendering may
440-
* use incorrect channel write masks.
441-
*/
442-
rb->_BaseFormat = _mesa_get_format_base_format(format);
443-
rb->InternalFormat = rb->_BaseFormat;
444-
445-
rb->Format = format;
446-
if (!screen->mesa_format_supports_render[rb->Format]) {
447-
/* The glRenderbufferStorage paths in core Mesa detect if the driver
448-
* does not support the user-requested format, and then searches for
449-
* a falback format. The DRI code bypasses core Mesa, though. So we do
450-
* the fallbacks here.
451-
*
452-
* We must support MESA_FORMAT_R8G8B8X8 on Android because the Android
453-
* framework requires HAL_PIXEL_FORMAT_RGBX8888 winsys surfaces.
454-
*/
455-
rb->Format = _mesa_format_fallback_rgbx_to_rgba(rb->Format);
456-
assert(screen->mesa_format_supports_render[rb->Format]);
457-
}
468+
rb->Format = fallback_rgbx_to_rgba(screen, rb, format);
458469

459470
/* intel-specific methods */
460471
rb->Delete = intel_delete_renderbuffer;

0 commit comments

Comments
 (0)