summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/nine/basetexture9.c
diff options
context:
space:
mode:
authorAxel Davy <[email protected]>2014-12-03 23:33:07 +0100
committerEmil Velikov <[email protected]>2015-01-22 22:16:19 +0000
commitb0b5430322406a521b8a75468452ac5d4ce86750 (patch)
tree36a60016b826964ac486e792e121e358740866dc /src/gallium/state_trackers/nine/basetexture9.c
parent82810d3b660dfeef53a18c0d48914783e2999b2a (diff)
st/nine: Check if srgb format is supported before trying to use it.
According to msdn, we must act as if user didn't ask srgb if we don't support it. Reviewed-by: Ilia Mirkin <[email protected]> Reviewed-by: David Heidelberg <[email protected]> Signed-off-by: Axel Davy <[email protected]> Cc: "10.4" <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/nine/basetexture9.c')
-rw-r--r--src/gallium/state_trackers/nine/basetexture9.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/gallium/state_trackers/nine/basetexture9.c b/src/gallium/state_trackers/nine/basetexture9.c
index 6341dd35ac0..c09d443f2d0 100644
--- a/src/gallium/state_trackers/nine/basetexture9.c
+++ b/src/gallium/state_trackers/nine/basetexture9.c
@@ -446,8 +446,10 @@ NineBaseTexture9_UpdateSamplerView( struct NineBaseTexture9 *This,
{
const struct util_format_description *desc;
struct pipe_context *pipe = This->pipe;
+ struct pipe_screen *screen = pipe->screen;
struct pipe_resource *resource = This->base.resource;
struct pipe_sampler_view templ;
+ enum pipe_format srgb_format;
unsigned i;
uint8_t swizzle[4];
@@ -500,7 +502,14 @@ NineBaseTexture9_UpdateSamplerView( struct NineBaseTexture9 *This,
}
}
- templ.format = sRGB ? util_format_srgb(resource->format) : resource->format;
+ /* if requested and supported, convert to the sRGB format */
+ srgb_format = util_format_srgb(resource->format);
+ if (sRGB && srgb_format != PIPE_FORMAT_NONE &&
+ screen->is_format_supported(screen, srgb_format,
+ resource->target, 0, resource->bind))
+ templ.format = srgb_format;
+ else
+ templ.format = resource->format;
templ.u.tex.first_layer = 0;
templ.u.tex.last_layer = resource->target == PIPE_TEXTURE_3D ?
resource->depth0 - 1 : resource->array_size - 1;