vkd3d-shader/hlsl: Allow lowering separate sampler arrays on deref offset 0.

This commit is contained in:
Francisco Casas 2024-12-04 15:44:48 -03:00 committed by Henri Verbeet
parent 2c9269ac3a
commit aa3a716249
Notes: Henri Verbeet 2024-12-10 15:58:19 +01:00
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1303
2 changed files with 16 additions and 7 deletions

View File

@ -2806,6 +2806,16 @@ static struct hlsl_type *clone_texture_array_as_combined_sampler_array(struct hl
return ctx->builtin_types.sampler[type->sampler_dim];
}
static bool deref_offset_is_zero(struct hlsl_ctx *ctx, const struct hlsl_deref *deref)
{
enum hlsl_regset regset = hlsl_deref_get_regset(ctx, deref);
unsigned int index;
if (!hlsl_regset_index_from_deref(ctx, deref, regset, &index))
return false;
return index == 0;
}
/* Lower samples from separate texture and sampler variables to samples from
* synthetized combined samplers. That is, translate SM4-style samples in the
* source to SM1-style samples in the bytecode. */
@ -2832,10 +2842,9 @@ static bool lower_separate_samples(struct hlsl_ctx *ctx, struct hlsl_ir_node *in
VKD3D_ASSERT(hlsl_type_is_resource(resource->data_type));
VKD3D_ASSERT(hlsl_type_is_resource(sampler->data_type));
if (sampler->data_type->class == HLSL_CLASS_ARRAY)
if (sampler->data_type->class == HLSL_CLASS_ARRAY && !deref_offset_is_zero(ctx, &load->sampler))
{
/* Only supported by d3dcompiler if the sampler is the first component
* of the sampler array. */
/* Not supported by d3dcompiler. */
hlsl_error(ctx, &instr->loc, VKD3D_SHADER_ERROR_HLSL_NOT_IMPLEMENTED,
"Lower separated samples with sampler arrays.");
return false;

View File

@ -114,7 +114,7 @@ if(sm<4) probe (0, 0) rgba(1, 1, 1, 11)
if(sm>=4) probe (0, 0) rgba(10, 10, 10, 11)
[pixel shader todo(sm<4)]
[pixel shader]
Texture2D tex;
sampler sam[2];
@ -124,7 +124,7 @@ float4 main() : sv_target
}
[test]
todo(sm<4 | msl) draw quad
todo(msl) draw quad
probe (0, 0) rgba (21, 21, 21, 11)
@ -206,7 +206,7 @@ if(sm<4) probe (0, 0) rgba(453021, 453021, 453021, 111111)
if(sm>=4) probe (0, 0) rgba(12333, 12333, 12333, 111111)
[pixel shader todo(sm<4)]
[pixel shader]
Texture2D texA;
sampler samA[2];
Texture2D texB[2];
@ -221,7 +221,7 @@ float4 main() : sv_target
}
[test]
todo(sm<4 | msl) draw quad
todo(msl) draw quad
if(sm<4) probe (0, 0) rgba(4351, 4351, 4351, 1111)
if(sm>=4) probe (0, 0) rgba(3125, 3125, 3125, 1111)