diff options
author | Axel Davy <[email protected]> | 2014-12-02 23:33:37 +0100 |
---|---|---|
committer | Emil Velikov <[email protected]> | 2015-01-22 22:16:18 +0000 |
commit | 47280d777d33c8a78fb7286892071ef31c12f604 (patch) | |
tree | 39b5c71647350e1672b925b6371c5b32cb602b61 /src/gallium | |
parent | 0abfb80dacf80c1f2d0a6a4142b9ab84695aa9e7 (diff) |
st/nine: NineBaseTexture9: update sampler view creation
While previous code was having the correct behaviour in general,
this new code is more readable (without checking all gallium formats
manually) and has a more defined behaviour for depth stencil resources.
Reviewed-by: Tiziano Bacocco <[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')
-rw-r--r-- | src/gallium/state_trackers/nine/basetexture9.c | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/src/gallium/state_trackers/nine/basetexture9.c b/src/gallium/state_trackers/nine/basetexture9.c index af4778b35c1..efa884f4ac0 100644 --- a/src/gallium/state_trackers/nine/basetexture9.c +++ b/src/gallium/state_trackers/nine/basetexture9.c @@ -436,6 +436,10 @@ NineBaseTexture9_CreatePipeResource( struct NineBaseTexture9 *This, return D3D_OK; } +#define SWIZZLE_TO_REPLACE(s) (s == UTIL_FORMAT_SWIZZLE_0 || \ + s == UTIL_FORMAT_SWIZZLE_1 || \ + s == UTIL_FORMAT_SWIZZLE_NONE) + HRESULT NineBaseTexture9_UpdateSamplerView( struct NineBaseTexture9 *This, const int sRGB ) @@ -444,6 +448,7 @@ NineBaseTexture9_UpdateSamplerView( struct NineBaseTexture9 *This, struct pipe_context *pipe = This->pipe; struct pipe_resource *resource = This->base.resource; struct pipe_sampler_view templ; + unsigned i; uint8_t swizzle[4]; DBG("This=%p sRGB=%d\n", This, sRGB); @@ -463,20 +468,34 @@ NineBaseTexture9_UpdateSamplerView( struct NineBaseTexture9 *This, swizzle[3] = PIPE_SWIZZLE_ALPHA; desc = util_format_description(resource->format); if (desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) { - /* ZZZ1 -> 0Z01 (see end of docs/source/tgsi.rst) - * XXX: but it's wrong - swizzle[0] = PIPE_SWIZZLE_ZERO; - swizzle[2] = PIPE_SWIZZLE_ZERO; */ - } else - if (desc->swizzle[0] == UTIL_FORMAT_SWIZZLE_X && - desc->swizzle[3] == UTIL_FORMAT_SWIZZLE_1) { - /* R001/RG01 -> R111/RG11 */ - if (desc->swizzle[1] == UTIL_FORMAT_SWIZZLE_0) - swizzle[1] = PIPE_SWIZZLE_ONE; - if (desc->swizzle[2] == UTIL_FORMAT_SWIZZLE_0) - swizzle[2] = PIPE_SWIZZLE_ONE; + /* msdn doc is incomplete here and wrong. + * The only formats that can be read directly here + * are DF16, DF24 and INTZ. + * Tested on win the swizzle is + * R = depth, G = B = 0, A = 1 for DF16 and DF24 + * R = G = B = A = depth for INTZ + * For the other ZS formats that can't be read directly + * but can be used as shadow map, the result is duplicated on + * all channel */ + if (This->format == D3DFMT_DF16 || + This->format == D3DFMT_DF24) { + swizzle[1] = PIPE_SWIZZLE_ZERO; + swizzle[2] = PIPE_SWIZZLE_ZERO; + swizzle[3] = PIPE_SWIZZLE_ONE; + } else { + swizzle[1] = PIPE_SWIZZLE_RED; + swizzle[2] = PIPE_SWIZZLE_RED; + swizzle[3] = PIPE_SWIZZLE_RED; + } + } else if (resource->format != PIPE_FORMAT_A8_UNORM) { + /* A8 is the only exception that should have 0.0 as default values + * for RGB. It is already what gallium does. All the other ones + * should have 1.0 for non-defined values */ + for (i = 0; i < 4; i++) { + if (SWIZZLE_TO_REPLACE(desc->swizzle[i])) + swizzle[i] = PIPE_SWIZZLE_ONE; + } } - /* but 000A remains unchanged */ templ.format = sRGB ? util_format_srgb(resource->format) : resource->format; templ.u.tex.first_layer = 0; |