From: Joshua Ashton joshua@froggi.es
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/hlsl.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index c71eac3f1..1eee4278a 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -854,14 +854,14 @@ struct vkd3d_string_buffer *hlsl_type_to_string(struct hlsl_ctx *ctx, const stru { struct vkd3d_string_buffer *string;
- static const char base_types[HLSL_TYPE_LAST_SCALAR + 1][7] = - { - "float", - "half", - "double", - "int", - "uint", - "bool", + static const char *const base_types[] = + { + [HLSL_TYPE_FLOAT] = "float", + [HLSL_TYPE_HALF] = "half", + [HLSL_TYPE_DOUBLE] = "double", + [HLSL_TYPE_INT] = "int", + [HLSL_TYPE_UINT] = "uint", + [HLSL_TYPE_BOOL] = "bool", };
if (!(string = hlsl_get_string_buffer(ctx))) @@ -915,7 +915,7 @@ struct vkd3d_string_buffer *hlsl_type_to_string(struct hlsl_ctx *ctx, const stru
case HLSL_CLASS_OBJECT: { - static const char dimensions[5][HLSL_SAMPLER_DIM_MAX + 1] = + static const char *const dimensions[] = { [HLSL_SAMPLER_DIM_1D] = "1D", [HLSL_SAMPLER_DIM_2D] = "2D",
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- Yes, this is very similar to the allocation path for textures, and it will be similar to the allocation path for UAVs. I was unable to deduplicate it in a way I was happy with...
libs/vkd3d-shader/hlsl_codegen.c | 59 ++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 24b8205c1..e358bd7c9 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -1202,6 +1202,64 @@ static void allocate_buffers(struct hlsl_ctx *ctx) } }
+static const struct hlsl_ir_var *get_reserved_sampler(struct hlsl_ctx *ctx, uint32_t index) +{ + const struct hlsl_ir_var *var; + + LIST_FOR_EACH_ENTRY(var, &ctx->extern_vars, const struct hlsl_ir_var, extern_entry) + { + if (var->last_read && var->reg_reservation.type == 's' && var->reg_reservation.index == index) + return var; + } + return NULL; +} + +static void allocate_samplers(struct hlsl_ctx *ctx) +{ + struct hlsl_ir_var *var; + uint32_t index = 0; + + LIST_FOR_EACH_ENTRY(var, &ctx->extern_vars, struct hlsl_ir_var, extern_entry) + { + if (!var->last_read || var->data_type->type != HLSL_CLASS_OBJECT + || var->data_type->base_type != HLSL_TYPE_SAMPLER) + continue; + + if (var->reg_reservation.type == 's') + { + const struct hlsl_ir_var *reserved_sampler = get_reserved_sampler(ctx, var->reg_reservation.index); + + if (reserved_sampler && reserved_sampler != var) + { + hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_OVERLAPPING_RESERVATIONS, + "Multiple samplers bound to s%u.", var->reg_reservation.index); + hlsl_note(ctx, reserved_sampler->loc, VKD3D_SHADER_LOG_ERROR, + "Sampler '%s' is already bound to s%u.", reserved_sampler->name, + var->reg_reservation.index); + } + + var->reg.id = var->reg_reservation.index; + var->reg.allocated = true; + TRACE("Allocated reserved %s to s%u.\n", var->name, index); + } + else if (!var->reg_reservation.type) + { + while (get_reserved_sampler(ctx, index)) + ++index; + + var->reg.id = index; + var->reg.allocated = true; + TRACE("Allocated %s to s%u.\n", var->name, index); + ++index; + } + else + { + hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_RESERVATION, + "Samplers must be bound to register type 's'."); + } + } +} + static const struct hlsl_ir_var *get_reserved_texture(struct hlsl_ctx *ctx, uint32_t index) { const struct hlsl_ir_var *var; @@ -1379,6 +1437,7 @@ int hlsl_emit_dxbc(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_fun allocate_textures(ctx); } allocate_semantic_registers(ctx); + allocate_samplers(ctx);
if (ctx->result) return ctx->result;
On Tue, Nov 9, 2021 at 4:41 AM Zebediah Figura zfigura@codeweavers.com wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
Yes, this is very similar to the allocation path for textures, and it will be similar to the allocation path for UAVs. I was unable to deduplicate it in a way I was happy with...
I'm going to try to do what I mentioned in https://www.winehq.org/pipermail/wine-devel/2021-August/193271.html and see if that makes things nicer here.
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/hlsl_sm1.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_sm1.c b/libs/vkd3d-shader/hlsl_sm1.c index c3d27eea1..875f521f7 100644 --- a/libs/vkd3d-shader/hlsl_sm1.c +++ b/libs/vkd3d-shader/hlsl_sm1.c @@ -352,8 +352,18 @@ static void write_sm1_uniforms(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffe if (!var->semantic.name && var->reg.allocated) { put_u32(buffer, 0); /* name */ - put_u32(buffer, vkd3d_make_u32(D3DXRS_FLOAT4, var->reg.id)); - put_u32(buffer, var->data_type->reg_size / 4); + if (var->data_type->type == HLSL_CLASS_OBJECT + && (var->data_type->base_type == HLSL_TYPE_SAMPLER + || var->data_type->base_type == HLSL_TYPE_TEXTURE)) + { + put_u32(buffer, vkd3d_make_u32(D3DXRS_SAMPLER, var->reg.id)); + put_u32(buffer, 1); + } + else + { + put_u32(buffer, vkd3d_make_u32(D3DXRS_FLOAT4, var->reg.id)); + put_u32(buffer, var->data_type->reg_size / 4); + } put_u32(buffer, 0); /* type */ put_u32(buffer, 0); /* FIXME: default value */ }
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com -- I don't really know much about SM1, so I wouldn't swear the patch is correct. But it looks sensible and it doesn't appear to be breaking totally unrelated things.
Only thing I would change is to leave "put_u32(buffer, var->data_type->reg_size / 4)" out of the conditional, since I think I remember that textures and samplers have register size 4. But it's not a big deal.
On 09/11/21 04:39, Zebediah Figura wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
libs/vkd3d-shader/hlsl_sm1.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_sm1.c b/libs/vkd3d-shader/hlsl_sm1.c index c3d27eea1..875f521f7 100644 --- a/libs/vkd3d-shader/hlsl_sm1.c +++ b/libs/vkd3d-shader/hlsl_sm1.c @@ -352,8 +352,18 @@ static void write_sm1_uniforms(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffe if (!var->semantic.name && var->reg.allocated) { put_u32(buffer, 0); /* name */
put_u32(buffer, vkd3d_make_u32(D3DXRS_FLOAT4, var->reg.id));
put_u32(buffer, var->data_type->reg_size / 4);
if (var->data_type->type == HLSL_CLASS_OBJECT
&& (var->data_type->base_type == HLSL_TYPE_SAMPLER
|| var->data_type->base_type == HLSL_TYPE_TEXTURE))
{
put_u32(buffer, vkd3d_make_u32(D3DXRS_SAMPLER, var->reg.id));
put_u32(buffer, 1);
}
else
{
put_u32(buffer, vkd3d_make_u32(D3DXRS_FLOAT4, var->reg.id));
put_u32(buffer, var->data_type->reg_size / 4);
} put_u32(buffer, 0); /* type */ put_u32(buffer, 0); /* FIXME: default value */ }
On 11/9/21 10:12 AM, Giovanni Mascellani wrote:
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
I don't really know much about SM1, so I wouldn't swear the patch is correct. But it looks sensible and it doesn't appear to be breaking totally unrelated things.
Only thing I would change is to leave "put_u32(buffer, var->data_type->reg_size / 4)" out of the conditional, since I think I remember that textures and samplers have register size 4. But it's not a big deal.
I believe they currently have reg_size 0. There's not a meaningful register size for them anyway.
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/hlsl_sm4.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index d48a41d11..e597425ae 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -974,6 +974,20 @@ static void write_sm4_dcl_constant_buffer(struct vkd3d_bytecode_buffer *buffer, write_sm4_instruction(buffer, &instr); }
+static void write_sm4_dcl_sampler(struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_var *var) +{ + const struct sm4_instruction instr = + { + .opcode = VKD3D_SM4_OP_DCL_SAMPLER, + + .dsts[0].reg.type = VKD3D_SM4_RT_SAMPLER, + .dsts[0].reg.idx = {var->reg.id}, + .dsts[0].reg.idx_count = 1, + .dst_count = 1, + }; + write_sm4_instruction(buffer, &instr); +} + static void write_sm4_dcl_texture(struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_var *var) { const struct sm4_instruction instr = @@ -1647,7 +1661,9 @@ static void write_sm4_shdr(struct hlsl_ctx *ctx, if (!var->reg.allocated || var->data_type->type != HLSL_CLASS_OBJECT) continue;
- if (var->data_type->base_type == HLSL_TYPE_TEXTURE) + if (var->data_type->base_type == HLSL_TYPE_SAMPLER) + write_sm4_dcl_sampler(&buffer, var); + else if (var->data_type->base_type == HLSL_TYPE_TEXTURE) write_sm4_dcl_texture(&buffer, var); }
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
On 09/11/21 04:39, Zebediah Figura wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
libs/vkd3d-shader/hlsl_sm4.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index d48a41d11..e597425ae 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -974,6 +974,20 @@ static void write_sm4_dcl_constant_buffer(struct vkd3d_bytecode_buffer *buffer, write_sm4_instruction(buffer, &instr); }
+static void write_sm4_dcl_sampler(struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_var *var) +{
- const struct sm4_instruction instr =
- {
.opcode = VKD3D_SM4_OP_DCL_SAMPLER,
.dsts[0].reg.type = VKD3D_SM4_RT_SAMPLER,
.dsts[0].reg.idx = {var->reg.id},
.dsts[0].reg.idx_count = 1,
.dst_count = 1,
- };
- write_sm4_instruction(buffer, &instr);
+}
- static void write_sm4_dcl_texture(struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_var *var) { const struct sm4_instruction instr =
@@ -1647,7 +1661,9 @@ static void write_sm4_shdr(struct hlsl_ctx *ctx, if (!var->reg.allocated || var->data_type->type != HLSL_CLASS_OBJECT) continue;
if (var->data_type->base_type == HLSL_TYPE_TEXTURE)
if (var->data_type->base_type == HLSL_TYPE_SAMPLER)
write_sm4_dcl_sampler(&buffer, var);
else if (var->data_type->base_type == HLSL_TYPE_TEXTURE) write_sm4_dcl_texture(&buffer, var); }
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/hlsl_sm4.c | 56 ++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index e597425ae..da31d5ae2 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -749,7 +749,7 @@ struct sm4_instruction { struct sm4_register reg; unsigned int swizzle; - } srcs[2]; + } srcs[3]; unsigned int src_count;
uint32_t idx[2]; @@ -761,6 +761,7 @@ static unsigned int sm4_swizzle_type(enum vkd3d_sm4_register_type type) switch (type) { case VKD3D_SM4_RT_IMMCONST: + case VKD3D_SM4_RT_SAMPLER: return VKD3D_SM4_SWIZZLE_NONE;
case VKD3D_SM4_RT_CONSTBUFFER: @@ -790,6 +791,14 @@ 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; + reg->idx[0] = var->reg.id; + reg->idx_count = 1; + *writemask = VKD3DSP_WRITEMASK_ALL; + } else { unsigned int offset = hlsl_offset_from_deref(deref) + var->buffer_offset; @@ -1227,6 +1236,32 @@ 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, dst); + instr.dst_count = 1; + + sm4_register_from_node(&instr.srcs[0].reg, &writemask, coords); + instr.srcs[0].swizzle = hlsl_swizzle_from_writemask(writemask); + + sm4_register_from_deref(ctx, &instr.srcs[1].reg, &writemask, 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, 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) { @@ -1497,6 +1532,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."); @@ -1510,7 +1560,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.\n"); + write_sm4_sample(ctx, buffer, resource_type, &load->node, &load->resource, &load->sampler, coords); break; } }
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
On Tue, Nov 9, 2021 at 4:56 AM Zebediah Figura zfigura@codeweavers.com wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
libs/vkd3d-shader/hlsl_sm4.c | 56 ++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index e597425ae..da31d5ae2 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c
@@ -1227,6 +1236,32 @@ 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)
Just for my own curiosity: any particular reason for write_sm4_sample() (and write_sm4_ld()) to take an explicit resource_type argument?
On 11/9/21 9:01 AM, Matteo Bruni wrote:
On Tue, Nov 9, 2021 at 4:56 AM Zebediah Figura zfigura@codeweavers.com wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
libs/vkd3d-shader/hlsl_sm4.c | 56 ++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index e597425ae..da31d5ae2 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c
@@ -1227,6 +1236,32 @@ 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)
Just for my own curiosity: any particular reason for write_sm4_sample() (and write_sm4_ld()) to take an explicit resource_type argument?
Shader model 5 or so encodes the resource type into the sample instruction as a modifier, for no apparent reason. Not sure now if I ever did that in a patch.
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
On 09/11/21 04:39, Zebediah Figura wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
libs/vkd3d-shader/hlsl_sm4.c | 56 ++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index e597425ae..da31d5ae2 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -749,7 +749,7 @@ struct sm4_instruction { struct sm4_register reg; unsigned int swizzle;
- } srcs[2];
} srcs[3]; unsigned int src_count;
uint32_t idx[2];
@@ -761,6 +761,7 @@ static unsigned int sm4_swizzle_type(enum vkd3d_sm4_register_type type) switch (type) { case VKD3D_SM4_RT_IMMCONST:
case VKD3D_SM4_RT_SAMPLER: return VKD3D_SM4_SWIZZLE_NONE; case VKD3D_SM4_RT_CONSTBUFFER:
@@ -790,6 +791,14 @@ 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;
reg->idx[0] = var->reg.id;
reg->idx_count = 1;
*writemask = VKD3DSP_WRITEMASK_ALL;
} else { unsigned int offset = hlsl_offset_from_deref(deref) + var->buffer_offset;
@@ -1227,6 +1236,32 @@ 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, dst);
- instr.dst_count = 1;
- sm4_register_from_node(&instr.srcs[0].reg, &writemask, coords);
- instr.srcs[0].swizzle = hlsl_swizzle_from_writemask(writemask);
- sm4_register_from_deref(ctx, &instr.srcs[1].reg, &writemask, 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, 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) {
@@ -1497,6 +1532,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.");
@@ -1510,7 +1560,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.\n");
}write_sm4_sample(ctx, buffer, resource_type, &load->node, &load->resource, &load->sampler, coords); break; }
On Tue, 9 Nov 2021 at 04:56, Zebediah Figura zfigura@codeweavers.com wrote:
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.\n");
Is the extra newline intentional here?
On 11/10/21 04:30, Henri Verbeet wrote:
On Tue, 9 Nov 2021 at 04:56, Zebediah Figura zfigura@codeweavers.com wrote:
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.\n");
Is the extra newline intentional here?
Nope, that was a mistake.
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com -- Might be the third time I sign off on this patch... :-P
On 09/11/21 04:39, Zebediah Figura wrote:
From: Joshua Ashton joshua@froggi.es
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
libs/vkd3d-shader/hlsl.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index c71eac3f1..1eee4278a 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -854,14 +854,14 @@ struct vkd3d_string_buffer *hlsl_type_to_string(struct hlsl_ctx *ctx, const stru { struct vkd3d_string_buffer *string;
- static const char base_types[HLSL_TYPE_LAST_SCALAR + 1][7] =
- {
"float",
"half",
"double",
"int",
"uint",
"bool",
static const char *const base_types[] =
{
[HLSL_TYPE_FLOAT] = "float",
[HLSL_TYPE_HALF] = "half",
[HLSL_TYPE_DOUBLE] = "double",
[HLSL_TYPE_INT] = "int",
[HLSL_TYPE_UINT] = "uint",
[HLSL_TYPE_BOOL] = "bool", }; if (!(string = hlsl_get_string_buffer(ctx)))
@@ -915,7 +915,7 @@ struct vkd3d_string_buffer *hlsl_type_to_string(struct hlsl_ctx *ctx, const stru
case HLSL_CLASS_OBJECT: {
static const char dimensions[5][HLSL_SAMPLER_DIM_MAX + 1] =
static const char *const dimensions[] = { [HLSL_SAMPLER_DIM_1D] = "1D", [HLSL_SAMPLER_DIM_2D] = "2D",