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 <davyaxel0@gmail.com>
This commit is contained in:
Axel Davy 2018-10-14 22:02:06 +02:00
parent 847861aab4
commit 739c700950
3 changed files with 14 additions and 10 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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) {