vkd3d-shader/hlsl: Parse SampleCmpLevelZero() method.

This commit is contained in:
Nikolay Sivov 2023-05-26 11:14:07 +02:00 committed by Alexandre Julliard
parent c33219c97b
commit a2e85a8a76
Notes: Alexandre Julliard 2023-05-29 22:32:35 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Zebediah Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/206
4 changed files with 16 additions and 2 deletions

View File

@ -2445,6 +2445,7 @@ static void dump_ir_resource_load(struct vkd3d_string_buffer *buffer, const stru
[HLSL_RESOURCE_LOAD] = "load_resource", [HLSL_RESOURCE_LOAD] = "load_resource",
[HLSL_RESOURCE_SAMPLE] = "sample", [HLSL_RESOURCE_SAMPLE] = "sample",
[HLSL_RESOURCE_SAMPLE_CMP] = "sample_cmp", [HLSL_RESOURCE_SAMPLE_CMP] = "sample_cmp",
[HLSL_RESOURCE_SAMPLE_CMP_LZ] = "sample_cmp_lz",
[HLSL_RESOURCE_SAMPLE_LOD] = "sample_lod", [HLSL_RESOURCE_SAMPLE_LOD] = "sample_lod",
[HLSL_RESOURCE_SAMPLE_LOD_BIAS] = "sample_biased", [HLSL_RESOURCE_SAMPLE_LOD_BIAS] = "sample_biased",
[HLSL_RESOURCE_SAMPLE_GRAD] = "sample_grad", [HLSL_RESOURCE_SAMPLE_GRAD] = "sample_grad",

View File

@ -616,6 +616,7 @@ enum hlsl_resource_load_type
HLSL_RESOURCE_LOAD, HLSL_RESOURCE_LOAD,
HLSL_RESOURCE_SAMPLE, HLSL_RESOURCE_SAMPLE,
HLSL_RESOURCE_SAMPLE_CMP, HLSL_RESOURCE_SAMPLE_CMP,
HLSL_RESOURCE_SAMPLE_CMP_LZ,
HLSL_RESOURCE_SAMPLE_LOD, HLSL_RESOURCE_SAMPLE_LOD,
HLSL_RESOURCE_SAMPLE_LOD_BIAS, HLSL_RESOURCE_SAMPLE_LOD_BIAS,
HLSL_RESOURCE_SAMPLE_GRAD, HLSL_RESOURCE_SAMPLE_GRAD,

View File

@ -3862,7 +3862,7 @@ static bool add_sample_cmp_method_call(struct hlsl_ctx *ctx, struct list *instrs
const struct hlsl_type *object_type = object->data_type; const struct hlsl_type *object_type = object->data_type;
const unsigned int sampler_dim = hlsl_sampler_dim_count(object_type->sampler_dim); const unsigned int sampler_dim = hlsl_sampler_dim_count(object_type->sampler_dim);
const unsigned int offset_dim = hlsl_offset_dim_count(object_type->sampler_dim); const unsigned int offset_dim = hlsl_offset_dim_count(object_type->sampler_dim);
struct hlsl_resource_load_params load_params = {.type = HLSL_RESOURCE_SAMPLE_CMP}; struct hlsl_resource_load_params load_params = { 0 };
const struct hlsl_type *sampler_type; const struct hlsl_type *sampler_type;
struct hlsl_ir_node *load; struct hlsl_ir_node *load;
@ -3872,6 +3872,11 @@ static bool add_sample_cmp_method_call(struct hlsl_ctx *ctx, struct list *instrs
return raise_invalid_method_object_type(ctx, object_type, name, loc); return raise_invalid_method_object_type(ctx, object_type, name, loc);
} }
if (!strcmp(name, "SampleCmpLevelZero"))
load_params.type = HLSL_RESOURCE_SAMPLE_CMP_LZ;
else
load_params.type = HLSL_RESOURCE_SAMPLE_CMP;
if (params->args_count < 3 || params->args_count > 5 + !!offset_dim) if (params->args_count < 3 || params->args_count > 5 + !!offset_dim)
{ {
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT, hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT,
@ -4191,6 +4196,7 @@ object_methods[] =
{ "Sample", add_sample_method_call }, { "Sample", add_sample_method_call },
{ "SampleBias", add_sample_lod_method_call }, { "SampleBias", add_sample_lod_method_call },
{ "SampleCmp", add_sample_cmp_method_call }, { "SampleCmp", add_sample_cmp_method_call },
{ "SampleCmpLevelZero", add_sample_cmp_method_call },
{ "SampleGrad", add_sample_grad_method_call }, { "SampleGrad", add_sample_grad_method_call },
{ "SampleLevel", add_sample_lod_method_call }, { "SampleLevel", add_sample_lod_method_call },
}; };

View File

@ -4113,6 +4113,10 @@ static void write_sm4_sample(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer
instr.opcode = VKD3D_SM4_OP_SAMPLE_C; instr.opcode = VKD3D_SM4_OP_SAMPLE_C;
break; break;
case HLSL_RESOURCE_SAMPLE_CMP_LZ:
instr.opcode = VKD3D_SM4_OP_SAMPLE_C_LZ;
break;
case HLSL_RESOURCE_SAMPLE_LOD: case HLSL_RESOURCE_SAMPLE_LOD:
instr.opcode = VKD3D_SM4_OP_SAMPLE_LOD; instr.opcode = VKD3D_SM4_OP_SAMPLE_LOD;
break; break;
@ -4159,7 +4163,8 @@ static void write_sm4_sample(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer
sm4_src_from_node(&instr.srcs[4], load->ddy.node, VKD3DSP_WRITEMASK_ALL); sm4_src_from_node(&instr.srcs[4], load->ddy.node, VKD3DSP_WRITEMASK_ALL);
instr.src_count += 2; instr.src_count += 2;
} }
else if (load->load_type == HLSL_RESOURCE_SAMPLE_CMP) else if (load->load_type == HLSL_RESOURCE_SAMPLE_CMP
|| load->load_type == HLSL_RESOURCE_SAMPLE_CMP_LZ)
{ {
sm4_src_from_node(&instr.srcs[3], load->cmp.node, VKD3DSP_WRITEMASK_ALL); sm4_src_from_node(&instr.srcs[3], load->cmp.node, VKD3DSP_WRITEMASK_ALL);
++instr.src_count; ++instr.src_count;
@ -4963,6 +4968,7 @@ static void write_sm4_resource_load(struct hlsl_ctx *ctx,
case HLSL_RESOURCE_SAMPLE: case HLSL_RESOURCE_SAMPLE:
case HLSL_RESOURCE_SAMPLE_CMP: case HLSL_RESOURCE_SAMPLE_CMP:
case HLSL_RESOURCE_SAMPLE_CMP_LZ:
case HLSL_RESOURCE_SAMPLE_LOD: case HLSL_RESOURCE_SAMPLE_LOD:
case HLSL_RESOURCE_SAMPLE_LOD_BIAS: case HLSL_RESOURCE_SAMPLE_LOD_BIAS:
case HLSL_RESOURCE_SAMPLE_GRAD: case HLSL_RESOURCE_SAMPLE_GRAD: