Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
On 01/12/21 17:14, Matteo Bruni wrote:
From: Zebediah Figura zfigura@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com
changelog: Fix typo in the call to sm4_register_from_deref() for the sampler argument.
libs/vkd3d-shader/hlsl_sm4.c | 59 ++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index c0c26f80..1c0fea53 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -753,7 +753,7 @@ struct sm4_instruction struct sm4_register reg; enum vkd3d_sm4_swizzle_type swizzle_type; unsigned int swizzle;
- } srcs[2];
} srcs[3]; unsigned int src_count;
uint32_t idx[2];
@@ -776,6 +776,16 @@ static void sm4_register_from_deref(struct hlsl_ctx *ctx, struct sm4_register *r reg->idx_count = 1; *writemask = VKD3DSP_WRITEMASK_ALL; }
else if (data_type->type == HLSL_CLASS_OBJECT && data_type->base_type == HLSL_TYPE_SAMPLER)
{
reg->type = VKD3D_SM4_RT_SAMPLER;
reg->dim = VKD3D_SM4_DIMENSION_NONE;
if (swizzle_type)
*swizzle_type = VKD3D_SM4_SWIZZLE_NONE;
reg->idx[0] = var->reg.id;
reg->idx_count = 1;
*writemask = VKD3DSP_WRITEMASK_ALL;
} else { unsigned int offset = hlsl_offset_from_deref_safe(ctx, deref) + var->buffer_offset;
@@ -1238,6 +1248,34 @@ static void write_sm4_ld(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buf write_sm4_instruction(buffer, &instr); }
+static void write_sm4_sample(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer,
const struct hlsl_type *resource_type, const struct hlsl_ir_node *dst,
const struct hlsl_deref *resource, const struct hlsl_deref *sampler, const struct hlsl_ir_node *coords)
+{
- struct sm4_instruction instr;
- unsigned int writemask;
- memset(&instr, 0, sizeof(instr));
- instr.opcode = VKD3D_SM4_OP_SAMPLE;
- sm4_register_from_node(&instr.dsts[0].reg, &instr.dsts[0].writemask, NULL, dst);
- instr.dst_count = 1;
- sm4_register_from_node(&instr.srcs[0].reg, &writemask, &instr.srcs[0].swizzle_type, coords);
- instr.srcs[0].swizzle = hlsl_swizzle_from_writemask(writemask);
- sm4_register_from_deref(ctx, &instr.srcs[1].reg, &writemask,
&instr.srcs[1].swizzle_type, resource, resource_type);
- instr.srcs[1].swizzle = hlsl_map_swizzle(hlsl_swizzle_from_writemask(writemask), instr.dsts[0].writemask);
- sm4_register_from_deref(ctx, &instr.srcs[2].reg, &writemask,
&instr.srcs[2].swizzle_type, sampler, sampler->var->data_type);
- instr.src_count = 3;
- write_sm4_instruction(buffer, &instr);
+}
- static void write_sm4_expr(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_expr *expr) {
@@ -1516,6 +1554,21 @@ static void write_sm4_resource_load(struct hlsl_ctx *ctx, const struct hlsl_type *resource_type = load->resource.var->data_type; const struct hlsl_ir_node *coords = load->coords.node;
- if (load->sampler.var)
- {
const struct hlsl_type *sampler_type = load->sampler.var->data_type;
assert(sampler_type->type == HLSL_CLASS_OBJECT);
assert(sampler_type->base_type == HLSL_TYPE_SAMPLER);
assert(sampler_type->sampler_dim == HLSL_SAMPLER_DIM_GENERIC);
if (!load->sampler.var->is_uniform)
{
hlsl_fixme(ctx, load->node.loc, "Sample using non-uniform sampler variable.");
return;
}
- }
if (!load->resource.var->is_uniform) { hlsl_fixme(ctx, load->node.loc, "Load from non-uniform resource variable.");
@@ -1529,7 +1582,9 @@ static void write_sm4_resource_load(struct hlsl_ctx *ctx, break;
case HLSL_RESOURCE_SAMPLE:
hlsl_fixme(ctx, load->node.loc, "Resource sample instruction.");
if (!load->sampler.var)
hlsl_fixme(ctx, load->node.loc, "SM4 combined sample expression.");
}write_sm4_sample(ctx, buffer, resource_type, &load->node, &load->resource, &load->sampler, coords); break; }