Commit 5a81de82 authored by Eric Anholt's avatar Eric Anholt

glamor: Don't try to do rendering with unsupported formats.

I'm amazed we've made it as far as we have without these checks: if
you made an unusual format picture that wasn't the normal a8r8g8b8 or
x8r8g8b8 or a8, we'd go ahead and try to render with it, ignoring that
the sampler would fetch totally wrong bits.

Fixes 260 tests in rendercheck -t blend -o src -f a8r8g8b8,x2r10g10b10
Signed-off-by: Eric Anholt's avatarEric Anholt <eric@anholt.net>
Reviewed-by: Michel Dänzer's avatarMichel Dänzer <michel.daenzer@amd.com>
Reviewed-by: default avatarDave Airlie <airlied@redhat.com>
parent 0d7cbd6f
......@@ -753,6 +753,29 @@ glamor_set_normalize_tcoords_generic(PixmapPtr pixmap,
texcoords, stride);
}
/**
* Returns whether the general composite path supports this picture
* format for a pixmap that is permanently stored in an FBO (as
* opposed to the GLAMOR_PIXMAP_DYNAMIC_UPLOAD path).
*
* We could support many more formats by using GL_ARB_texture_view to
* parse the same bits as different formats. For now, we only support
* tweaking whether we sample the alpha bits of an a8r8g8b8, or just
* force them to 1.
*/
static Bool
glamor_render_format_is_supported(PictFormatShort format)
{
switch (format) {
case PICT_a8r8g8b8:
case PICT_x8r8g8b8:
case PICT_a8:
return TRUE;
default:
return FALSE;
}
}
static Bool
glamor_composite_choose_shader(CARD8 op,
PicturePtr source,
......@@ -783,6 +806,11 @@ glamor_composite_choose_shader(CARD8 op,
goto fail;
}
if (!glamor_render_format_is_supported(dest->format)) {
glamor_fallback("Unsupported dest picture format.\n");
goto fail;
}
memset(&key, 0, sizeof(key));
if (!source) {
key.source = SHADER_SOURCE_SOLID;
......@@ -951,6 +979,11 @@ glamor_composite_choose_shader(CARD8 op,
glamor_fallback("Failed to upload source texture.\n");
goto fail;
}
} else {
if (!glamor_render_format_is_supported(source->format)) {
glamor_fallback("Unsupported source picture format.\n");
goto fail;
}
}
if (mask_status == GLAMOR_UPLOAD_PENDING) {
......@@ -959,6 +992,11 @@ glamor_composite_choose_shader(CARD8 op,
glamor_fallback("Failed to upload mask texture.\n");
goto fail;
}
} else if (mask) {
if (!glamor_render_format_is_supported(mask->format)) {
glamor_fallback("Unsupported mask picture format.\n");
goto fail;
}
}
}
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment