diff options
author | Axel Davy <[email protected]> | 2018-10-14 22:02:06 +0200 |
---|---|---|
committer | Axel Davy <[email protected]> | 2018-10-26 22:16:16 +0200 |
commit | 739c7009504b1a7b13997eda86db9afa5b8d6df9 (patch) | |
tree | afadcc5bf4da850bd56226dcd85db7185e9bc092 | |
parent | 847861aab4f5630d5eb298f1741b4f48d79e7139 (diff) |
st/nine: Enable shadow mapping for ps 1.X
We didn't implement shadow textures for ps 1.X,
assuming the case couldn't happen...
Well it does.
Fixes: https://github.com/iXit/Mesa-3D/issues/261
Signed-off-by: Axel Davy <[email protected]>
-rw-r--r-- | src/gallium/state_trackers/nine/nine_shader.c | 8 | ||||
-rw-r--r-- | src/gallium/state_trackers/nine/pixelshader9.c | 2 | ||||
-rw-r--r-- | src/gallium/state_trackers/nine/pixelshader9.h | 14 |
3 files changed, 14 insertions, 10 deletions
diff --git a/src/gallium/state_trackers/nine/nine_shader.c b/src/gallium/state_trackers/nine/nine_shader.c index 2b11958b261..145647bc3f8 100644 --- a/src/gallium/state_trackers/nine/nine_shader.c +++ b/src/gallium/state_trackers/nine/nine_shader.c @@ -771,12 +771,13 @@ TEX_with_ps1x_projection(struct shader_translator *tx, struct ureg_dst dst, { unsigned dim = 1 + ((tx->info->projected >> (2 * idx)) & 3); struct ureg_dst tmp; + boolean shadow = !!(tx->info->sampler_mask_shadow & (1 << idx)); /* dim == 1: no projection * Looks like must be disabled when it makes no * sense according the texture dimensions */ - if (dim == 1 || dim <= target) { + if (dim == 1 || (dim <= target && !shadow)) { ureg_TEX(tx->ureg, dst, target, src0, src1); } else if (dim == 4) { ureg_TXP(tx->ureg, dst, target, src0, src1); @@ -2107,9 +2108,10 @@ d3dstt_to_tgsi_tex_shadow(BYTE sampler_type) static inline unsigned ps1x_sampler_type(const struct nine_shader_info *info, unsigned stage) { + boolean shadow = !!(info->sampler_mask_shadow & (1 << stage)); switch ((info->sampler_ps1xtypes >> (stage * 2)) & 0x3) { - case 1: return TGSI_TEXTURE_1D; - case 0: return TGSI_TEXTURE_2D; + case 1: return shadow ? TGSI_TEXTURE_SHADOW1D : TGSI_TEXTURE_1D; + case 0: return shadow ? TGSI_TEXTURE_SHADOW2D : TGSI_TEXTURE_2D; case 3: return TGSI_TEXTURE_3D; default: return TGSI_TEXTURE_CUBE; diff --git a/src/gallium/state_trackers/nine/pixelshader9.c b/src/gallium/state_trackers/nine/pixelshader9.c index 6f053f709bf..5d79019a1bc 100644 --- a/src/gallium/state_trackers/nine/pixelshader9.c +++ b/src/gallium/state_trackers/nine/pixelshader9.c @@ -164,7 +164,7 @@ NinePixelShader9_GetVariant( struct NinePixelShader9 *This ) info.const_b_base = NINE_CONST_B_BASE(device->max_ps_const_f) / 16; info.byte_code = This->byte_code.tokens; info.sampler_mask_shadow = key & 0xffff; - info.sampler_ps1xtypes = key; + info.sampler_ps1xtypes = (key >> 16) & 0xffff; info.fog_enable = device->context.rs[D3DRS_FOGENABLE]; info.fog_mode = device->context.rs[D3DRS_FOGTABLEMODE]; info.force_color_in_centroid = key >> 34 & 1; diff --git a/src/gallium/state_trackers/nine/pixelshader9.h b/src/gallium/state_trackers/nine/pixelshader9.h index accd00a6a8c..bcbadd71057 100644 --- a/src/gallium/state_trackers/nine/pixelshader9.h +++ b/src/gallium/state_trackers/nine/pixelshader9.h @@ -68,13 +68,16 @@ NinePixelShader9_UpdateKey( struct NinePixelShader9 *ps, struct nine_context *context ) { uint16_t samplers_shadow; - uint32_t samplers_ps1_types; + uint16_t samplers_ps1_types; uint16_t projected; uint64_t key; BOOL res; + samplers_shadow = (uint16_t)((context->samplers_shadow & NINE_PS_SAMPLERS_MASK) >> NINE_SAMPLER_PS(0)); + key = samplers_shadow & ps->sampler_mask; + if (unlikely(ps->byte_code.version < 0x20)) { - /* no depth textures, but variable targets */ + /* variable targets */ uint32_t m = ps->sampler_mask; samplers_ps1_types = 0; while (m) { @@ -82,10 +85,9 @@ NinePixelShader9_UpdateKey( struct NinePixelShader9 *ps, m &= ~(1 << s); samplers_ps1_types |= (context->texture[s].enabled ? context->texture[s].pstype : 1) << (s * 2); } - key = samplers_ps1_types; - } else { - samplers_shadow = (uint16_t)((context->samplers_shadow & NINE_PS_SAMPLERS_MASK) >> NINE_SAMPLER_PS(0)); - key = samplers_shadow & ps->sampler_mask; + /* Note: For ps 1.X, only samplers 0 1 2 and 3 are available (except 1.4 where 4 and 5 are available). + * Thus there is no overflow of samplers_ps1_types. */ + key |= samplers_ps1_types << 16; } if (ps->byte_code.version < 0x30) { |