Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- 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 c0c26f804..c36aa5618 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[1].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; } }
Signed-off-by: Zebediah Figura zfigura@codeweavers.com ---
This depends on 220151.
libs/vkd3d-shader/hlsl_codegen.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index d9f78601d..2c620c7d7 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -233,6 +233,11 @@ static void replace_node(struct hlsl_ir_node *old, struct hlsl_ir_node *new) hlsl_src_remove(src); hlsl_src_from_node(src, new); } +} + +static void replace_and_remove_node(struct hlsl_ir_node *old, struct hlsl_ir_node *new) +{ + replace_node(old, new); list_remove(&old->entry); hlsl_free_instr(old); } @@ -413,7 +418,7 @@ static bool copy_propagation_analyze_load(struct hlsl_ctx *ctx, struct hlsl_ir_l return false; list_add_before(&node->entry, &swizzle_node->node.entry);
- replace_node(node, &swizzle_node->node); + replace_and_remove_node(node, &swizzle_node->node);
return true; } @@ -503,7 +508,7 @@ static bool fold_redundant_casts(struct hlsl_ctx *ctx, struct hlsl_ir_node *inst if (hlsl_types_are_equal(src_type, dst_type) || (src_type->base_type == dst_type->base_type && is_vec1(src_type) && is_vec1(dst_type))) { - replace_node(&expr->node, expr->operands[0].node); + replace_and_remove_node(&expr->node, expr->operands[0].node); return true; } } @@ -718,7 +723,7 @@ static bool fold_constants(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, voi }
list_add_before(&expr->node.entry, &res->node.entry); - replace_node(&expr->node, &res->node); + replace_and_remove_node(&expr->node, &res->node); return true; }
@@ -738,7 +743,7 @@ static bool remove_trivial_swizzles(struct hlsl_ctx *ctx, struct hlsl_ir_node *i if (((swizzle->swizzle >> (2 * i)) & 3) != i) return false;
- replace_node(instr, swizzle->val.node); + replace_and_remove_node(instr, swizzle->val.node);
return true; }
Hi,
On 23/11/21 02:45, Zebediah Figura wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
This depends on 220151.
It also clashes with 220153, though it's easy to fix that.
I am not particularly opposed to this patch, but what is the reason? In most (if not all) cases, if you replace a node and don't remove it, it will eventually be removed by DCE, so the result is going to be the same in the end (maybe processing will be a little slower, but I don't think that's a big problem).
There are some cases in which it is necessary to immediately remove the replaced node, because otherwise optimization enters an infinite loop. Since you introduced replace_and_remove_node I guess you already discovered that the hard way! :-P
But are there cases in which it is necessary to _not_ remove the replaced node? Because if there aren't, I would just always remove it as it happens now, which seems to me the simplest solution.
Thanks, Giovanni.
On 11/23/21 3:46 AM, Giovanni Mascellani wrote:
Hi,
On 23/11/21 02:45, Zebediah Figura wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
This depends on 220151.
It also clashes with 220153, though it's easy to fix that.
I am not particularly opposed to this patch, but what is the reason? In most (if not all) cases, if you replace a node and don't remove it, it will eventually be removed by DCE, so the result is going to be the same in the end (maybe processing will be a little slower, but I don't think that's a big problem).
Yes, although that requires you to run DCE afterwards. Which is extra work, that's not particularly necessary if you already know what needs to be deleted. It also means that if you're going to run an optimization pass in a loop you need to make sure there's a DCE pass in that loop.
There are some cases in which it is necessary to immediately remove the replaced node, because otherwise optimization enters an infinite loop. Since you introduced replace_and_remove_node I guess you already discovered that the hard way! :-P
But are there cases in which it is necessary to _not_ remove the replaced node? Because if there aren't, I would just always remove it as it happens now, which seems to me the simplest solution.
Patches 3 and 4 in this series reuse the replaced node. It's not *necessary* to do that, but it works, and saves the trouble of allocating a new one. I'm not opposed if there's a consensus of "don't do that", though.
Hi,
On 23/11/21 17:17, Zebediah Figura wrote:
But are there cases in which it is necessary to _not_ remove the replaced node? Because if there aren't, I would just always remove it as it happens now, which seems to me the simplest solution.
Patches 3 and 4 in this series reuse the replaced node. It's not *necessary* to do that, but it works, and saves the trouble of allocating a new one. I'm not opposed if there's a consensus of "don't do that", though.
As I said in another subthread, I think that deleting the old cast node and re-creating it would make the code more readable, therefore would be preferable. But I can live with your solution.
Giovanni.
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
On 23/11/21 02:45, Zebediah Figura wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
This depends on 220151.
libs/vkd3d-shader/hlsl_codegen.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index d9f78601d..2c620c7d7 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -233,6 +233,11 @@ static void replace_node(struct hlsl_ir_node *old, struct hlsl_ir_node *new) hlsl_src_remove(src); hlsl_src_from_node(src, new); } +}
+static void replace_and_remove_node(struct hlsl_ir_node *old, struct hlsl_ir_node *new) +{
- replace_node(old, new); list_remove(&old->entry); hlsl_free_instr(old); }
@@ -413,7 +418,7 @@ static bool copy_propagation_analyze_load(struct hlsl_ctx *ctx, struct hlsl_ir_l return false; list_add_before(&node->entry, &swizzle_node->node.entry);
- replace_node(node, &swizzle_node->node);
replace_and_remove_node(node, &swizzle_node->node);
return true; }
@@ -503,7 +508,7 @@ static bool fold_redundant_casts(struct hlsl_ctx *ctx, struct hlsl_ir_node *inst if (hlsl_types_are_equal(src_type, dst_type) || (src_type->base_type == dst_type->base_type && is_vec1(src_type) && is_vec1(dst_type))) {
replace_node(&expr->node, expr->operands[0].node);
replace_and_remove_node(&expr->node, expr->operands[0].node); return true; } }
@@ -718,7 +723,7 @@ static bool fold_constants(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, voi }
list_add_before(&expr->node.entry, &res->node.entry);
- replace_node(&expr->node, &res->node);
- replace_and_remove_node(&expr->node, &res->node); return true; }
@@ -738,7 +743,7 @@ static bool remove_trivial_swizzles(struct hlsl_ctx *ctx, struct hlsl_ir_node *i if (((swizzle->swizzle >> (2 * i)) & 3) != i) return false;
- replace_node(instr, swizzle->val.node);
replace_and_remove_node(instr, swizzle->val.node);
return true; }
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- Makefile.am | 1 - libs/vkd3d-shader/hlsl_codegen.c | 33 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/Makefile.am b/Makefile.am index be3d8ec15..4010533af 100644 --- a/Makefile.am +++ b/Makefile.am @@ -290,7 +290,6 @@ XFAIL_TESTS = \ tests/conditional.shader_test \ tests/hlsl-array-dimension.shader_test \ tests/hlsl-bool-cast.shader_test \ - tests/hlsl-comma.shader_test \ tests/hlsl-cross.shader_test \ tests/hlsl-duplicate-modifiers.shader_test \ tests/hlsl-for.shader_test \ diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 2c620c7d7..b69df47a0 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -242,6 +242,38 @@ static void replace_and_remove_node(struct hlsl_ir_node *old, struct hlsl_ir_nod hlsl_free_instr(old); }
+/* Lower casts from vec1 to vecN to swizzles. */ +static bool lower_broadcasts(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context) +{ + const struct hlsl_type *src_type, *dst_type; + struct hlsl_ir_expr *cast; + + if (instr->type != HLSL_IR_EXPR) + return false; + cast = hlsl_ir_expr(instr); + src_type = cast->operands[0].node->data_type; + dst_type = cast->node.data_type; + + if (cast->op == HLSL_OP1_CAST + && src_type->type <= HLSL_CLASS_VECTOR && dst_type->type <= HLSL_CLASS_VECTOR + && src_type->dimx == 1) + { + struct hlsl_ir_swizzle *swizzle; + + if (!(swizzle = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(X, X, X, X), dst_type->dimx, &cast->node, &cast->node.loc))) + return false; + list_add_after(&cast->node.entry, &swizzle->node.entry); + + cast->node.data_type = hlsl_get_scalar_type(ctx, dst_type->base_type); + replace_node(&cast->node, &swizzle->node); + hlsl_src_remove(&swizzle->val); + hlsl_src_from_node(&swizzle->val, &cast->node); + return true; + } + + return false; +} + /* The copy propagation pass scans the code trying to reconstruct, for * each load, which is the store that last wrote to that * variable. When this happens, the load can be replaced with the node @@ -1666,6 +1698,7 @@ int hlsl_emit_dxbc(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_fun append_output_var_copy(ctx, &body->instrs, entry_func->return_var); }
+ transform_ir(ctx, lower_broadcasts, body, NULL); while (transform_ir(ctx, fold_redundant_casts, body, NULL)); do {
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
On 23/11/21 02:45, Zebediah Figura wrote:
+/* Lower casts from vec1 to vecN to swizzles. */ +static bool lower_broadcasts(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context) +{
- const struct hlsl_type *src_type, *dst_type;
- struct hlsl_ir_expr *cast;
- if (instr->type != HLSL_IR_EXPR)
return false;
- cast = hlsl_ir_expr(instr);
- src_type = cast->operands[0].node->data_type;
- dst_type = cast->node.data_type;
- if (cast->op == HLSL_OP1_CAST
&& src_type->type <= HLSL_CLASS_VECTOR && dst_type->type <= HLSL_CLASS_VECTOR
&& src_type->dimx == 1)
- {
struct hlsl_ir_swizzle *swizzle;
if (!(swizzle = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(X, X, X, X), dst_type->dimx, &cast->node, &cast->node.loc)))
return false;
list_add_after(&cast->node.entry, &swizzle->node.entry);
cast->node.data_type = hlsl_get_scalar_type(ctx, dst_type->base_type);
replace_node(&cast->node, &swizzle->node);
hlsl_src_remove(&swizzle->val);
hlsl_src_from_node(&swizzle->val, &cast->node);
I guess this answers to the question in my previous email (WRT why you want replace_node to not delete the replaced node).
This solution seems correct, but I cannot refrain from thinking the code would be more readable if you just created a new cast and just removed (and possibly deleted, but that's not very relevant) the old one.
While I am all for avoiding useless allocation round trips, I don't think that doing so at the expense of code readability is a good idea, until it is shown that that allocation really is a performance bottleneck.
Thanks, Giovanni.
On Tue, Nov 23, 2021 at 2:46 AM Zebediah Figura zfigura@codeweavers.com wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
Makefile.am | 1 - libs/vkd3d-shader/hlsl_codegen.c | 33 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/Makefile.am b/Makefile.am index be3d8ec15..4010533af 100644 --- a/Makefile.am +++ b/Makefile.am @@ -290,7 +290,6 @@ XFAIL_TESTS = \ tests/conditional.shader_test \ tests/hlsl-array-dimension.shader_test \ tests/hlsl-bool-cast.shader_test \
tests/hlsl-comma.shader_test \ tests/hlsl-cross.shader_test \ tests/hlsl-duplicate-modifiers.shader_test \ tests/hlsl-for.shader_test \
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 2c620c7d7..b69df47a0 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -242,6 +242,38 @@ static void replace_and_remove_node(struct hlsl_ir_node *old, struct hlsl_ir_nod hlsl_free_instr(old); }
+/* Lower casts from vec1 to vecN to swizzles. */ +static bool lower_broadcasts(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context) +{
- const struct hlsl_type *src_type, *dst_type;
- struct hlsl_ir_expr *cast;
- if (instr->type != HLSL_IR_EXPR)
return false;
- cast = hlsl_ir_expr(instr);
- src_type = cast->operands[0].node->data_type;
- dst_type = cast->node.data_type;
- if (cast->op == HLSL_OP1_CAST
&& src_type->type <= HLSL_CLASS_VECTOR && dst_type->type <= HLSL_CLASS_VECTOR
&& src_type->dimx == 1)
- {
struct hlsl_ir_swizzle *swizzle;
if (!(swizzle = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(X, X, X, X), dst_type->dimx, &cast->node, &cast->node.loc)))
return false;
list_add_after(&cast->node.entry, &swizzle->node.entry);
cast->node.data_type = hlsl_get_scalar_type(ctx, dst_type->base_type);
replace_node(&cast->node, &swizzle->node);
hlsl_src_remove(&swizzle->val);
hlsl_src_from_node(&swizzle->val, &cast->node);
This seems a bit opaque to me. What do you think about the attached change on top of this patch?
Hi,
On 26/11/21 20:37, Matteo Bruni wrote:
This seems a bit opaque to me. What do you think about the attached change on top of this patch?
Personally, I don't find this fixup easier to read than the original.
Giovanni.
On 11/26/21 13:37, Matteo Bruni wrote:
On Tue, Nov 23, 2021 at 2:46 AM Zebediah Figura zfigura@codeweavers.com wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
Makefile.am | 1 - libs/vkd3d-shader/hlsl_codegen.c | 33 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/Makefile.am b/Makefile.am index be3d8ec15..4010533af 100644 --- a/Makefile.am +++ b/Makefile.am @@ -290,7 +290,6 @@ XFAIL_TESTS = \ tests/conditional.shader_test \ tests/hlsl-array-dimension.shader_test \ tests/hlsl-bool-cast.shader_test \
tests/hlsl-comma.shader_test \ tests/hlsl-cross.shader_test \ tests/hlsl-duplicate-modifiers.shader_test \ tests/hlsl-for.shader_test \
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 2c620c7d7..b69df47a0 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -242,6 +242,38 @@ static void replace_and_remove_node(struct hlsl_ir_node *old, struct hlsl_ir_nod hlsl_free_instr(old); }
+/* Lower casts from vec1 to vecN to swizzles. */ +static bool lower_broadcasts(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context) +{
- const struct hlsl_type *src_type, *dst_type;
- struct hlsl_ir_expr *cast;
- if (instr->type != HLSL_IR_EXPR)
return false;
- cast = hlsl_ir_expr(instr);
- src_type = cast->operands[0].node->data_type;
- dst_type = cast->node.data_type;
- if (cast->op == HLSL_OP1_CAST
&& src_type->type <= HLSL_CLASS_VECTOR && dst_type->type <= HLSL_CLASS_VECTOR
&& src_type->dimx == 1)
- {
struct hlsl_ir_swizzle *swizzle;
if (!(swizzle = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(X, X, X, X), dst_type->dimx, &cast->node, &cast->node.loc)))
return false;
list_add_after(&cast->node.entry, &swizzle->node.entry);
cast->node.data_type = hlsl_get_scalar_type(ctx, dst_type->base_type);
replace_node(&cast->node, &swizzle->node);
hlsl_src_remove(&swizzle->val);
hlsl_src_from_node(&swizzle->val, &cast->node);
This seems a bit opaque to me. What do you think about the attached change on top of this patch?
Unlike Giovanni I do think that helps :-)
Although at this point I'm more and more inclined to agree with Giovanni's original suggestion, i.e. just create a new node anyway, and get rid of patch 2/6.
On Mon, Nov 29, 2021 at 6:06 PM Zebediah Figura zfigura@codeweavers.com wrote:
On 11/26/21 13:37, Matteo Bruni wrote:
On Tue, Nov 23, 2021 at 2:46 AM Zebediah Figura zfigura@codeweavers.com wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
Makefile.am | 1 - libs/vkd3d-shader/hlsl_codegen.c | 33 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/Makefile.am b/Makefile.am index be3d8ec15..4010533af 100644 --- a/Makefile.am +++ b/Makefile.am @@ -290,7 +290,6 @@ XFAIL_TESTS = \ tests/conditional.shader_test \ tests/hlsl-array-dimension.shader_test \ tests/hlsl-bool-cast.shader_test \
tests/hlsl-comma.shader_test \ tests/hlsl-cross.shader_test \ tests/hlsl-duplicate-modifiers.shader_test \ tests/hlsl-for.shader_test \
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 2c620c7d7..b69df47a0 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -242,6 +242,38 @@ static void replace_and_remove_node(struct hlsl_ir_node *old, struct hlsl_ir_nod hlsl_free_instr(old); }
+/* Lower casts from vec1 to vecN to swizzles. */ +static bool lower_broadcasts(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context) +{
- const struct hlsl_type *src_type, *dst_type;
- struct hlsl_ir_expr *cast;
- if (instr->type != HLSL_IR_EXPR)
return false;
- cast = hlsl_ir_expr(instr);
- src_type = cast->operands[0].node->data_type;
- dst_type = cast->node.data_type;
- if (cast->op == HLSL_OP1_CAST
&& src_type->type <= HLSL_CLASS_VECTOR && dst_type->type <= HLSL_CLASS_VECTOR
&& src_type->dimx == 1)
- {
struct hlsl_ir_swizzle *swizzle;
if (!(swizzle = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(X, X, X, X), dst_type->dimx, &cast->node, &cast->node.loc)))
return false;
list_add_after(&cast->node.entry, &swizzle->node.entry);
cast->node.data_type = hlsl_get_scalar_type(ctx, dst_type->base_type);
replace_node(&cast->node, &swizzle->node);
hlsl_src_remove(&swizzle->val);
hlsl_src_from_node(&swizzle->val, &cast->node);
This seems a bit opaque to me. What do you think about the attached change on top of this patch?
Unlike Giovanni I do think that helps :-)
Although at this point I'm more and more inclined to agree with Giovanni's original suggestion, i.e. just create a new node anyway, and get rid of patch 2/6.
Seems fair. Let's see how bad the rebase will be...
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- Makefile.am | 1 - libs/vkd3d-shader/hlsl_codegen.c | 32 ++++++++++++++++++++++++++++++++ libs/vkd3d-shader/hlsl_sm4.c | 15 ++++++--------- 3 files changed, 38 insertions(+), 10 deletions(-)
diff --git a/Makefile.am b/Makefile.am index 4010533af..88bdc0ee4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -290,7 +290,6 @@ XFAIL_TESTS = \ tests/conditional.shader_test \ tests/hlsl-array-dimension.shader_test \ tests/hlsl-bool-cast.shader_test \ - tests/hlsl-cross.shader_test \ tests/hlsl-duplicate-modifiers.shader_test \ tests/hlsl-for.shader_test \ tests/hlsl-function-overload.shader_test \ diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index b69df47a0..e61c6de6f 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -653,6 +653,37 @@ static bool split_struct_copies(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr return true; }
+static bool lower_narrowing_casts(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context) +{ + const struct hlsl_type *src_type, *dst_type; + struct hlsl_ir_expr *cast; + + if (instr->type != HLSL_IR_EXPR) + return false; + cast = hlsl_ir_expr(instr); + src_type = cast->operands[0].node->data_type; + dst_type = cast->node.data_type; + + if (cast->op == HLSL_OP1_CAST + && src_type->type <= HLSL_CLASS_VECTOR && dst_type->type <= HLSL_CLASS_VECTOR + && dst_type->dimx < src_type->dimx) + { + struct hlsl_ir_swizzle *swizzle; + + if (!(swizzle = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(X, Y, Z, W), dst_type->dimx, &cast->node, &cast->node.loc))) + return false; + list_add_after(&cast->node.entry, &swizzle->node.entry); + + cast->node.data_type = hlsl_get_vector_type(ctx, dst_type->base_type, src_type->dimx); + replace_node(&cast->node, &swizzle->node); + hlsl_src_remove(&swizzle->val); + hlsl_src_from_node(&swizzle->val, &cast->node); + return true; + } + + return false; +} + static bool fold_constants(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context) { struct hlsl_ir_constant *arg1, *arg2 = NULL, *res; @@ -1706,6 +1737,7 @@ int hlsl_emit_dxbc(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_fun progress |= transform_ir(ctx, split_struct_copies, body, NULL); } while (progress); + transform_ir(ctx, lower_narrowing_casts, body, NULL); do { progress = transform_ir(ctx, fold_constants, body, NULL); diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index c36aa5618..ed6de2a11 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1298,9 +1298,8 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, { const struct hlsl_type *src_type = arg1->data_type;
- /* Narrowing casts need to be lowered. */ - if (src_type->dimx != expr->node.data_type->dimx) - hlsl_fixme(ctx, expr->node.loc, "Narrowing cast.\n"); + /* Narrowing casts were already lowered. */ + assert(src_type->dimx == expr->node.data_type->dimx);
switch (src_type->base_type) { @@ -1388,9 +1387,8 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, { const struct hlsl_type *src_type = arg1->data_type;
- /* Narrowing casts need to be lowered. */ - if (src_type->dimx != expr->node.data_type->dimx) - hlsl_fixme(ctx, expr->node.loc, "Narrowing cast."); + /* Narrowing casts were already lowered. */ + assert(src_type->dimx == expr->node.data_type->dimx);
switch (src_type->base_type) { @@ -1433,9 +1431,8 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, { const struct hlsl_type *src_type = arg1->data_type;
- /* Narrowing casts need to be lowered. */ - if (src_type->dimx != expr->node.data_type->dimx) - hlsl_fixme(ctx, expr->node.loc, "SM4 narrowing cast.\n"); + /* Narrowing casts were already lowered. */ + assert(src_type->dimx == expr->node.data_type->dimx);
switch (src_type->base_type) {
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com ---
On 23/11/21 02:45, Zebediah Figura wrote:
+static bool lower_narrowing_casts(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context) +{
- const struct hlsl_type *src_type, *dst_type;
- struct hlsl_ir_expr *cast;
- if (instr->type != HLSL_IR_EXPR)
return false;
- cast = hlsl_ir_expr(instr);
- src_type = cast->operands[0].node->data_type;
- dst_type = cast->node.data_type;
- if (cast->op == HLSL_OP1_CAST
&& src_type->type <= HLSL_CLASS_VECTOR && dst_type->type <= HLSL_CLASS_VECTOR
&& dst_type->dimx < src_type->dimx)
- {
struct hlsl_ir_swizzle *swizzle;
if (!(swizzle = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(X, Y, Z, W), dst_type->dimx, &cast->node, &cast->node.loc)))
return false;
list_add_after(&cast->node.entry, &swizzle->node.entry);
cast->node.data_type = hlsl_get_vector_type(ctx, dst_type->base_type, src_type->dimx);
replace_node(&cast->node, &swizzle->node);
hlsl_src_remove(&swizzle->val);
hlsl_src_from_node(&swizzle->val, &cast->node);
return true;
- }
- return false;
+}
The same comments of 3/6 apply here.
While reviewing this patch it occurred to me that both this and 3/6 can change the type of a node, by turning a scalar into a vector of dimension 1. I guess that by this point the code is sufficiently low-level that we don't care any more, but since this a bit vague, I'd propose to identify the point where all scalars in the IR can be converted to vectors of dimension 1, and from that point on scalars are not used any more. What do you think of that? (I like strongly types data...)
@@ -1706,6 +1737,7 @@ int hlsl_emit_dxbc(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_fun progress |= transform_ir(ctx, split_struct_copies, body, NULL); } while (progress);
- transform_ir(ctx, lower_narrowing_casts, body, NULL); do { progress = transform_ir(ctx, fold_constants, body, NULL);
Is there a specific reason for how you are ordering this pass (and 3/6?). Not that I have any problem with it, it is just that 4/6 seems similar to 3/6, but you put them in two different places.
For the record, I have another pass in my development patches that generalizes both 3/6 and 4/6 and also works with matrices. It will take some time to have it accepted, if it will ever be, so it should not be a reason to delay these two patches.
Thanks, Giovanni.
On 11/23/21 5:10 AM, Giovanni Mascellani wrote:
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
On 23/11/21 02:45, Zebediah Figura wrote:
+static bool lower_narrowing_casts(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context) +{
- const struct hlsl_type *src_type, *dst_type;
- struct hlsl_ir_expr *cast;
- if (instr->type != HLSL_IR_EXPR)
return false;
- cast = hlsl_ir_expr(instr);
- src_type = cast->operands[0].node->data_type;
- dst_type = cast->node.data_type;
- if (cast->op == HLSL_OP1_CAST
&& src_type->type <= HLSL_CLASS_VECTOR && dst_type->type <= HLSL_CLASS_VECTOR
&& dst_type->dimx < src_type->dimx)
- {
struct hlsl_ir_swizzle *swizzle;
if (!(swizzle = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(X, Y, Z, W), dst_type->dimx, &cast->node, &cast->node.loc)))
return false;
list_add_after(&cast->node.entry, &swizzle->node.entry);
cast->node.data_type = hlsl_get_vector_type(ctx, dst_type->base_type, src_type->dimx);
replace_node(&cast->node, &swizzle->node);
hlsl_src_remove(&swizzle->val);
hlsl_src_from_node(&swizzle->val, &cast->node);
return true;
- }
- return false;
+}
The same comments of 3/6 apply here.
While reviewing this patch it occurred to me that both this and 3/6 can change the type of a node, by turning a scalar into a vector of dimension 1. I guess that by this point the code is sufficiently low-level that we don't care any more, but since this a bit vague, I'd propose to identify the point where all scalars in the IR can be converted to vectors of dimension 1, and from that point on scalars are not used any more. What do you think of that? (I like strongly types data...)
I don't know that it's worth the trouble. Any given operation should be able to support vec1's as well as scalars. We have a helper for that, after all.
@@ -1706,6 +1737,7 @@ int hlsl_emit_dxbc(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_fun progress |= transform_ir(ctx, split_struct_copies, body, NULL); } while (progress);
- transform_ir(ctx, lower_narrowing_casts, body, NULL); do { progress = transform_ir(ctx, fold_constants, body, NULL);
Is there a specific reason for how you are ordering this pass (and 3/6?). Not that I have any problem with it, it is just that 4/6 seems similar to 3/6, but you put them in two different places.
For the record, I have another pass in my development patches that generalizes both 3/6 and 4/6 and also works with matrices. It will take some time to have it accepted, if it will ever be, so it should not be a reason to delay these two patches.
I don't think there's any particular reason, no.
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/hlsl.c | 18 +-- libs/vkd3d-shader/hlsl.h | 8 +- libs/vkd3d-shader/hlsl.l | 2 +- libs/vkd3d-shader/hlsl.y | 194 +++++++++++++++---------------- libs/vkd3d-shader/hlsl_codegen.c | 26 ++--- libs/vkd3d-shader/hlsl_sm1.c | 8 +- libs/vkd3d-shader/hlsl_sm4.c | 32 ++--- 7 files changed, 144 insertions(+), 144 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 9824c56dc..4a289dd5c 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -22,40 +22,40 @@ #include "hlsl.h" #include <stdio.h>
-void hlsl_note(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, +void hlsl_note(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc, enum vkd3d_shader_log_level level, const char *fmt, ...) { va_list args;
va_start(args, fmt); - vkd3d_shader_vnote(ctx->message_context, &loc, level, fmt, args); + vkd3d_shader_vnote(ctx->message_context, loc, level, fmt, args); va_end(args); }
-void hlsl_error(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, +void hlsl_error(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc, enum vkd3d_shader_error error, const char *fmt, ...) { va_list args;
va_start(args, fmt); - vkd3d_shader_verror(ctx->message_context, &loc, error, fmt, args); + vkd3d_shader_verror(ctx->message_context, loc, error, fmt, args); va_end(args);
if (!ctx->result) ctx->result = VKD3D_ERROR_INVALID_SHADER; }
-void hlsl_warning(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, +void hlsl_warning(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc, enum vkd3d_shader_error error, const char *fmt, ...) { va_list args;
va_start(args, fmt); - vkd3d_shader_vwarning(ctx->message_context, &loc, error, fmt, args); + vkd3d_shader_vwarning(ctx->message_context, loc, error, fmt, args); va_end(args); }
-void hlsl_fixme(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, const char *fmt, ...) +void hlsl_fixme(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc, const char *fmt, ...) { struct vkd3d_string_buffer *string; va_list args; @@ -64,7 +64,7 @@ void hlsl_fixme(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, co string = hlsl_get_string_buffer(ctx); vkd3d_string_buffer_printf(string, "Aborting due to not yet implemented feature: "); vkd3d_string_buffer_vprintf(string, fmt, args); - vkd3d_shader_error(ctx->message_context, &loc, VKD3D_SHADER_ERROR_HLSL_NOT_IMPLEMENTED, "%s", string->buffer); + vkd3d_shader_error(ctx->message_context, loc, VKD3D_SHADER_ERROR_HLSL_NOT_IMPLEMENTED, "%s", string->buffer); hlsl_release_string_buffer(ctx, string); va_end(args);
@@ -1950,7 +1950,7 @@ int hlsl_compile_shader(const struct vkd3d_shader_code *hlsl, const struct vkd3d { const struct vkd3d_shader_location loc = {.source_name = compile_info->source_name};
- hlsl_error(&ctx, loc, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, + hlsl_error(&ctx, &loc, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Entry point "%s" is not defined.", entry_point); hlsl_ctx_cleanup(&ctx); return VKD3D_ERROR_INVALID_SHADER; diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index e7bdb45e8..ec43f62e7 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -727,13 +727,13 @@ struct hlsl_ir_var *hlsl_new_var(struct hlsl_ctx *ctx, const char *name, struct struct hlsl_ir_load *hlsl_new_var_load(struct hlsl_ctx *ctx, struct hlsl_ir_var *var, const struct vkd3d_shader_location loc);
-void hlsl_error(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, +void hlsl_error(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc, enum vkd3d_shader_error error, const char *fmt, ...) VKD3D_PRINTF_FUNC(4, 5); -void hlsl_fixme(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, +void hlsl_fixme(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc, const char *fmt, ...) VKD3D_PRINTF_FUNC(3, 4); -void hlsl_warning(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, +void hlsl_warning(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc, enum vkd3d_shader_error error, const char *fmt, ...) VKD3D_PRINTF_FUNC(4, 5); -void hlsl_note(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, +void hlsl_note(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc, enum vkd3d_shader_log_level level, const char *fmt, ...) VKD3D_PRINTF_FUNC(4, 5);
void hlsl_push_scope(struct hlsl_ctx *ctx); diff --git a/libs/vkd3d-shader/hlsl.l b/libs/vkd3d-shader/hlsl.l index caf8fe8f9..e9281ec36 100644 --- a/libs/vkd3d-shader/hlsl.l +++ b/libs/vkd3d-shader/hlsl.l @@ -65,7 +65,7 @@ ANY (.) {RESERVED4} { struct hlsl_ctx *ctx = yyget_extra(yyscanner);
- hlsl_error(ctx, *yylloc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, + hlsl_error(ctx, yylloc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Reserved keyword "%s" used.", yytext); }
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index ff35c09e5..97dc98911 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -111,7 +111,7 @@ int yylex(HLSL_YYSTYPE *yylval_param, HLSL_YYLTYPE *yylloc_param, void *yyscanne
static void yyerror(YYLTYPE *loc, void *scanner, struct hlsl_ctx *ctx, const char *s) { - hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "%s", s); + hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "%s", s); }
static struct hlsl_ir_node *node_from_list(struct list *list) @@ -137,7 +137,7 @@ static void destroy_instr_list(struct list *list) static void check_invalid_matrix_modifiers(struct hlsl_ctx *ctx, DWORD modifiers, struct vkd3d_shader_location loc) { if (modifiers & HLSL_MODIFIERS_MAJORITY_MASK) - hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, + hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "'row_major' and 'column_major' modifiers are only allowed for matrices."); }
@@ -281,7 +281,7 @@ static struct hlsl_ir_node *add_implicit_conversion(struct hlsl_ctx *ctx, struct src_string = hlsl_type_to_string(ctx, src_type); dst_string = hlsl_type_to_string(ctx, dst_type); if (src_string && dst_string) - hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, + hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Can't implicitly convert from %s to %s.", src_string->buffer, dst_string->buffer); hlsl_release_string_buffer(ctx, src_string); hlsl_release_string_buffer(ctx, dst_string); @@ -289,7 +289,7 @@ static struct hlsl_ir_node *add_implicit_conversion(struct hlsl_ctx *ctx, struct }
if (dst_type->dimx * dst_type->dimy < src_type->dimx * src_type->dimy) - hlsl_warning(ctx, *loc, VKD3D_SHADER_WARNING_HLSL_IMPLICIT_TRUNCATION, "Implicit truncation of %s type.", + hlsl_warning(ctx, loc, VKD3D_SHADER_WARNING_HLSL_IMPLICIT_TRUNCATION, "Implicit truncation of %s type.", src_type->type == HLSL_CLASS_VECTOR ? "vector" : "matrix");
if (!(cast = hlsl_new_cast(ctx, node, dst_type, loc))) @@ -305,14 +305,14 @@ static DWORD add_modifiers(struct hlsl_ctx *ctx, DWORD modifiers, DWORD mod, con struct vkd3d_string_buffer *string;
if ((string = hlsl_modifiers_to_string(ctx, mod))) - hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, + hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "Modifier '%s' was already specified.", string->buffer); hlsl_release_string_buffer(ctx, string); return modifiers; } if ((mod & HLSL_MODIFIERS_MAJORITY_MASK) && (modifiers & HLSL_MODIFIERS_MAJORITY_MASK)) { - hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, + hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "'row_major' and 'column_major' modifiers are mutually exclusive."); return modifiers; } @@ -516,7 +516,7 @@ static struct hlsl_ir_jump *add_return(struct hlsl_ctx *ctx, struct list *instrs } else if (ctx->cur_function->return_var) { - hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_RETURN, "Non-void function must return a value."); + hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_INVALID_RETURN, "Non-void function must return a value."); return NULL; }
@@ -601,9 +601,9 @@ static struct hlsl_ir_load *add_array_load(struct hlsl_ctx *ctx, struct list *in else { if (expr_type->type == HLSL_CLASS_SCALAR) - hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_INDEX, "Scalar expressions cannot be array-indexed."); + hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_INVALID_INDEX, "Scalar expressions cannot be array-indexed."); else - hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_INDEX, "Expression cannot be array-indexed."); + hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_INVALID_INDEX, "Expression cannot be array-indexed."); return NULL; }
@@ -661,7 +661,7 @@ static struct hlsl_type *apply_type_modifiers(struct hlsl_ctx *ctx, struct hlsl_ *modifiers &= ~HLSL_TYPE_MODIFIERS_MASK;
if ((new_type->modifiers & HLSL_MODIFIER_ROW_MAJOR) && (new_type->modifiers & HLSL_MODIFIER_COLUMN_MAJOR)) - hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, + hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "'row_major' and 'column_major' modifiers are mutually exclusive.");
return new_type; @@ -696,7 +696,7 @@ static struct list *gen_struct_fields(struct hlsl_ctx *ctx, struct hlsl_type *ty field->semantic = v->semantic; if (v->initializer.args_count) { - hlsl_error(ctx, v->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Illegal initializer on a struct field."); + hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Illegal initializer on a struct field."); free_parse_initializer(&v->initializer); } list_add_tail(list, &field->entry); @@ -739,12 +739,12 @@ static bool add_typedef(struct hlsl_ctx *ctx, DWORD modifiers, struct hlsl_type
if ((type->modifiers & HLSL_MODIFIER_COLUMN_MAJOR) && (type->modifiers & HLSL_MODIFIER_ROW_MAJOR)) - hlsl_error(ctx, v->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, + hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "'row_major' and 'column_major' modifiers are mutually exclusive.");
ret = hlsl_scope_add_type(ctx->cur_scope, type); if (!ret) - hlsl_error(ctx, v->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED, + hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "Type '%s' is already defined.", v->name); vkd3d_free(v); } @@ -761,7 +761,7 @@ static bool add_func_parameter(struct hlsl_ctx *ctx, struct list *list, assert(param->type->modifiers & HLSL_MODIFIERS_MAJORITY_MASK);
if ((param->modifiers & HLSL_STORAGE_OUT) && (param->modifiers & HLSL_STORAGE_UNIFORM)) - hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, + hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "Parameter '%s' is declared as both "out" and "uniform".", param->name);
if (!(var = hlsl_new_var(ctx, param->name, param->type, loc, ¶m->semantic, param->modifiers, ¶m->reg_reservation))) @@ -928,7 +928,7 @@ static bool expr_common_shape(struct hlsl_ctx *ctx, struct hlsl_type *t1, struct struct vkd3d_string_buffer *string;
if ((string = hlsl_type_to_string(ctx, t1))) - hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, + hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Expression of type "%s" cannot be used in a numeric expression.", string->buffer); hlsl_release_string_buffer(ctx, string); return false; @@ -939,7 +939,7 @@ static bool expr_common_shape(struct hlsl_ctx *ctx, struct hlsl_type *t1, struct struct vkd3d_string_buffer *string;
if ((string = hlsl_type_to_string(ctx, t2))) - hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, + hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Expression of type "%s" cannot be used in a numeric expression.", string->buffer); hlsl_release_string_buffer(ctx, string); return false; @@ -951,7 +951,7 @@ static bool expr_common_shape(struct hlsl_ctx *ctx, struct hlsl_type *t1, struct struct vkd3d_string_buffer *t2_string = hlsl_type_to_string(ctx, t2);
if (t1_string && t2_string) - hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, + hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Expression data types "%s" and "%s" are incompatible.", t1_string->buffer, t2_string->buffer); hlsl_release_string_buffer(ctx, t1_string); @@ -1191,7 +1191,7 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in { if (lhs->type == HLSL_IR_EXPR && hlsl_ir_expr(lhs)->op == HLSL_OP1_CAST) { - hlsl_fixme(ctx, lhs->loc, "Cast on the LHS."); + hlsl_fixme(ctx, &lhs->loc, "Cast on the LHS."); vkd3d_free(store); return NULL; } @@ -1201,11 +1201,11 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in unsigned int width, s = swizzle->swizzle;
if (lhs->data_type->type == HLSL_CLASS_MATRIX) - hlsl_fixme(ctx, lhs->loc, "Matrix assignment with a writemask."); + hlsl_fixme(ctx, &lhs->loc, "Matrix assignment with a writemask.");
if (!invert_swizzle(&s, &writemask, &width)) { - hlsl_error(ctx, lhs->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_WRITEMASK, "Invalid writemask."); + hlsl_error(ctx, &lhs->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_WRITEMASK, "Invalid writemask."); vkd3d_free(store); return NULL; } @@ -1222,7 +1222,7 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in } else { - hlsl_error(ctx, lhs->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_LVALUE, "Invalid lvalue."); + hlsl_error(ctx, &lhs->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_LVALUE, "Invalid lvalue."); vkd3d_free(store); return NULL; } @@ -1251,7 +1251,7 @@ static bool add_increment(struct hlsl_ctx *ctx, struct list *instrs, bool decrem struct hlsl_ir_constant *one;
if (lhs->data_type->modifiers & HLSL_MODIFIER_CONST) - hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_MODIFIES_CONST, + hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_MODIFIES_CONST, "Argument to %s%screment operator is const.", post ? "post" : "pre", decrement ? "de" : "in");
if (!(one = hlsl_new_uint_constant(ctx, 1, loc))) @@ -1286,7 +1286,7 @@ static void struct_var_initializer(struct hlsl_ctx *ctx, struct list *list, stru
if (initializer_size(initializer) != hlsl_type_component_count(type)) { - hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT, + hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT, "Expected %u components in initializer, but got %u.", hlsl_type_component_count(type), initializer_size(initializer)); free_parse_initializer(initializer); @@ -1317,7 +1317,7 @@ static void struct_var_initializer(struct hlsl_ctx *ctx, struct list *list, stru } else { - hlsl_fixme(ctx, node->loc, "Implicit cast in structure initializer."); + hlsl_fixme(ctx, &node->loc, "Implicit cast in structure initializer."); } }
@@ -1381,7 +1381,7 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t local = false;
if ((modifiers & HLSL_STORAGE_UNIFORM) && (modifiers & HLSL_STORAGE_STATIC)) - hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, + hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "Variable '%s' is declared as both "uniform" and "static".", var->name);
/* Mark it as uniform. We need to do this here since synthetic @@ -1392,9 +1392,9 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t
if ((func = hlsl_get_func_decl(ctx, var->name))) { - hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED, + hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "'%s' is already defined as a function.", var->name); - hlsl_note(ctx, func->loc, VKD3D_SHADER_LOG_ERROR, + hlsl_note(ctx, &func->loc, VKD3D_SHADER_LOG_ERROR, "'%s' was previously defined here.", var->name); } } @@ -1408,19 +1408,19 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t struct vkd3d_string_buffer *string;
if ((string = hlsl_modifiers_to_string(ctx, modifiers & invalid))) - hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, + hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "Modifiers '%s' are not allowed on local variables.", string->buffer); hlsl_release_string_buffer(ctx, string); } if (var->semantic.name) - hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC, + hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC, "Semantics are not allowed on local variables."); }
if ((type->modifiers & HLSL_MODIFIER_CONST) && !v->initializer.args_count && !(modifiers & (HLSL_STORAGE_STATIC | HLSL_STORAGE_UNIFORM))) { - hlsl_error(ctx, v->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_INITIALIZER, + hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_INITIALIZER, "Const variable "%s" is missing an initializer.", var->name); hlsl_free_var(var); vkd3d_free(v); @@ -1431,9 +1431,9 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t { struct hlsl_ir_var *old = hlsl_get_var(ctx->cur_scope, var->name);
- hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED, + hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "Variable "%s" was already declared in this scope.", var->name); - hlsl_note(ctx, old->loc, VKD3D_SHADER_LOG_ERROR, ""%s" was previously declared here.", old->name); + hlsl_note(ctx, &old->loc, VKD3D_SHADER_LOG_ERROR, ""%s" was previously declared here.", old->name); hlsl_free_var(var); vkd3d_free(v); continue; @@ -1449,7 +1449,7 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t { if (size < type->dimx * type->dimy) { - hlsl_error(ctx, v->loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT, + hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT, "Expected %u components in numeric initializer, but got %u.", type->dimx * type->dimy, size); free_parse_initializer(&v->initializer); @@ -1460,7 +1460,7 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t if ((type->type == HLSL_CLASS_STRUCT || type->type == HLSL_CLASS_ARRAY) && hlsl_type_component_count(type) != size) { - hlsl_error(ctx, v->loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT, + hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT, "Expected %u components in initializer, but got %u.", hlsl_type_component_count(type), size); free_parse_initializer(&v->initializer); vkd3d_free(v); @@ -1482,14 +1482,14 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t } if (v->arrays.count) { - hlsl_fixme(ctx, v->loc, "Array initializer."); + hlsl_fixme(ctx, &v->loc, "Array initializer."); free_parse_initializer(&v->initializer); vkd3d_free(v); continue; } if (v->initializer.args_count > 1) { - hlsl_fixme(ctx, v->loc, "Complex initializer."); + hlsl_fixme(ctx, &v->loc, "Complex initializer."); free_parse_initializer(&v->initializer); vkd3d_free(v); continue; @@ -1711,7 +1711,7 @@ static struct list *add_call(struct hlsl_ctx *ctx, const char *name,
if ((decl = find_function_call(ctx, name, params))) { - hlsl_fixme(ctx, loc, "Call to user-defined function "%s".", name); + hlsl_fixme(ctx, &loc, "Call to user-defined function "%s".", name); free_parse_initializer(params); return NULL; } @@ -1720,7 +1720,7 @@ static struct list *add_call(struct hlsl_ctx *ctx, const char *name, { if (intrinsic->param_count >= 0 && params->args_count != intrinsic->param_count) { - hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT, + hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT, "Wrong number of arguments to function '%s': expected %u, but got %u.\n", name, intrinsic->param_count, params->args_count); free_parse_initializer(params); @@ -1738,7 +1738,7 @@ static struct list *add_call(struct hlsl_ctx *ctx, const char *name, struct vkd3d_string_buffer *string;
if ((string = hlsl_type_to_string(ctx, params->args[i]->data_type))) - hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, + hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Wrong type for argument %u of '%s': expected a numeric type, but got '%s'.\n", i + 1, name, string->buffer); hlsl_release_string_buffer(ctx, string); @@ -1756,7 +1756,7 @@ static struct list *add_call(struct hlsl_ctx *ctx, const char *name, } else { - hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Function "%s" is not defined.", name); + hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Function "%s" is not defined.", name); free_parse_initializer(params); return NULL; } @@ -1775,7 +1775,7 @@ static struct list *add_constructor(struct hlsl_ctx *ctx, struct hlsl_type *type char name[23];
if (type->type == HLSL_CLASS_MATRIX) - hlsl_fixme(ctx, loc, "Matrix constructor."); + hlsl_fixme(ctx, &loc, "Matrix constructor.");
sprintf(name, "<constructor-%x>", counter++); if (!(var = hlsl_new_synthetic_var(ctx, name, type, loc))) @@ -1791,7 +1791,7 @@ static struct list *add_constructor(struct hlsl_ctx *ctx, struct hlsl_type *type struct vkd3d_string_buffer *string;
if ((string = hlsl_type_to_string(ctx, arg->data_type))) - hlsl_error(ctx, arg->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, + hlsl_error(ctx, &arg->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Invalid type %s for constructor argument.", string->buffer); hlsl_release_string_buffer(ctx, string); continue; @@ -1836,7 +1836,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl struct vkd3d_string_buffer *string;
if ((string = hlsl_type_to_string(ctx, object_type))) - hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, + hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Type '%s' does not have methods.", string->buffer); hlsl_release_string_buffer(ctx, string); return false; @@ -1853,7 +1853,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
if (params->args_count < 1 || params->args_count > 3) { - hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT, + hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT, "Wrong number of arguments to method 'Load': expected 1, 2, or 3, but got %u.", params->args_count); return false; } @@ -1881,7 +1881,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
if (params->args_count != 2 && params->args_count != 3) { - hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT, + hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT, "Wrong number of arguments to method 'Sample': expected 2 or 3, but got %u.", params->args_count); return false; } @@ -1895,7 +1895,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl struct vkd3d_string_buffer *string;
if ((string = hlsl_type_to_string(ctx, sampler_type))) - hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, + hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Wrong type for argument 0 of Sample(): expected 'sampler', but got '%s'.", string->buffer); hlsl_release_string_buffer(ctx, string); return false; @@ -1920,7 +1920,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl struct vkd3d_string_buffer *string;
if ((string = hlsl_type_to_string(ctx, object_type))) - hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, + hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Method '%s' is not defined on type '%s'.", name, string->buffer); hlsl_release_string_buffer(ctx, string); return false; @@ -2162,16 +2162,16 @@ hlsl_prog: { if (decl->has_body && $2.decl->has_body) { - hlsl_error(ctx, $2.decl->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED, + hlsl_error(ctx, &$2.decl->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "Function "%s" is already defined.", $2.name); - hlsl_note(ctx, decl->loc, VKD3D_SHADER_LOG_ERROR, ""%s" was previously defined here.", $2.name); + hlsl_note(ctx, &decl->loc, VKD3D_SHADER_LOG_ERROR, ""%s" was previously defined here.", $2.name); YYABORT; } else if (!hlsl_types_are_equal(decl->return_type, $2.decl->return_type)) { - hlsl_error(ctx, $2.decl->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED, + hlsl_error(ctx, &$2.decl->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "Function "%s" was already declared with a different return type.", $2.name); - hlsl_note(ctx, decl->loc, VKD3D_SHADER_LOG_ERROR, ""%s" was previously declared here.", $2.name); + hlsl_note(ctx, &decl->loc, VKD3D_SHADER_LOG_ERROR, ""%s" was previously declared here.", $2.name); YYABORT; } } @@ -2182,7 +2182,7 @@ hlsl_prog: | hlsl_prog declaration_statement { if (!list_empty($2)) - hlsl_fixme(ctx, @2, "Uniform initializer."); + hlsl_fixme(ctx, &@2, "Uniform initializer."); destroy_instr_list($2); } | hlsl_prog preproc_directive @@ -2192,7 +2192,7 @@ buffer_declaration: buffer_type any_identifier colon_attribute { if ($3.semantic.name) - hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC, "Semantics are not allowed on buffers."); + hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC, "Semantics are not allowed on buffers.");
if (!(ctx->cur_buffer = hlsl_new_buffer(ctx, $1, $2, &$3.reg_reservation, @2))) YYABORT; @@ -2249,10 +2249,10 @@ struct_declaration: if (!$3) { if (!$2->name) - hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, + hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Anonymous struct type must declare a variable."); if (modifiers) - hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, + hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "Modifiers are not allowed on struct type declarations."); }
@@ -2274,14 +2274,14 @@ named_struct_spec:
if (hlsl_get_var(ctx->cur_scope, $2)) { - hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_REDEFINED, ""%s" is already declared as a variable.", $2); + hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_REDEFINED, ""%s" is already declared as a variable.", $2); YYABORT; }
ret = hlsl_scope_add_type(ctx->cur_scope, $$); if (!ret) { - hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "Struct "%s" is already defined.", $2); + hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "Struct "%s" is already defined.", $2); YYABORT; } } @@ -2312,9 +2312,9 @@ fields_list: { if ((existing = get_struct_field($$, field->name))) { - hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_REDEFINED, + hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "Field "%s" is already defined.", field->name); - hlsl_note(ctx, existing->loc, VKD3D_SHADER_LOG_ERROR, + hlsl_note(ctx, &existing->loc, VKD3D_SHADER_LOG_ERROR, "'%s' was previously defined here.", field->name); vkd3d_free(field); } @@ -2343,7 +2343,7 @@ field: struct vkd3d_string_buffer *string;
if ((string = hlsl_modifiers_to_string(ctx, modifiers))) - hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, + hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "Modifiers '%s' are not allowed on struct fields.", string->buffer); hlsl_release_string_buffer(ctx, string); } @@ -2373,21 +2373,21 @@ func_prototype:
if ($1) { - hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, + hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "Modifiers are not allowed on functions."); YYABORT; } if ((var = hlsl_get_var(ctx->globals, $3))) { - hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_REDEFINED, + hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_REDEFINED, ""%s" is already declared as a variable.", $3); - hlsl_note(ctx, var->loc, VKD3D_SHADER_LOG_ERROR, + hlsl_note(ctx, &var->loc, VKD3D_SHADER_LOG_ERROR, ""%s" was previously declared here.", $3); YYABORT; } if (hlsl_types_are_equal($2, ctx->builtin_types.Void) && $7.semantic.name) { - hlsl_error(ctx, @7, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC, + hlsl_error(ctx, &@7, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC, "Semantics are not allowed on void functions."); }
@@ -2494,7 +2494,7 @@ param_list: $$ = $1; if (!add_func_parameter(ctx, $$, &$3, @3)) { - hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_REDEFINED, + hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "Parameter "%s" is already declared.", $3.name); YYABORT; } @@ -2529,7 +2529,7 @@ input_mods: struct vkd3d_string_buffer *string;
if ((string = hlsl_modifiers_to_string(ctx, $2))) - hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, + hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "Modifier "%s" was already specified.", string->buffer); hlsl_release_string_buffer(ctx, string); YYABORT; @@ -2578,14 +2578,14 @@ type:
string = hlsl_type_to_string(ctx, $3); if (string) - hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, + hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Vector base type %s is not scalar.", string->buffer); hlsl_release_string_buffer(ctx, string); YYABORT; } if ($5 < 1 || $5 > 4) { - hlsl_error(ctx, @5, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE, + hlsl_error(ctx, &@5, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE, "Vector size %d is not between 1 and 4.", $5); YYABORT; } @@ -2604,20 +2604,20 @@ type:
string = hlsl_type_to_string(ctx, $3); if (string) - hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, + hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Matrix base type %s is not scalar.", string->buffer); hlsl_release_string_buffer(ctx, string); YYABORT; } if ($5 < 1 || $5 > 4) { - hlsl_error(ctx, @5, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE, + hlsl_error(ctx, &@5, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE, "Matrix row count %d is not between 1 and 4.", $5); YYABORT; } if ($7 < 1 || $7 > 4) { - hlsl_error(ctx, @7, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE, + hlsl_error(ctx, &@7, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE, "Matrix column count %d is not between 1 and 4.", $7); YYABORT; } @@ -2668,7 +2668,7 @@ type:
string = hlsl_type_to_string(ctx, $3); if (string) - hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, + hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Texture data type %s is not scalar or vector.\n", string->buffer); hlsl_release_string_buffer(ctx, string); } @@ -2683,7 +2683,7 @@ type: { $$ = hlsl_get_type(ctx->cur_scope, $2, true); if ($$->type != HLSL_CLASS_STRUCT) - hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_REDEFINED, ""%s" redefined as a structure.", $2); + hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_REDEFINED, ""%s" redefined as a structure.", $2); vkd3d_free($2); }
@@ -2706,7 +2706,7 @@ typedef: if ($2 & ~HLSL_TYPE_MODIFIERS_MASK) { struct parse_variable_def *v, *v_next; - hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, + hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "Storage modifiers are not allowed on typedefs."); LIST_FOR_EACH_ENTRY_SAFE(v, v_next, $4, struct parse_variable_def, entry) vkd3d_free(v); @@ -2828,7 +2828,7 @@ arrays:
if (!size) { - hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE, + hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE, "Array size is not a positive integer constant."); vkd3d_free($$.sizes); YYABORT; @@ -2836,7 +2836,7 @@ arrays:
if (size > 65536) { - hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE, + hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE, "Array size %u is not between 1 and 65536.", size); vkd3d_free($$.sizes); YYABORT; @@ -3001,7 +3001,7 @@ selection_statement: struct vkd3d_string_buffer *string;
if ((string = hlsl_type_to_string(ctx, condition->data_type))) - hlsl_error(ctx, instr->node.loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, + hlsl_error(ctx, &instr->node.loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "if condition type %s is not scalar.", string->buffer); hlsl_release_string_buffer(ctx, string); } @@ -3103,7 +3103,7 @@ primary_expr:
if (!(var = hlsl_get_var(ctx->cur_scope, $1))) { - hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Variable "%s" is not defined.", $1); + hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Variable "%s" is not defined.", $1); YYABORT; } if (!(load = hlsl_new_var_load(ctx, var, @1))) @@ -3137,7 +3137,7 @@ primary_expr: } else { - hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Identifier "%s" is not declared.\n", $1); + hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Identifier "%s" is not declared.\n", $1); YYABORT; } } @@ -3173,7 +3173,7 @@ postfix_expr:
if (!(field = get_struct_field(type->e.elements, $3))) { - hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Field "%s" is not defined.", $3); + hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Field "%s" is not defined.", $3); YYABORT; }
@@ -3187,7 +3187,7 @@ postfix_expr:
if (!(swizzle = get_swizzle(ctx, node, $3, &@3))) { - hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Invalid swizzle "%s".", $3); + hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Invalid swizzle "%s".", $3); YYABORT; } list_add_tail($1, &swizzle->node.entry); @@ -3195,7 +3195,7 @@ postfix_expr: } else { - hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Invalid subscript "%s".", $3); + hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Invalid subscript "%s".", $3); YYABORT; } } @@ -3209,7 +3209,7 @@ postfix_expr:
if (index->data_type->type != HLSL_CLASS_SCALAR) { - hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Array index is not scalar."); + hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Array index is not scalar."); destroy_instr_list($1); YYABORT; } @@ -3234,7 +3234,7 @@ postfix_expr: { if ($1) { - hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, + hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "Modifiers are not allowed on constructors."); free_parse_initializer(&$4); YYABORT; @@ -3244,7 +3244,7 @@ postfix_expr: struct vkd3d_string_buffer *string;
if ((string = hlsl_type_to_string(ctx, $2))) - hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, + hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Constructor data type %s is not numeric.", string->buffer); hlsl_release_string_buffer(ctx, string); free_parse_initializer(&$4); @@ -3252,7 +3252,7 @@ postfix_expr: } if ($2->dimx * $2->dimy != initializer_size(&$4)) { - hlsl_error(ctx, @4, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT, + hlsl_error(ctx, &@4, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT, "Expected %u components in constructor, but got %u.", $2->dimx * $2->dimy, initializer_size(&$4)); free_parse_initializer(&$4); @@ -3331,7 +3331,7 @@ unary_expr:
if ($2) { - hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, + hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "Modifiers are not allowed on casts."); YYABORT; } @@ -3347,7 +3347,7 @@ unary_expr: src_string = hlsl_type_to_string(ctx, src_type); dst_string = hlsl_type_to_string(ctx, dst_type); if (src_string && dst_string) - hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Can't cast from %s to %s.", + hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Can't cast from %s to %s.", src_string->buffer, dst_string->buffer); hlsl_release_string_buffer(ctx, src_string); hlsl_release_string_buffer(ctx, dst_string); @@ -3398,11 +3398,11 @@ shift_expr: add_expr | shift_expr OP_LEFTSHIFT add_expr { - hlsl_fixme(ctx, @$, "Left shift."); + hlsl_fixme(ctx, &@$, "Left shift."); } | shift_expr OP_RIGHTSHIFT add_expr { - hlsl_fixme(ctx, @$, "Right shift."); + hlsl_fixme(ctx, &@$, "Right shift."); }
relational_expr: @@ -3439,42 +3439,42 @@ bitand_expr: equality_expr | bitand_expr '&' equality_expr { - hlsl_fixme(ctx, @$, "Bitwise AND."); + hlsl_fixme(ctx, &@$, "Bitwise AND."); }
bitxor_expr: bitand_expr | bitxor_expr '^' bitand_expr { - hlsl_fixme(ctx, @$, "Bitwise XOR."); + hlsl_fixme(ctx, &@$, "Bitwise XOR."); }
bitor_expr: bitxor_expr | bitor_expr '|' bitxor_expr { - hlsl_fixme(ctx, @$, "Bitwise OR."); + hlsl_fixme(ctx, &@$, "Bitwise OR."); }
logicand_expr: bitor_expr | logicand_expr OP_AND bitor_expr { - hlsl_fixme(ctx, @$, "Logical AND."); + hlsl_fixme(ctx, &@$, "Logical AND."); }
logicor_expr: logicand_expr | logicor_expr OP_OR logicand_expr { - hlsl_fixme(ctx, @$, "Logical OR."); + hlsl_fixme(ctx, &@$, "Logical OR."); }
conditional_expr: logicor_expr | logicor_expr '?' expr ':' assignment_expr { - hlsl_fixme(ctx, @$, "Ternary operator."); + hlsl_fixme(ctx, &@$, "Ternary operator."); }
assignment_expr: @@ -3486,7 +3486,7 @@ assignment_expr:
if (lhs->data_type->modifiers & HLSL_MODIFIER_CONST) { - hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_MODIFIES_CONST, "Statement modifies a const expression."); + hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_MODIFIES_CONST, "Statement modifies a const expression."); YYABORT; } list_move_tail($3, $1); diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index e61c6de6f..72af013c9 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -113,7 +113,7 @@ static void prepend_input_struct_copy(struct hlsl_ctx *ctx, struct list *instrs, else if (field->semantic.name) prepend_input_copy(ctx, instrs, var, field->type, field_offset + field->reg_offset, &field->semantic); else - hlsl_error(ctx, field->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC, + hlsl_error(ctx, &field->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC, "Field '%s' is missing a semantic.", field->name); } } @@ -184,7 +184,7 @@ static void append_output_struct_copy(struct hlsl_ctx *ctx, struct list *instrs, else if (field->semantic.name) append_output_copy(ctx, instrs, var, field->type, field_offset + field->reg_offset, &field->semantic); else - hlsl_error(ctx, field->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC, + hlsl_error(ctx, &field->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC, "Field '%s' is missing a semantic.", field->name); } } @@ -1397,7 +1397,7 @@ static void allocate_semantic_register(struct hlsl_ctx *ctx, struct hlsl_ir_var
if (!hlsl_sm1_usage_from_semantic(&var->semantic, &usage, &usage_idx)) { - hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC, + hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC, "Invalid semantic '%s'.", var->semantic.name); return; } @@ -1414,7 +1414,7 @@ static void allocate_semantic_register(struct hlsl_ctx *ctx, struct hlsl_ir_var
if (!hlsl_sm4_usage_from_semantic(ctx, &var->semantic, output, &usage)) { - hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC, + hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC, "Invalid semantic '%s'.", var->semantic.name); return; } @@ -1505,9 +1505,9 @@ static void allocate_buffers(struct hlsl_ctx *ctx)
if (reserved_buffer && reserved_buffer != buffer) { - hlsl_error(ctx, buffer->loc, VKD3D_SHADER_ERROR_HLSL_OVERLAPPING_RESERVATIONS, + hlsl_error(ctx, &buffer->loc, VKD3D_SHADER_ERROR_HLSL_OVERLAPPING_RESERVATIONS, "Multiple buffers bound to cb%u.", buffer->reservation.index); - hlsl_note(ctx, reserved_buffer->loc, VKD3D_SHADER_LOG_ERROR, + hlsl_note(ctx, &reserved_buffer->loc, VKD3D_SHADER_LOG_ERROR, "Buffer %s is already bound to cb%u.", reserved_buffer->name, buffer->reservation.index); }
@@ -1527,7 +1527,7 @@ static void allocate_buffers(struct hlsl_ctx *ctx) } else { - hlsl_error(ctx, buffer->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_RESERVATION, + hlsl_error(ctx, &buffer->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_RESERVATION, "Constant buffers must be allocated to register type 'b'."); } } @@ -1592,10 +1592,10 @@ static void allocate_objects(struct hlsl_ctx *ctx, enum hlsl_base_type type)
if (reserved_object && reserved_object != var) { - hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_OVERLAPPING_RESERVATIONS, + hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_OVERLAPPING_RESERVATIONS, "Multiple objects bound to %c%u.", type_info->reg_name, var->reg_reservation.index); - hlsl_note(ctx, reserved_object->loc, VKD3D_SHADER_LOG_ERROR, + hlsl_note(ctx, &reserved_object->loc, VKD3D_SHADER_LOG_ERROR, "Object '%s' is already bound to %c%u.", reserved_object->name, type_info->reg_name, var->reg_reservation.index); } @@ -1619,7 +1619,7 @@ static void allocate_objects(struct hlsl_ctx *ctx, enum hlsl_base_type type) struct vkd3d_string_buffer *type_string;
type_string = hlsl_type_to_string(ctx, var->data_type); - hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_RESERVATION, + hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_RESERVATION, "Object of type '%s' must be bound to register type '%c'.", type_string->buffer, type_info->reg_name); hlsl_release_string_buffer(ctx, type_string); @@ -1660,7 +1660,7 @@ unsigned int hlsl_offset_from_deref_safe(struct hlsl_ctx *ctx, const struct hlsl if (hlsl_offset_from_deref(deref, &offset)) return offset;
- hlsl_fixme(ctx, deref->offset.node->loc, "Dereference with non-constant offset of type %s.", + hlsl_fixme(ctx, &deref->offset.node->loc, "Dereference with non-constant offset of type %s.", hlsl_node_type_to_string(deref->offset.node->type));
return 0; @@ -1711,7 +1711,7 @@ int hlsl_emit_dxbc(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_fun else { if (var->data_type->type != HLSL_CLASS_STRUCT && !var->semantic.name) - hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC, + hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC, "Parameter "%s" is missing a semantic.", var->name);
if (var->modifiers & HLSL_STORAGE_IN) @@ -1723,7 +1723,7 @@ int hlsl_emit_dxbc(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_fun if (entry_func->return_var) { if (entry_func->return_var->data_type->type != HLSL_CLASS_STRUCT && !entry_func->return_var->semantic.name) - hlsl_error(ctx, entry_func->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC, + hlsl_error(ctx, &entry_func->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC, "Entry point "%s" is missing a return value semantic.", entry_func->func->name);
append_output_var_copy(ctx, &body->instrs, entry_func->return_var); diff --git a/libs/vkd3d-shader/hlsl_sm1.c b/libs/vkd3d-shader/hlsl_sm1.c index 4ff552bcb..1868bb708 100644 --- a/libs/vkd3d-shader/hlsl_sm1.c +++ b/libs/vkd3d-shader/hlsl_sm1.c @@ -617,7 +617,7 @@ static void write_sm1_expr(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *b if (instr->data_type->base_type != HLSL_TYPE_FLOAT) { /* These need to be lowered. */ - hlsl_fixme(ctx, instr->loc, "SM1 non-float expression."); + hlsl_fixme(ctx, &instr->loc, "SM1 non-float expression."); return; }
@@ -655,7 +655,7 @@ static void write_sm1_expr(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *b break;
default: - hlsl_fixme(ctx, instr->loc, "SM1 "%s" expression.", debug_hlsl_expr_op(expr->op)); + hlsl_fixme(ctx, &instr->loc, "SM1 "%s" expression.", debug_hlsl_expr_op(expr->op)); break; } } @@ -785,12 +785,12 @@ static void write_sm1_instructions(struct hlsl_ctx *ctx, struct vkd3d_bytecode_b if (instr->data_type->type == HLSL_CLASS_MATRIX) { /* These need to be lowered. */ - hlsl_fixme(ctx, instr->loc, "SM1 matrix expression."); + hlsl_fixme(ctx, &instr->loc, "SM1 matrix expression."); continue; } else if (instr->data_type->type == HLSL_CLASS_OBJECT) { - hlsl_fixme(ctx, instr->loc, "Object copy.\n"); + hlsl_fixme(ctx, &instr->loc, "Object copy.\n"); break; }
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index ed6de2a11..5cb0f3f8f 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -191,7 +191,7 @@ static void write_sm4_signature(struct hlsl_ctx *ctx, struct dxbc_writer *dxbc,
default: if ((string = hlsl_type_to_string(ctx, var->data_type))) - hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, + hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Invalid data type %s for semantic variable %s.", string->buffer, var->name); hlsl_release_string_buffer(ctx, string); put_u32(&buffer, D3D_REGISTER_COMPONENT_UNKNOWN); @@ -1317,11 +1317,11 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, break;
case HLSL_TYPE_BOOL: - hlsl_fixme(ctx, expr->node.loc, "Casts from bool to float are not implemented.\n"); + hlsl_fixme(ctx, &expr->node.loc, "Casts from bool to float are not implemented.\n"); break;
case HLSL_TYPE_DOUBLE: - hlsl_fixme(ctx, expr->node.loc, "Casts from double to float are not implemented.\n"); + hlsl_fixme(ctx, &expr->node.loc, "Casts from double to float are not implemented.\n"); break;
default: @@ -1373,7 +1373,7 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, break;
default: - hlsl_fixme(ctx, expr->node.loc, "SM4 float "%s" expression.", debug_hlsl_expr_op(expr->op)); + hlsl_fixme(ctx, &expr->node.loc, "SM4 float "%s" expression.", debug_hlsl_expr_op(expr->op)); break; } break; @@ -1403,11 +1403,11 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, break;
case HLSL_TYPE_BOOL: - hlsl_fixme(ctx, expr->node.loc, "SM4 cast from bool to int."); + hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from bool to int."); break;
case HLSL_TYPE_DOUBLE: - hlsl_fixme(ctx, expr->node.loc, "SM4 cast from double to int."); + hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from double to int."); break;
default: @@ -1417,7 +1417,7 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, }
default: - hlsl_fixme(ctx, expr->node.loc, "SM4 int "%s" expression.", debug_hlsl_expr_op(expr->op)); + hlsl_fixme(ctx, &expr->node.loc, "SM4 int "%s" expression.", debug_hlsl_expr_op(expr->op)); break; } break; @@ -1447,11 +1447,11 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, break;
case HLSL_TYPE_BOOL: - hlsl_fixme(ctx, expr->node.loc, "SM4 cast from bool to uint.\n"); + hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from bool to uint.\n"); break;
case HLSL_TYPE_DOUBLE: - hlsl_fixme(ctx, expr->node.loc, "SM4 cast from double to uint.\n"); + hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from double to uint.\n"); break;
default: @@ -1461,7 +1461,7 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, }
default: - hlsl_fixme(ctx, expr->node.loc, "SM4 uint "%s" expression.\n", debug_hlsl_expr_op(expr->op)); + hlsl_fixme(ctx, &expr->node.loc, "SM4 uint "%s" expression.\n", debug_hlsl_expr_op(expr->op)); break; } break; @@ -1472,7 +1472,7 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, struct vkd3d_string_buffer *string;
if ((string = hlsl_type_to_string(ctx, expr->node.data_type))) - hlsl_fixme(ctx, expr->node.loc, "SM4 %s expression.", string->buffer); + hlsl_fixme(ctx, &expr->node.loc, "SM4 %s expression.", string->buffer); hlsl_release_string_buffer(ctx, string); break; } @@ -1561,14 +1561,14 @@ static void write_sm4_resource_load(struct hlsl_ctx *ctx,
if (!load->sampler.var->is_uniform) { - hlsl_fixme(ctx, load->node.loc, "Sample using non-uniform sampler variable."); + 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."); + hlsl_fixme(ctx, &load->node.loc, "Load from non-uniform resource variable."); return; }
@@ -1580,7 +1580,7 @@ static void write_sm4_resource_load(struct hlsl_ctx *ctx,
case HLSL_RESOURCE_SAMPLE: if (!load->sampler.var) - hlsl_fixme(ctx, load->node.loc, "SM4 combined sample expression."); + 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; } @@ -1595,7 +1595,7 @@ static void write_sm4_store(struct hlsl_ctx *ctx,
if (store->lhs.var->data_type->type == HLSL_CLASS_MATRIX) { - hlsl_fixme(ctx, store->node.loc, "Store to a matrix variable.\n"); + hlsl_fixme(ctx, &store->node.loc, "Store to a matrix variable.\n"); return; }
@@ -1649,7 +1649,7 @@ static void write_sm4_block(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer * } else if (instr->data_type->type == HLSL_CLASS_OBJECT) { - hlsl_fixme(ctx, instr->loc, "Object copy.\n"); + hlsl_fixme(ctx, &instr->loc, "Object copy.\n"); break; }
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- Thanks for doing this and the following one!
On 23/11/21 02:45, Zebediah Figura wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
libs/vkd3d-shader/hlsl.c | 18 +-- libs/vkd3d-shader/hlsl.h | 8 +- libs/vkd3d-shader/hlsl.l | 2 +- libs/vkd3d-shader/hlsl.y | 194 +++++++++++++++---------------- libs/vkd3d-shader/hlsl_codegen.c | 26 ++--- libs/vkd3d-shader/hlsl_sm1.c | 8 +- libs/vkd3d-shader/hlsl_sm4.c | 32 ++--- 7 files changed, 144 insertions(+), 144 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 9824c56dc..4a289dd5c 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -22,40 +22,40 @@ #include "hlsl.h" #include <stdio.h>
-void hlsl_note(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, +void hlsl_note(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc, enum vkd3d_shader_log_level level, const char *fmt, ...) { va_list args;
va_start(args, fmt);
- vkd3d_shader_vnote(ctx->message_context, &loc, level, fmt, args);
- vkd3d_shader_vnote(ctx->message_context, loc, level, fmt, args); va_end(args); }
-void hlsl_error(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, +void hlsl_error(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc, enum vkd3d_shader_error error, const char *fmt, ...) { va_list args;
va_start(args, fmt);
- vkd3d_shader_verror(ctx->message_context, &loc, error, fmt, args);
vkd3d_shader_verror(ctx->message_context, loc, error, fmt, args); va_end(args);
if (!ctx->result) ctx->result = VKD3D_ERROR_INVALID_SHADER; }
-void hlsl_warning(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, +void hlsl_warning(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc, enum vkd3d_shader_error error, const char *fmt, ...) { va_list args;
va_start(args, fmt);
- vkd3d_shader_vwarning(ctx->message_context, &loc, error, fmt, args);
- vkd3d_shader_vwarning(ctx->message_context, loc, error, fmt, args); va_end(args); }
-void hlsl_fixme(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, const char *fmt, ...) +void hlsl_fixme(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc, const char *fmt, ...) { struct vkd3d_string_buffer *string; va_list args; @@ -64,7 +64,7 @@ void hlsl_fixme(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, co string = hlsl_get_string_buffer(ctx); vkd3d_string_buffer_printf(string, "Aborting due to not yet implemented feature: "); vkd3d_string_buffer_vprintf(string, fmt, args);
- vkd3d_shader_error(ctx->message_context, &loc, VKD3D_SHADER_ERROR_HLSL_NOT_IMPLEMENTED, "%s", string->buffer);
- vkd3d_shader_error(ctx->message_context, loc, VKD3D_SHADER_ERROR_HLSL_NOT_IMPLEMENTED, "%s", string->buffer); hlsl_release_string_buffer(ctx, string); va_end(args);
@@ -1950,7 +1950,7 @@ int hlsl_compile_shader(const struct vkd3d_shader_code *hlsl, const struct vkd3d { const struct vkd3d_shader_location loc = {.source_name = compile_info->source_name};
hlsl_error(&ctx, loc, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED,
hlsl_error(&ctx, &loc, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Entry point \"%s\" is not defined.", entry_point); hlsl_ctx_cleanup(&ctx); return VKD3D_ERROR_INVALID_SHADER;
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index e7bdb45e8..ec43f62e7 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -727,13 +727,13 @@ struct hlsl_ir_var *hlsl_new_var(struct hlsl_ctx *ctx, const char *name, struct struct hlsl_ir_load *hlsl_new_var_load(struct hlsl_ctx *ctx, struct hlsl_ir_var *var, const struct vkd3d_shader_location loc);
-void hlsl_error(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, +void hlsl_error(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc, enum vkd3d_shader_error error, const char *fmt, ...) VKD3D_PRINTF_FUNC(4, 5); -void hlsl_fixme(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, +void hlsl_fixme(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc, const char *fmt, ...) VKD3D_PRINTF_FUNC(3, 4); -void hlsl_warning(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, +void hlsl_warning(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc, enum vkd3d_shader_error error, const char *fmt, ...) VKD3D_PRINTF_FUNC(4, 5); -void hlsl_note(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, +void hlsl_note(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc, enum vkd3d_shader_log_level level, const char *fmt, ...) VKD3D_PRINTF_FUNC(4, 5);
void hlsl_push_scope(struct hlsl_ctx *ctx); diff --git a/libs/vkd3d-shader/hlsl.l b/libs/vkd3d-shader/hlsl.l index caf8fe8f9..e9281ec36 100644 --- a/libs/vkd3d-shader/hlsl.l +++ b/libs/vkd3d-shader/hlsl.l @@ -65,7 +65,7 @@ ANY (.) {RESERVED4} { struct hlsl_ctx *ctx = yyget_extra(yyscanner);
hlsl_error(ctx, *yylloc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX,
hlsl_error(ctx, yylloc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Reserved keyword \"%s\" used.", yytext); }
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index ff35c09e5..97dc98911 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -111,7 +111,7 @@ int yylex(HLSL_YYSTYPE *yylval_param, HLSL_YYLTYPE *yylloc_param, void *yyscanne
static void yyerror(YYLTYPE *loc, void *scanner, struct hlsl_ctx *ctx, const char *s) {
- hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "%s", s);
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "%s", s); }
static struct hlsl_ir_node *node_from_list(struct list *list)
@@ -137,7 +137,7 @@ static void destroy_instr_list(struct list *list) static void check_invalid_matrix_modifiers(struct hlsl_ctx *ctx, DWORD modifiers, struct vkd3d_shader_location loc) { if (modifiers & HLSL_MODIFIERS_MAJORITY_MASK)
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
}hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "'row_major' and 'column_major' modifiers are only allowed for matrices.");
@@ -281,7 +281,7 @@ static struct hlsl_ir_node *add_implicit_conversion(struct hlsl_ctx *ctx, struct src_string = hlsl_type_to_string(ctx, src_type); dst_string = hlsl_type_to_string(ctx, dst_type); if (src_string && dst_string)
hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Can't implicitly convert from %s to %s.", src_string->buffer, dst_string->buffer); hlsl_release_string_buffer(ctx, src_string); hlsl_release_string_buffer(ctx, dst_string);
@@ -289,7 +289,7 @@ static struct hlsl_ir_node *add_implicit_conversion(struct hlsl_ctx *ctx, struct }
if (dst_type->dimx * dst_type->dimy < src_type->dimx * src_type->dimy)
hlsl_warning(ctx, *loc, VKD3D_SHADER_WARNING_HLSL_IMPLICIT_TRUNCATION, "Implicit truncation of %s type.",
hlsl_warning(ctx, loc, VKD3D_SHADER_WARNING_HLSL_IMPLICIT_TRUNCATION, "Implicit truncation of %s type.", src_type->type == HLSL_CLASS_VECTOR ? "vector" : "matrix"); if (!(cast = hlsl_new_cast(ctx, node, dst_type, loc)))
@@ -305,14 +305,14 @@ static DWORD add_modifiers(struct hlsl_ctx *ctx, DWORD modifiers, DWORD mod, con struct vkd3d_string_buffer *string;
if ((string = hlsl_modifiers_to_string(ctx, mod)))
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "Modifier '%s' was already specified.", string->buffer); hlsl_release_string_buffer(ctx, string); return modifiers; } if ((mod & HLSL_MODIFIERS_MAJORITY_MASK) && (modifiers & HLSL_MODIFIERS_MAJORITY_MASK)) {
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "'row_major' and 'column_major' modifiers are mutually exclusive."); return modifiers; }
@@ -516,7 +516,7 @@ static struct hlsl_ir_jump *add_return(struct hlsl_ctx *ctx, struct list *instrs } else if (ctx->cur_function->return_var) {
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_RETURN, "Non-void function must return a value.");
hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_INVALID_RETURN, "Non-void function must return a value."); return NULL; }
@@ -601,9 +601,9 @@ static struct hlsl_ir_load *add_array_load(struct hlsl_ctx *ctx, struct list *in else { if (expr_type->type == HLSL_CLASS_SCALAR)
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_INDEX, "Scalar expressions cannot be array-indexed.");
hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_INVALID_INDEX, "Scalar expressions cannot be array-indexed."); else
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_INDEX, "Expression cannot be array-indexed.");
hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_INVALID_INDEX, "Expression cannot be array-indexed."); return NULL; }
@@ -661,7 +661,7 @@ static struct hlsl_type *apply_type_modifiers(struct hlsl_ctx *ctx, struct hlsl_ *modifiers &= ~HLSL_TYPE_MODIFIERS_MASK;
if ((new_type->modifiers & HLSL_MODIFIER_ROW_MAJOR) && (new_type->modifiers & HLSL_MODIFIER_COLUMN_MAJOR))
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "'row_major' and 'column_major' modifiers are mutually exclusive."); return new_type;
@@ -696,7 +696,7 @@ static struct list *gen_struct_fields(struct hlsl_ctx *ctx, struct hlsl_type *ty field->semantic = v->semantic; if (v->initializer.args_count) {
hlsl_error(ctx, v->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Illegal initializer on a struct field.");
hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Illegal initializer on a struct field."); free_parse_initializer(&v->initializer); } list_add_tail(list, &field->entry);
@@ -739,12 +739,12 @@ static bool add_typedef(struct hlsl_ctx *ctx, DWORD modifiers, struct hlsl_type
if ((type->modifiers & HLSL_MODIFIER_COLUMN_MAJOR) && (type->modifiers & HLSL_MODIFIER_ROW_MAJOR))
hlsl_error(ctx, v->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "'row_major' and 'column_major' modifiers are mutually exclusive."); ret = hlsl_scope_add_type(ctx->cur_scope, type); if (!ret)
hlsl_error(ctx, v->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "Type '%s' is already defined.", v->name); vkd3d_free(v); }
@@ -761,7 +761,7 @@ static bool add_func_parameter(struct hlsl_ctx *ctx, struct list *list, assert(param->type->modifiers & HLSL_MODIFIERS_MAJORITY_MASK);
if ((param->modifiers & HLSL_STORAGE_OUT) && (param->modifiers & HLSL_STORAGE_UNIFORM))
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "Parameter '%s' is declared as both \"out\" and \"uniform\".", param->name); if (!(var = hlsl_new_var(ctx, param->name, param->type, loc, ¶m->semantic, param->modifiers, ¶m->reg_reservation)))
@@ -928,7 +928,7 @@ static bool expr_common_shape(struct hlsl_ctx *ctx, struct hlsl_type *t1, struct struct vkd3d_string_buffer *string;
if ((string = hlsl_type_to_string(ctx, t1)))
hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Expression of type \"%s\" cannot be used in a numeric expression.", string->buffer); hlsl_release_string_buffer(ctx, string); return false;
@@ -939,7 +939,7 @@ static bool expr_common_shape(struct hlsl_ctx *ctx, struct hlsl_type *t1, struct struct vkd3d_string_buffer *string;
if ((string = hlsl_type_to_string(ctx, t2)))
hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Expression of type \"%s\" cannot be used in a numeric expression.", string->buffer); hlsl_release_string_buffer(ctx, string); return false;
@@ -951,7 +951,7 @@ static bool expr_common_shape(struct hlsl_ctx *ctx, struct hlsl_type *t1, struct struct vkd3d_string_buffer *t2_string = hlsl_type_to_string(ctx, t2);
if (t1_string && t2_string)
hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Expression data types \"%s\" and \"%s\" are incompatible.", t1_string->buffer, t2_string->buffer); hlsl_release_string_buffer(ctx, t1_string);
@@ -1191,7 +1191,7 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in { if (lhs->type == HLSL_IR_EXPR && hlsl_ir_expr(lhs)->op == HLSL_OP1_CAST) {
hlsl_fixme(ctx, lhs->loc, "Cast on the LHS.");
hlsl_fixme(ctx, &lhs->loc, "Cast on the LHS."); vkd3d_free(store); return NULL; }
@@ -1201,11 +1201,11 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in unsigned int width, s = swizzle->swizzle;
if (lhs->data_type->type == HLSL_CLASS_MATRIX)
hlsl_fixme(ctx, lhs->loc, "Matrix assignment with a writemask.");
hlsl_fixme(ctx, &lhs->loc, "Matrix assignment with a writemask."); if (!invert_swizzle(&s, &writemask, &width)) {
hlsl_error(ctx, lhs->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_WRITEMASK, "Invalid writemask.");
hlsl_error(ctx, &lhs->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_WRITEMASK, "Invalid writemask."); vkd3d_free(store); return NULL; }
@@ -1222,7 +1222,7 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in } else {
hlsl_error(ctx, lhs->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_LVALUE, "Invalid lvalue.");
hlsl_error(ctx, &lhs->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_LVALUE, "Invalid lvalue."); vkd3d_free(store); return NULL; }
@@ -1251,7 +1251,7 @@ static bool add_increment(struct hlsl_ctx *ctx, struct list *instrs, bool decrem struct hlsl_ir_constant *one;
if (lhs->data_type->modifiers & HLSL_MODIFIER_CONST)
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_MODIFIES_CONST,
hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_MODIFIES_CONST, "Argument to %s%screment operator is const.", post ? "post" : "pre", decrement ? "de" : "in"); if (!(one = hlsl_new_uint_constant(ctx, 1, loc)))
@@ -1286,7 +1286,7 @@ static void struct_var_initializer(struct hlsl_ctx *ctx, struct list *list, stru
if (initializer_size(initializer) != hlsl_type_component_count(type)) {
hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT,
hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT, "Expected %u components in initializer, but got %u.", hlsl_type_component_count(type), initializer_size(initializer)); free_parse_initializer(initializer);
@@ -1317,7 +1317,7 @@ static void struct_var_initializer(struct hlsl_ctx *ctx, struct list *list, stru } else {
hlsl_fixme(ctx, node->loc, "Implicit cast in structure initializer.");
hlsl_fixme(ctx, &node->loc, "Implicit cast in structure initializer."); } }
@@ -1381,7 +1381,7 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t local = false;
if ((modifiers & HLSL_STORAGE_UNIFORM) && (modifiers & HLSL_STORAGE_STATIC))
hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "Variable '%s' is declared as both \"uniform\" and \"static\".", var->name); /* Mark it as uniform. We need to do this here since synthetic
@@ -1392,9 +1392,9 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t
if ((func = hlsl_get_func_decl(ctx, var->name))) {
hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "'%s' is already defined as a function.", var->name);
hlsl_note(ctx, func->loc, VKD3D_SHADER_LOG_ERROR,
hlsl_note(ctx, &func->loc, VKD3D_SHADER_LOG_ERROR, "'%s' was previously defined here.", var->name); } }
@@ -1408,19 +1408,19 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t struct vkd3d_string_buffer *string;
if ((string = hlsl_modifiers_to_string(ctx, modifiers & invalid)))
hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "Modifiers '%s' are not allowed on local variables.", string->buffer); hlsl_release_string_buffer(ctx, string); } if (var->semantic.name)
hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC,
hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC, "Semantics are not allowed on local variables."); } if ((type->modifiers & HLSL_MODIFIER_CONST) && !v->initializer.args_count && !(modifiers & (HLSL_STORAGE_STATIC | HLSL_STORAGE_UNIFORM))) {
hlsl_error(ctx, v->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_INITIALIZER,
hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_INITIALIZER, "Const variable \"%s\" is missing an initializer.", var->name); hlsl_free_var(var); vkd3d_free(v);
@@ -1431,9 +1431,9 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t { struct hlsl_ir_var *old = hlsl_get_var(ctx->cur_scope, var->name);
hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "Variable \"%s\" was already declared in this scope.", var->name);
hlsl_note(ctx, old->loc, VKD3D_SHADER_LOG_ERROR, "\"%s\" was previously declared here.", old->name);
hlsl_note(ctx, &old->loc, VKD3D_SHADER_LOG_ERROR, "\"%s\" was previously declared here.", old->name); hlsl_free_var(var); vkd3d_free(v); continue;
@@ -1449,7 +1449,7 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t { if (size < type->dimx * type->dimy) {
hlsl_error(ctx, v->loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT,
hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT, "Expected %u components in numeric initializer, but got %u.", type->dimx * type->dimy, size); free_parse_initializer(&v->initializer);
@@ -1460,7 +1460,7 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t if ((type->type == HLSL_CLASS_STRUCT || type->type == HLSL_CLASS_ARRAY) && hlsl_type_component_count(type) != size) {
hlsl_error(ctx, v->loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT,
hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT, "Expected %u components in initializer, but got %u.", hlsl_type_component_count(type), size); free_parse_initializer(&v->initializer); vkd3d_free(v);
@@ -1482,14 +1482,14 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t } if (v->arrays.count) {
hlsl_fixme(ctx, v->loc, "Array initializer.");
hlsl_fixme(ctx, &v->loc, "Array initializer."); free_parse_initializer(&v->initializer); vkd3d_free(v); continue; } if (v->initializer.args_count > 1) {
hlsl_fixme(ctx, v->loc, "Complex initializer.");
hlsl_fixme(ctx, &v->loc, "Complex initializer."); free_parse_initializer(&v->initializer); vkd3d_free(v); continue;
@@ -1711,7 +1711,7 @@ static struct list *add_call(struct hlsl_ctx *ctx, const char *name,
if ((decl = find_function_call(ctx, name, params))) {
hlsl_fixme(ctx, loc, "Call to user-defined function \"%s\".", name);
hlsl_fixme(ctx, &loc, "Call to user-defined function \"%s\".", name); free_parse_initializer(params); return NULL; }
@@ -1720,7 +1720,7 @@ static struct list *add_call(struct hlsl_ctx *ctx, const char *name, { if (intrinsic->param_count >= 0 && params->args_count != intrinsic->param_count) {
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT,
hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT, "Wrong number of arguments to function '%s': expected %u, but got %u.\n", name, intrinsic->param_count, params->args_count); free_parse_initializer(params);
@@ -1738,7 +1738,7 @@ static struct list *add_call(struct hlsl_ctx *ctx, const char *name, struct vkd3d_string_buffer *string;
if ((string = hlsl_type_to_string(ctx, params->args[i]->data_type)))
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Wrong type for argument %u of '%s': expected a numeric type, but got '%s'.\n", i + 1, name, string->buffer); hlsl_release_string_buffer(ctx, string);
@@ -1756,7 +1756,7 @@ static struct list *add_call(struct hlsl_ctx *ctx, const char *name, } else {
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Function \"%s\" is not defined.", name);
hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Function \"%s\" is not defined.", name); free_parse_initializer(params); return NULL; }
@@ -1775,7 +1775,7 @@ static struct list *add_constructor(struct hlsl_ctx *ctx, struct hlsl_type *type char name[23];
if (type->type == HLSL_CLASS_MATRIX)
hlsl_fixme(ctx, loc, "Matrix constructor.");
hlsl_fixme(ctx, &loc, "Matrix constructor."); sprintf(name, "<constructor-%x>", counter++); if (!(var = hlsl_new_synthetic_var(ctx, name, type, loc)))
@@ -1791,7 +1791,7 @@ static struct list *add_constructor(struct hlsl_ctx *ctx, struct hlsl_type *type struct vkd3d_string_buffer *string;
if ((string = hlsl_type_to_string(ctx, arg->data_type)))
hlsl_error(ctx, arg->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
hlsl_error(ctx, &arg->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Invalid type %s for constructor argument.", string->buffer); hlsl_release_string_buffer(ctx, string); continue;
@@ -1836,7 +1836,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl struct vkd3d_string_buffer *string;
if ((string = hlsl_type_to_string(ctx, object_type)))
hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Type '%s' does not have methods.", string->buffer); hlsl_release_string_buffer(ctx, string); return false;
@@ -1853,7 +1853,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
if (params->args_count < 1 || params->args_count > 3) {
hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT,
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT, "Wrong number of arguments to method 'Load': expected 1, 2, or 3, but got %u.", params->args_count); return false; }
@@ -1881,7 +1881,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
if (params->args_count != 2 && params->args_count != 3) {
hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT,
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT, "Wrong number of arguments to method 'Sample': expected 2 or 3, but got %u.", params->args_count); return false; }
@@ -1895,7 +1895,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl struct vkd3d_string_buffer *string;
if ((string = hlsl_type_to_string(ctx, sampler_type)))
hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Wrong type for argument 0 of Sample(): expected 'sampler', but got '%s'.", string->buffer); hlsl_release_string_buffer(ctx, string); return false;
@@ -1920,7 +1920,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl struct vkd3d_string_buffer *string;
if ((string = hlsl_type_to_string(ctx, object_type)))
hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED,
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Method '%s' is not defined on type '%s'.", name, string->buffer); hlsl_release_string_buffer(ctx, string); return false;
@@ -2162,16 +2162,16 @@ hlsl_prog: { if (decl->has_body && $2.decl->has_body) {
hlsl_error(ctx, $2.decl->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
hlsl_error(ctx, &$2.decl->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "Function \"%s\" is already defined.", $2.name);
hlsl_note(ctx, decl->loc, VKD3D_SHADER_LOG_ERROR, "\"%s\" was previously defined here.", $2.name);
hlsl_note(ctx, &decl->loc, VKD3D_SHADER_LOG_ERROR, "\"%s\" was previously defined here.", $2.name); YYABORT; } else if (!hlsl_types_are_equal(decl->return_type, $2.decl->return_type)) {
hlsl_error(ctx, $2.decl->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
hlsl_error(ctx, &$2.decl->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "Function \"%s\" was already declared with a different return type.", $2.name);
hlsl_note(ctx, decl->loc, VKD3D_SHADER_LOG_ERROR, "\"%s\" was previously declared here.", $2.name);
hlsl_note(ctx, &decl->loc, VKD3D_SHADER_LOG_ERROR, "\"%s\" was previously declared here.", $2.name); YYABORT; } }
@@ -2182,7 +2182,7 @@ hlsl_prog: | hlsl_prog declaration_statement { if (!list_empty($2))
hlsl_fixme(ctx, @2, "Uniform initializer.");
hlsl_fixme(ctx, &@2, "Uniform initializer."); destroy_instr_list($2); } | hlsl_prog preproc_directive
@@ -2192,7 +2192,7 @@ buffer_declaration: buffer_type any_identifier colon_attribute { if ($3.semantic.name)
hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC, "Semantics are not allowed on buffers.");
hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC, "Semantics are not allowed on buffers."); if (!(ctx->cur_buffer = hlsl_new_buffer(ctx, $1, $2, &$3.reg_reservation, @2))) YYABORT;
@@ -2249,10 +2249,10 @@ struct_declaration: if (!$3) { if (!$2->name)
hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX,
hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Anonymous struct type must declare a variable."); if (modifiers)
hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "Modifiers are not allowed on struct type declarations."); }
@@ -2274,14 +2274,14 @@ named_struct_spec:
if (hlsl_get_var(ctx->cur_scope, $2)) {
hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "\"%s\" is already declared as a variable.", $2);
hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "\"%s\" is already declared as a variable.", $2); YYABORT; } ret = hlsl_scope_add_type(ctx->cur_scope, $$); if (!ret) {
hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "Struct \"%s\" is already defined.", $2);
hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "Struct \"%s\" is already defined.", $2); YYABORT; } }
@@ -2312,9 +2312,9 @@ fields_list: { if ((existing = get_struct_field($$, field->name))) {
hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "Field \"%s\" is already defined.", field->name);
hlsl_note(ctx, existing->loc, VKD3D_SHADER_LOG_ERROR,
hlsl_note(ctx, &existing->loc, VKD3D_SHADER_LOG_ERROR, "'%s' was previously defined here.", field->name); vkd3d_free(field); }
@@ -2343,7 +2343,7 @@ field: struct vkd3d_string_buffer *string;
if ((string = hlsl_modifiers_to_string(ctx, modifiers)))
hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "Modifiers '%s' are not allowed on struct fields.", string->buffer); hlsl_release_string_buffer(ctx, string); }
@@ -2373,21 +2373,21 @@ func_prototype:
if ($1) {
hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "Modifiers are not allowed on functions."); YYABORT; } if ((var = hlsl_get_var(ctx->globals, $3))) {
hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "\"%s\" is already declared as a variable.", $3);
hlsl_note(ctx, var->loc, VKD3D_SHADER_LOG_ERROR,
hlsl_note(ctx, &var->loc, VKD3D_SHADER_LOG_ERROR, "\"%s\" was previously declared here.", $3); YYABORT; } if (hlsl_types_are_equal($2, ctx->builtin_types.Void) && $7.semantic.name) {
hlsl_error(ctx, @7, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC,
hlsl_error(ctx, &@7, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC, "Semantics are not allowed on void functions."); }
@@ -2494,7 +2494,7 @@ param_list: $$ = $1; if (!add_func_parameter(ctx, $$, &$3, @3)) {
hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "Parameter \"%s\" is already declared.", $3.name); YYABORT; }
@@ -2529,7 +2529,7 @@ input_mods: struct vkd3d_string_buffer *string;
if ((string = hlsl_modifiers_to_string(ctx, $2)))
hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "Modifier \"%s\" was already specified.", string->buffer); hlsl_release_string_buffer(ctx, string); YYABORT;
@@ -2578,14 +2578,14 @@ type:
string = hlsl_type_to_string(ctx, $3); if (string)
hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Vector base type %s is not scalar.", string->buffer); hlsl_release_string_buffer(ctx, string); YYABORT; } if ($5 < 1 || $5 > 4) {
hlsl_error(ctx, @5, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE,
hlsl_error(ctx, &@5, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE, "Vector size %d is not between 1 and 4.", $5); YYABORT; }
@@ -2604,20 +2604,20 @@ type:
string = hlsl_type_to_string(ctx, $3); if (string)
hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Matrix base type %s is not scalar.", string->buffer); hlsl_release_string_buffer(ctx, string); YYABORT; } if ($5 < 1 || $5 > 4) {
hlsl_error(ctx, @5, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE,
hlsl_error(ctx, &@5, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE, "Matrix row count %d is not between 1 and 4.", $5); YYABORT; } if ($7 < 1 || $7 > 4) {
hlsl_error(ctx, @7, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE,
hlsl_error(ctx, &@7, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE, "Matrix column count %d is not between 1 and 4.", $7); YYABORT; }
@@ -2668,7 +2668,7 @@ type:
string = hlsl_type_to_string(ctx, $3); if (string)
hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Texture data type %s is not scalar or vector.\n", string->buffer); hlsl_release_string_buffer(ctx, string); }
@@ -2683,7 +2683,7 @@ type: { $$ = hlsl_get_type(ctx->cur_scope, $2, true); if ($$->type != HLSL_CLASS_STRUCT)
hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "\"%s\" redefined as a structure.", $2);
hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "\"%s\" redefined as a structure.", $2); vkd3d_free($2); }
@@ -2706,7 +2706,7 @@ typedef: if ($2 & ~HLSL_TYPE_MODIFIERS_MASK) { struct parse_variable_def *v, *v_next;
hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "Storage modifiers are not allowed on typedefs."); LIST_FOR_EACH_ENTRY_SAFE(v, v_next, $4, struct parse_variable_def, entry) vkd3d_free(v);
@@ -2828,7 +2828,7 @@ arrays:
if (!size) {
hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE,
hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE, "Array size is not a positive integer constant."); vkd3d_free($$.sizes); YYABORT;
@@ -2836,7 +2836,7 @@ arrays:
if (size > 65536) {
hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE,
hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE, "Array size %u is not between 1 and 65536.", size); vkd3d_free($$.sizes); YYABORT;
@@ -3001,7 +3001,7 @@ selection_statement: struct vkd3d_string_buffer *string;
if ((string = hlsl_type_to_string(ctx, condition->data_type)))
hlsl_error(ctx, instr->node.loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
hlsl_error(ctx, &instr->node.loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "if condition type %s is not scalar.", string->buffer); hlsl_release_string_buffer(ctx, string); }
@@ -3103,7 +3103,7 @@ primary_expr:
if (!(var = hlsl_get_var(ctx->cur_scope, $1))) {
hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Variable \"%s\" is not defined.", $1);
hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Variable \"%s\" is not defined.", $1); YYABORT; } if (!(load = hlsl_new_var_load(ctx, var, @1)))
@@ -3137,7 +3137,7 @@ primary_expr: } else {
hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Identifier \"%s\" is not declared.\n", $1);
hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Identifier \"%s\" is not declared.\n", $1); YYABORT; } }
@@ -3173,7 +3173,7 @@ postfix_expr:
if (!(field = get_struct_field(type->e.elements, $3))) {
hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Field \"%s\" is not defined.", $3);
hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Field \"%s\" is not defined.", $3); YYABORT; }
@@ -3187,7 +3187,7 @@ postfix_expr:
if (!(swizzle = get_swizzle(ctx, node, $3, &@3))) {
hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Invalid swizzle \"%s\".", $3);
hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Invalid swizzle \"%s\".", $3); YYABORT; } list_add_tail($1, &swizzle->node.entry);
@@ -3195,7 +3195,7 @@ postfix_expr: } else {
hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Invalid subscript \"%s\".", $3);
hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Invalid subscript \"%s\".", $3); YYABORT; } }
@@ -3209,7 +3209,7 @@ postfix_expr:
if (index->data_type->type != HLSL_CLASS_SCALAR) {
hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Array index is not scalar.");
hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Array index is not scalar."); destroy_instr_list($1); YYABORT; }
@@ -3234,7 +3234,7 @@ postfix_expr: { if ($1) {
hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "Modifiers are not allowed on constructors."); free_parse_initializer(&$4); YYABORT;
@@ -3244,7 +3244,7 @@ postfix_expr: struct vkd3d_string_buffer *string;
if ((string = hlsl_type_to_string(ctx, $2)))
hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Constructor data type %s is not numeric.", string->buffer); hlsl_release_string_buffer(ctx, string); free_parse_initializer(&$4);
@@ -3252,7 +3252,7 @@ postfix_expr: } if ($2->dimx * $2->dimy != initializer_size(&$4)) {
hlsl_error(ctx, @4, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT,
hlsl_error(ctx, &@4, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT, "Expected %u components in constructor, but got %u.", $2->dimx * $2->dimy, initializer_size(&$4)); free_parse_initializer(&$4);
@@ -3331,7 +3331,7 @@ unary_expr:
if ($2) {
hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "Modifiers are not allowed on casts."); YYABORT; }
@@ -3347,7 +3347,7 @@ unary_expr: src_string = hlsl_type_to_string(ctx, src_type); dst_string = hlsl_type_to_string(ctx, dst_type); if (src_string && dst_string)
hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Can't cast from %s to %s.",
hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Can't cast from %s to %s.", src_string->buffer, dst_string->buffer); hlsl_release_string_buffer(ctx, src_string); hlsl_release_string_buffer(ctx, dst_string);
@@ -3398,11 +3398,11 @@ shift_expr: add_expr | shift_expr OP_LEFTSHIFT add_expr {
hlsl_fixme(ctx, @$, "Left shift.");
hlsl_fixme(ctx, &@$, "Left shift."); } | shift_expr OP_RIGHTSHIFT add_expr {
hlsl_fixme(ctx, @$, "Right shift.");
hlsl_fixme(ctx, &@$, "Right shift."); }
relational_expr:
@@ -3439,42 +3439,42 @@ bitand_expr: equality_expr | bitand_expr '&' equality_expr {
hlsl_fixme(ctx, @$, "Bitwise AND.");
hlsl_fixme(ctx, &@$, "Bitwise AND."); }
bitxor_expr: bitand_expr | bitxor_expr '^' bitand_expr {
hlsl_fixme(ctx, @$, "Bitwise XOR.");
hlsl_fixme(ctx, &@$, "Bitwise XOR."); }
bitor_expr: bitxor_expr | bitor_expr '|' bitxor_expr {
hlsl_fixme(ctx, @$, "Bitwise OR.");
hlsl_fixme(ctx, &@$, "Bitwise OR."); }
logicand_expr: bitor_expr | logicand_expr OP_AND bitor_expr {
hlsl_fixme(ctx, @$, "Logical AND.");
hlsl_fixme(ctx, &@$, "Logical AND."); }
logicor_expr: logicand_expr | logicor_expr OP_OR logicand_expr {
hlsl_fixme(ctx, @$, "Logical OR.");
hlsl_fixme(ctx, &@$, "Logical OR."); }
conditional_expr: logicor_expr | logicor_expr '?' expr ':' assignment_expr {
hlsl_fixme(ctx, @$, "Ternary operator.");
hlsl_fixme(ctx, &@$, "Ternary operator."); }
assignment_expr:
@@ -3486,7 +3486,7 @@ assignment_expr:
if (lhs->data_type->modifiers & HLSL_MODIFIER_CONST) {
hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_MODIFIES_CONST, "Statement modifies a const expression.");
hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_MODIFIES_CONST, "Statement modifies a const expression."); YYABORT; } list_move_tail($3, $1);
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index e61c6de6f..72af013c9 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -113,7 +113,7 @@ static void prepend_input_struct_copy(struct hlsl_ctx *ctx, struct list *instrs, else if (field->semantic.name) prepend_input_copy(ctx, instrs, var, field->type, field_offset + field->reg_offset, &field->semantic); else
hlsl_error(ctx, field->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC,
}hlsl_error(ctx, &field->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC, "Field '%s' is missing a semantic.", field->name); }
@@ -184,7 +184,7 @@ static void append_output_struct_copy(struct hlsl_ctx *ctx, struct list *instrs, else if (field->semantic.name) append_output_copy(ctx, instrs, var, field->type, field_offset + field->reg_offset, &field->semantic); else
hlsl_error(ctx, field->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC,
}hlsl_error(ctx, &field->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC, "Field '%s' is missing a semantic.", field->name); }
@@ -1397,7 +1397,7 @@ static void allocate_semantic_register(struct hlsl_ctx *ctx, struct hlsl_ir_var
if (!hlsl_sm1_usage_from_semantic(&var->semantic, &usage, &usage_idx)) {
hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC,
hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC, "Invalid semantic '%s'.", var->semantic.name); return; }
@@ -1414,7 +1414,7 @@ static void allocate_semantic_register(struct hlsl_ctx *ctx, struct hlsl_ir_var
if (!hlsl_sm4_usage_from_semantic(ctx, &var->semantic, output, &usage)) {
hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC,
hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC, "Invalid semantic '%s'.", var->semantic.name); return; }
@@ -1505,9 +1505,9 @@ static void allocate_buffers(struct hlsl_ctx *ctx)
if (reserved_buffer && reserved_buffer != buffer) {
hlsl_error(ctx, buffer->loc, VKD3D_SHADER_ERROR_HLSL_OVERLAPPING_RESERVATIONS,
hlsl_error(ctx, &buffer->loc, VKD3D_SHADER_ERROR_HLSL_OVERLAPPING_RESERVATIONS, "Multiple buffers bound to cb%u.", buffer->reservation.index);
hlsl_note(ctx, reserved_buffer->loc, VKD3D_SHADER_LOG_ERROR,
hlsl_note(ctx, &reserved_buffer->loc, VKD3D_SHADER_LOG_ERROR, "Buffer %s is already bound to cb%u.", reserved_buffer->name, buffer->reservation.index); }
@@ -1527,7 +1527,7 @@ static void allocate_buffers(struct hlsl_ctx *ctx) } else {
hlsl_error(ctx, buffer->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_RESERVATION,
hlsl_error(ctx, &buffer->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_RESERVATION, "Constant buffers must be allocated to register type 'b'."); } }
@@ -1592,10 +1592,10 @@ static void allocate_objects(struct hlsl_ctx *ctx, enum hlsl_base_type type)
if (reserved_object && reserved_object != var) {
hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_OVERLAPPING_RESERVATIONS,
hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_OVERLAPPING_RESERVATIONS, "Multiple objects bound to %c%u.", type_info->reg_name, var->reg_reservation.index);
hlsl_note(ctx, reserved_object->loc, VKD3D_SHADER_LOG_ERROR,
hlsl_note(ctx, &reserved_object->loc, VKD3D_SHADER_LOG_ERROR, "Object '%s' is already bound to %c%u.", reserved_object->name, type_info->reg_name, var->reg_reservation.index); }
@@ -1619,7 +1619,7 @@ static void allocate_objects(struct hlsl_ctx *ctx, enum hlsl_base_type type) struct vkd3d_string_buffer *type_string;
type_string = hlsl_type_to_string(ctx, var->data_type);
hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_RESERVATION,
hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_RESERVATION, "Object of type '%s' must be bound to register type '%c'.", type_string->buffer, type_info->reg_name); hlsl_release_string_buffer(ctx, type_string);
@@ -1660,7 +1660,7 @@ unsigned int hlsl_offset_from_deref_safe(struct hlsl_ctx *ctx, const struct hlsl if (hlsl_offset_from_deref(deref, &offset)) return offset;
- hlsl_fixme(ctx, deref->offset.node->loc, "Dereference with non-constant offset of type %s.",
hlsl_fixme(ctx, &deref->offset.node->loc, "Dereference with non-constant offset of type %s.", hlsl_node_type_to_string(deref->offset.node->type));
return 0;
@@ -1711,7 +1711,7 @@ int hlsl_emit_dxbc(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_fun else { if (var->data_type->type != HLSL_CLASS_STRUCT && !var->semantic.name)
hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC,
hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC, "Parameter \"%s\" is missing a semantic.", var->name); if (var->modifiers & HLSL_STORAGE_IN)
@@ -1723,7 +1723,7 @@ int hlsl_emit_dxbc(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_fun if (entry_func->return_var) { if (entry_func->return_var->data_type->type != HLSL_CLASS_STRUCT && !entry_func->return_var->semantic.name)
hlsl_error(ctx, entry_func->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC,
hlsl_error(ctx, &entry_func->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC, "Entry point \"%s\" is missing a return value semantic.", entry_func->func->name); append_output_var_copy(ctx, &body->instrs, entry_func->return_var);
diff --git a/libs/vkd3d-shader/hlsl_sm1.c b/libs/vkd3d-shader/hlsl_sm1.c index 4ff552bcb..1868bb708 100644 --- a/libs/vkd3d-shader/hlsl_sm1.c +++ b/libs/vkd3d-shader/hlsl_sm1.c @@ -617,7 +617,7 @@ static void write_sm1_expr(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *b if (instr->data_type->base_type != HLSL_TYPE_FLOAT) { /* These need to be lowered. */
hlsl_fixme(ctx, instr->loc, "SM1 non-float expression.");
hlsl_fixme(ctx, &instr->loc, "SM1 non-float expression."); return; }
@@ -655,7 +655,7 @@ static void write_sm1_expr(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *b break;
default:
hlsl_fixme(ctx, instr->loc, "SM1 \"%s\" expression.", debug_hlsl_expr_op(expr->op));
}hlsl_fixme(ctx, &instr->loc, "SM1 \"%s\" expression.", debug_hlsl_expr_op(expr->op)); break; }
@@ -785,12 +785,12 @@ static void write_sm1_instructions(struct hlsl_ctx *ctx, struct vkd3d_bytecode_b if (instr->data_type->type == HLSL_CLASS_MATRIX) { /* These need to be lowered. */
hlsl_fixme(ctx, instr->loc, "SM1 matrix expression.");
hlsl_fixme(ctx, &instr->loc, "SM1 matrix expression."); continue; } else if (instr->data_type->type == HLSL_CLASS_OBJECT) {
hlsl_fixme(ctx, instr->loc, "Object copy.\n");
hlsl_fixme(ctx, &instr->loc, "Object copy.\n"); break; }
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index ed6de2a11..5cb0f3f8f 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -191,7 +191,7 @@ static void write_sm4_signature(struct hlsl_ctx *ctx, struct dxbc_writer *dxbc,
default: if ((string = hlsl_type_to_string(ctx, var->data_type)))
hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Invalid data type %s for semantic variable %s.", string->buffer, var->name); hlsl_release_string_buffer(ctx, string); put_u32(&buffer, D3D_REGISTER_COMPONENT_UNKNOWN);
@@ -1317,11 +1317,11 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, break;
case HLSL_TYPE_BOOL:
hlsl_fixme(ctx, expr->node.loc, "Casts from bool to float are not implemented.\n");
hlsl_fixme(ctx, &expr->node.loc, "Casts from bool to float are not implemented.\n"); break; case HLSL_TYPE_DOUBLE:
hlsl_fixme(ctx, expr->node.loc, "Casts from double to float are not implemented.\n");
hlsl_fixme(ctx, &expr->node.loc, "Casts from double to float are not implemented.\n"); break; default:
@@ -1373,7 +1373,7 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, break;
default:
hlsl_fixme(ctx, expr->node.loc, "SM4 float \"%s\" expression.", debug_hlsl_expr_op(expr->op));
hlsl_fixme(ctx, &expr->node.loc, "SM4 float \"%s\" expression.", debug_hlsl_expr_op(expr->op)); break; } break;
@@ -1403,11 +1403,11 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, break;
case HLSL_TYPE_BOOL:
hlsl_fixme(ctx, expr->node.loc, "SM4 cast from bool to int.");
hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from bool to int."); break; case HLSL_TYPE_DOUBLE:
hlsl_fixme(ctx, expr->node.loc, "SM4 cast from double to int.");
hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from double to int."); break; default:
@@ -1417,7 +1417,7 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, }
default:
hlsl_fixme(ctx, expr->node.loc, "SM4 int \"%s\" expression.", debug_hlsl_expr_op(expr->op));
hlsl_fixme(ctx, &expr->node.loc, "SM4 int \"%s\" expression.", debug_hlsl_expr_op(expr->op)); break; } break;
@@ -1447,11 +1447,11 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, break;
case HLSL_TYPE_BOOL:
hlsl_fixme(ctx, expr->node.loc, "SM4 cast from bool to uint.\n");
hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from bool to uint.\n"); break; case HLSL_TYPE_DOUBLE:
hlsl_fixme(ctx, expr->node.loc, "SM4 cast from double to uint.\n");
hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from double to uint.\n"); break; default:
@@ -1461,7 +1461,7 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, }
default:
hlsl_fixme(ctx, expr->node.loc, "SM4 uint \"%s\" expression.\n", debug_hlsl_expr_op(expr->op));
hlsl_fixme(ctx, &expr->node.loc, "SM4 uint \"%s\" expression.\n", debug_hlsl_expr_op(expr->op)); break; } break;
@@ -1472,7 +1472,7 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, struct vkd3d_string_buffer *string;
if ((string = hlsl_type_to_string(ctx, expr->node.data_type)))
hlsl_fixme(ctx, expr->node.loc, "SM4 %s expression.", string->buffer);
hlsl_fixme(ctx, &expr->node.loc, "SM4 %s expression.", string->buffer); hlsl_release_string_buffer(ctx, string); break; }
@@ -1561,14 +1561,14 @@ static void write_sm4_resource_load(struct hlsl_ctx *ctx,
if (!load->sampler.var->is_uniform) {
hlsl_fixme(ctx, load->node.loc, "Sample using non-uniform sampler variable.");
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.");
hlsl_fixme(ctx, &load->node.loc, "Load from non-uniform resource variable."); return; }
@@ -1580,7 +1580,7 @@ static void write_sm4_resource_load(struct hlsl_ctx *ctx,
case HLSL_RESOURCE_SAMPLE: if (!load->sampler.var)
hlsl_fixme(ctx, load->node.loc, "SM4 combined sample expression.");
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; }
@@ -1595,7 +1595,7 @@ static void write_sm4_store(struct hlsl_ctx *ctx,
if (store->lhs.var->data_type->type == HLSL_CLASS_MATRIX) {
hlsl_fixme(ctx, store->node.loc, "Store to a matrix variable.\n");
hlsl_fixme(ctx, &store->node.loc, "Store to a matrix variable.\n"); return; }
@@ -1649,7 +1649,7 @@ static void write_sm4_block(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer * } else if (instr->data_type->type == HLSL_CLASS_OBJECT) {
hlsl_fixme(ctx, instr->loc, "Object copy.\n");
hlsl_fixme(ctx, &instr->loc, "Object copy.\n"); break; }
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/hlsl.c | 2 +- libs/vkd3d-shader/hlsl.h | 2 +- libs/vkd3d-shader/hlsl.y | 68 +++++++++++++++++++++------------------- 3 files changed, 37 insertions(+), 35 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 4a289dd5c..ccf75bea0 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -646,7 +646,7 @@ struct hlsl_ir_resource_load *hlsl_new_resource_load(struct hlsl_ctx *ctx, struc }
struct hlsl_ir_swizzle *hlsl_new_swizzle(struct hlsl_ctx *ctx, DWORD s, unsigned int components, - struct hlsl_ir_node *val, struct vkd3d_shader_location *loc) + struct hlsl_ir_node *val, const struct vkd3d_shader_location *loc) { struct hlsl_ir_swizzle *swizzle;
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index ec43f62e7..60ace9bfd 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -713,7 +713,7 @@ struct hlsl_ir_store *hlsl_new_store(struct hlsl_ctx *ctx, struct hlsl_ir_var *v struct hlsl_ir_node *rhs, unsigned int writemask, struct vkd3d_shader_location loc); struct hlsl_type *hlsl_new_struct_type(struct hlsl_ctx *ctx, const char *name, struct list *fields); struct hlsl_ir_swizzle *hlsl_new_swizzle(struct hlsl_ctx *ctx, DWORD s, unsigned int components, - struct hlsl_ir_node *val, struct vkd3d_shader_location *loc); + struct hlsl_ir_node *val, const struct vkd3d_shader_location *loc); struct hlsl_ir_var *hlsl_new_synthetic_var(struct hlsl_ctx *ctx, const char *name, struct hlsl_type *type, const struct vkd3d_shader_location loc); struct hlsl_type *hlsl_new_texture_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim, struct hlsl_type *format); diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 97dc98911..052a71913 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -921,7 +921,7 @@ static enum hlsl_base_type expr_common_base_type(enum hlsl_base_type t1, enum hl }
static bool expr_common_shape(struct hlsl_ctx *ctx, struct hlsl_type *t1, struct hlsl_type *t2, - struct vkd3d_shader_location *loc, enum hlsl_type_class *type, unsigned int *dimx, unsigned int *dimy) + const struct vkd3d_shader_location *loc, enum hlsl_type_class *type, unsigned int *dimx, unsigned int *dimy) { if (t1->type > HLSL_CLASS_LAST_NUMERIC) { @@ -996,8 +996,9 @@ static bool expr_common_shape(struct hlsl_ctx *ctx, struct hlsl_type *t1, struct return true; }
-static struct hlsl_ir_expr *add_expr(struct hlsl_ctx *ctx, struct list *instrs, enum hlsl_ir_expr_op op, - struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS], struct hlsl_type *type, struct vkd3d_shader_location *loc) +static struct hlsl_ir_expr *add_expr(struct hlsl_ctx *ctx, struct list *instrs, + enum hlsl_ir_expr_op op, struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS], + struct hlsl_type *type, const struct vkd3d_shader_location *loc) { struct hlsl_ir_expr *expr; unsigned int i; @@ -1014,7 +1015,7 @@ static struct hlsl_ir_expr *add_expr(struct hlsl_ctx *ctx, struct list *instrs, }
static struct hlsl_ir_expr *add_unary_arithmetic_expr(struct hlsl_ctx *ctx, struct list *instrs, - enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg, struct vkd3d_shader_location *loc) + enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg, const struct vkd3d_shader_location *loc) { struct hlsl_ir_node *args[HLSL_MAX_OPERANDS] = {arg};
@@ -1023,7 +1024,7 @@ static struct hlsl_ir_expr *add_unary_arithmetic_expr(struct hlsl_ctx *ctx, stru
static struct hlsl_ir_expr *add_binary_arithmetic_expr(struct hlsl_ctx *ctx, struct list *instrs, enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg1, struct hlsl_ir_node *arg2, - struct vkd3d_shader_location *loc) + const struct vkd3d_shader_location *loc) { struct hlsl_type *common_type; enum hlsl_base_type base = expr_common_base_type(arg1->data_type->base_type, arg2->data_type->base_type); @@ -1570,24 +1571,24 @@ static const struct hlsl_ir_function_decl *find_function_call(struct hlsl_ctx *c }
static bool intrinsic_abs(struct hlsl_ctx *ctx, - const struct parse_initializer *params, struct vkd3d_shader_location loc) + const struct parse_initializer *params, const struct vkd3d_shader_location *loc) { - return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_ABS, params->args[0], &loc); + return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_ABS, params->args[0], loc); }
static bool intrinsic_clamp(struct hlsl_ctx *ctx, - const struct parse_initializer *params, struct vkd3d_shader_location loc) + const struct parse_initializer *params, const struct vkd3d_shader_location *loc) { struct hlsl_ir_expr *max;
- if (!(max = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MAX, params->args[0], params->args[1], &loc))) + if (!(max = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MAX, params->args[0], params->args[1], loc))) return false;
- return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MIN, &max->node, params->args[2], &loc); + return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MIN, &max->node, params->args[2], loc); }
static bool intrinsic_cross(struct hlsl_ctx *ctx, - const struct parse_initializer *params, struct vkd3d_shader_location loc) + const struct parse_initializer *params, const struct vkd3d_shader_location *loc) { struct hlsl_ir_swizzle *arg1_swzl1, *arg1_swzl2, *arg2_swzl1, *arg2_swzl2; struct hlsl_ir_node *arg1 = params->args[0], *arg2 = params->args[1]; @@ -1603,78 +1604,78 @@ static bool intrinsic_cross(struct hlsl_ctx *ctx,
cast_type = hlsl_get_vector_type(ctx, base, 3);
- if (!(arg1_cast = add_implicit_conversion(ctx, params->instrs, arg1, cast_type, &loc))) + if (!(arg1_cast = add_implicit_conversion(ctx, params->instrs, arg1, cast_type, loc))) return false;
- if (!(arg2_cast = add_implicit_conversion(ctx, params->instrs, arg2, cast_type, &loc))) + if (!(arg2_cast = add_implicit_conversion(ctx, params->instrs, arg2, cast_type, loc))) return false;
- if (!(arg1_swzl1 = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(Z, X, Y, Z), 3, arg1_cast, &loc))) + if (!(arg1_swzl1 = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(Z, X, Y, Z), 3, arg1_cast, loc))) return false; list_add_tail(params->instrs, &arg1_swzl1->node.entry);
- if (!(arg2_swzl1 = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(Y, Z, X, Y), 3, arg2_cast, &loc))) + if (!(arg2_swzl1 = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(Y, Z, X, Y), 3, arg2_cast, loc))) return false; list_add_tail(params->instrs, &arg2_swzl1->node.entry);
if (!(mul1 = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MUL, - &arg1_swzl1->node, &arg2_swzl1->node, &loc))) + &arg1_swzl1->node, &arg2_swzl1->node, loc))) return false;
- if (!(mul1_neg = hlsl_new_unary_expr(ctx, HLSL_OP1_NEG, &mul1->node, loc))) + if (!(mul1_neg = hlsl_new_unary_expr(ctx, HLSL_OP1_NEG, &mul1->node, *loc))) return false; list_add_tail(params->instrs, &mul1_neg->entry);
- if (!(arg1_swzl2 = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(Y, Z, X, Y), 3, arg1_cast, &loc))) + if (!(arg1_swzl2 = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(Y, Z, X, Y), 3, arg1_cast, loc))) return false; list_add_tail(params->instrs, &arg1_swzl2->node.entry);
- if (!(arg2_swzl2 = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(Z, X, Y, Z), 3, arg2_cast, &loc))) + if (!(arg2_swzl2 = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(Z, X, Y, Z), 3, arg2_cast, loc))) return false; list_add_tail(params->instrs, &arg2_swzl2->node.entry);
if (!(mul2 = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MUL, - &arg1_swzl2->node, &arg2_swzl2->node, &loc))) + &arg1_swzl2->node, &arg2_swzl2->node, loc))) return false;
- return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_ADD, &mul2->node, mul1_neg, &loc); + return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_ADD, &mul2->node, mul1_neg, loc); }
static bool intrinsic_max(struct hlsl_ctx *ctx, - const struct parse_initializer *params, struct vkd3d_shader_location loc) + const struct parse_initializer *params, const struct vkd3d_shader_location *loc) { - return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MAX, params->args[0], params->args[1], &loc); + return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MAX, params->args[0], params->args[1], loc); }
static bool intrinsic_pow(struct hlsl_ctx *ctx, - const struct parse_initializer *params, struct vkd3d_shader_location loc) + const struct parse_initializer *params, const struct vkd3d_shader_location *loc) { struct hlsl_ir_node *log, *exp; struct hlsl_ir_expr *mul;
- if (!(log = hlsl_new_unary_expr(ctx, HLSL_OP1_LOG2, params->args[0], loc))) + if (!(log = hlsl_new_unary_expr(ctx, HLSL_OP1_LOG2, params->args[0], *loc))) return false; list_add_tail(params->instrs, &log->entry);
- if (!(mul = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MUL, params->args[1], log, &loc))) + if (!(mul = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MUL, params->args[1], log, loc))) return false;
- if (!(exp = hlsl_new_unary_expr(ctx, HLSL_OP1_EXP2, &mul->node, loc))) + if (!(exp = hlsl_new_unary_expr(ctx, HLSL_OP1_EXP2, &mul->node, *loc))) return false; list_add_tail(params->instrs, &exp->entry); return true; }
static bool intrinsic_round(struct hlsl_ctx *ctx, - const struct parse_initializer *params, struct vkd3d_shader_location loc) + const struct parse_initializer *params, const struct vkd3d_shader_location *loc) { - return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_ROUND, params->args[0], &loc); + return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_ROUND, params->args[0], loc); }
static bool intrinsic_saturate(struct hlsl_ctx *ctx, - const struct parse_initializer *params, struct vkd3d_shader_location loc) + const struct parse_initializer *params, const struct vkd3d_shader_location *loc) { - return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_SAT, params->args[0], &loc); + return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_SAT, params->args[0], loc); }
static const struct intrinsic_function @@ -1682,7 +1683,8 @@ static const struct intrinsic_function const char *name; int param_count; bool check_numeric; - bool (*handler)(struct hlsl_ctx *ctx, const struct parse_initializer *params, struct vkd3d_shader_location loc); + bool (*handler)(struct hlsl_ctx *ctx, const struct parse_initializer *params, + const struct vkd3d_shader_location *loc); } intrinsic_functions[] = { @@ -1748,7 +1750,7 @@ static struct list *add_call(struct hlsl_ctx *ctx, const char *name, } }
- if (!intrinsic->handler(ctx, params, loc)) + if (!intrinsic->handler(ctx, params, &loc)) { free_parse_initializer(params); return NULL;
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
On 23/11/21 02:45, Zebediah Figura wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
libs/vkd3d-shader/hlsl.c | 2 +- libs/vkd3d-shader/hlsl.h | 2 +- libs/vkd3d-shader/hlsl.y | 68 +++++++++++++++++++++------------------- 3 files changed, 37 insertions(+), 35 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 4a289dd5c..ccf75bea0 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -646,7 +646,7 @@ struct hlsl_ir_resource_load *hlsl_new_resource_load(struct hlsl_ctx *ctx, struc }
struct hlsl_ir_swizzle *hlsl_new_swizzle(struct hlsl_ctx *ctx, DWORD s, unsigned int components,
struct hlsl_ir_node *val, struct vkd3d_shader_location *loc)
{ struct hlsl_ir_swizzle *swizzle;struct hlsl_ir_node *val, const struct vkd3d_shader_location *loc)
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index ec43f62e7..60ace9bfd 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -713,7 +713,7 @@ struct hlsl_ir_store *hlsl_new_store(struct hlsl_ctx *ctx, struct hlsl_ir_var *v struct hlsl_ir_node *rhs, unsigned int writemask, struct vkd3d_shader_location loc); struct hlsl_type *hlsl_new_struct_type(struct hlsl_ctx *ctx, const char *name, struct list *fields); struct hlsl_ir_swizzle *hlsl_new_swizzle(struct hlsl_ctx *ctx, DWORD s, unsigned int components,
struct hlsl_ir_node *val, struct vkd3d_shader_location *loc);
struct hlsl_ir_var *hlsl_new_synthetic_var(struct hlsl_ctx *ctx, const char *name, struct hlsl_type *type, const struct vkd3d_shader_location loc); struct hlsl_type *hlsl_new_texture_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim, struct hlsl_type *format);struct hlsl_ir_node *val, const struct vkd3d_shader_location *loc);
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 97dc98911..052a71913 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -921,7 +921,7 @@ static enum hlsl_base_type expr_common_base_type(enum hlsl_base_type t1, enum hl }
static bool expr_common_shape(struct hlsl_ctx *ctx, struct hlsl_type *t1, struct hlsl_type *t2,
struct vkd3d_shader_location *loc, enum hlsl_type_class *type, unsigned int *dimx, unsigned int *dimy)
{ if (t1->type > HLSL_CLASS_LAST_NUMERIC) {const struct vkd3d_shader_location *loc, enum hlsl_type_class *type, unsigned int *dimx, unsigned int *dimy)
@@ -996,8 +996,9 @@ static bool expr_common_shape(struct hlsl_ctx *ctx, struct hlsl_type *t1, struct return true; }
-static struct hlsl_ir_expr *add_expr(struct hlsl_ctx *ctx, struct list *instrs, enum hlsl_ir_expr_op op,
struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS], struct hlsl_type *type, struct vkd3d_shader_location *loc)
+static struct hlsl_ir_expr *add_expr(struct hlsl_ctx *ctx, struct list *instrs,
enum hlsl_ir_expr_op op, struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS],
{ struct hlsl_ir_expr *expr; unsigned int i;struct hlsl_type *type, const struct vkd3d_shader_location *loc)
@@ -1014,7 +1015,7 @@ static struct hlsl_ir_expr *add_expr(struct hlsl_ctx *ctx, struct list *instrs, }
static struct hlsl_ir_expr *add_unary_arithmetic_expr(struct hlsl_ctx *ctx, struct list *instrs,
enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg, struct vkd3d_shader_location *loc)
{ struct hlsl_ir_node *args[HLSL_MAX_OPERANDS] = {arg};enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg, const struct vkd3d_shader_location *loc)
@@ -1023,7 +1024,7 @@ static struct hlsl_ir_expr *add_unary_arithmetic_expr(struct hlsl_ctx *ctx, stru
static struct hlsl_ir_expr *add_binary_arithmetic_expr(struct hlsl_ctx *ctx, struct list *instrs, enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg1, struct hlsl_ir_node *arg2,
struct vkd3d_shader_location *loc)
{ struct hlsl_type *common_type; enum hlsl_base_type base = expr_common_base_type(arg1->data_type->base_type, arg2->data_type->base_type);const struct vkd3d_shader_location *loc)
@@ -1570,24 +1571,24 @@ static const struct hlsl_ir_function_decl *find_function_call(struct hlsl_ctx *c }
static bool intrinsic_abs(struct hlsl_ctx *ctx,
const struct parse_initializer *params, struct vkd3d_shader_location loc)
{const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
- return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_ABS, params->args[0], &loc);
return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_ABS, params->args[0], loc); }
static bool intrinsic_clamp(struct hlsl_ctx *ctx,
const struct parse_initializer *params, struct vkd3d_shader_location loc)
{ struct hlsl_ir_expr *max;const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
- if (!(max = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MAX, params->args[0], params->args[1], &loc)))
- if (!(max = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MAX, params->args[0], params->args[1], loc))) return false;
- return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MIN, &max->node, params->args[2], &loc);
return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MIN, &max->node, params->args[2], loc); }
static bool intrinsic_cross(struct hlsl_ctx *ctx,
const struct parse_initializer *params, struct vkd3d_shader_location loc)
{ struct hlsl_ir_swizzle *arg1_swzl1, *arg1_swzl2, *arg2_swzl1, *arg2_swzl2; struct hlsl_ir_node *arg1 = params->args[0], *arg2 = params->args[1];const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
@@ -1603,78 +1604,78 @@ static bool intrinsic_cross(struct hlsl_ctx *ctx,
cast_type = hlsl_get_vector_type(ctx, base, 3);
- if (!(arg1_cast = add_implicit_conversion(ctx, params->instrs, arg1, cast_type, &loc)))
- if (!(arg1_cast = add_implicit_conversion(ctx, params->instrs, arg1, cast_type, loc))) return false;
- if (!(arg2_cast = add_implicit_conversion(ctx, params->instrs, arg2, cast_type, &loc)))
- if (!(arg2_cast = add_implicit_conversion(ctx, params->instrs, arg2, cast_type, loc))) return false;
- if (!(arg1_swzl1 = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(Z, X, Y, Z), 3, arg1_cast, &loc)))
- if (!(arg1_swzl1 = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(Z, X, Y, Z), 3, arg1_cast, loc))) return false; list_add_tail(params->instrs, &arg1_swzl1->node.entry);
- if (!(arg2_swzl1 = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(Y, Z, X, Y), 3, arg2_cast, &loc)))
if (!(arg2_swzl1 = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(Y, Z, X, Y), 3, arg2_cast, loc))) return false; list_add_tail(params->instrs, &arg2_swzl1->node.entry);
if (!(mul1 = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MUL,
&arg1_swzl1->node, &arg2_swzl1->node, &loc)))
&arg1_swzl1->node, &arg2_swzl1->node, loc))) return false;
- if (!(mul1_neg = hlsl_new_unary_expr(ctx, HLSL_OP1_NEG, &mul1->node, loc)))
- if (!(mul1_neg = hlsl_new_unary_expr(ctx, HLSL_OP1_NEG, &mul1->node, *loc))) return false; list_add_tail(params->instrs, &mul1_neg->entry);
- if (!(arg1_swzl2 = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(Y, Z, X, Y), 3, arg1_cast, &loc)))
- if (!(arg1_swzl2 = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(Y, Z, X, Y), 3, arg1_cast, loc))) return false; list_add_tail(params->instrs, &arg1_swzl2->node.entry);
- if (!(arg2_swzl2 = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(Z, X, Y, Z), 3, arg2_cast, &loc)))
if (!(arg2_swzl2 = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(Z, X, Y, Z), 3, arg2_cast, loc))) return false; list_add_tail(params->instrs, &arg2_swzl2->node.entry);
if (!(mul2 = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MUL,
&arg1_swzl2->node, &arg2_swzl2->node, &loc)))
&arg1_swzl2->node, &arg2_swzl2->node, loc))) return false;
- return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_ADD, &mul2->node, mul1_neg, &loc);
return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_ADD, &mul2->node, mul1_neg, loc); }
static bool intrinsic_max(struct hlsl_ctx *ctx,
const struct parse_initializer *params, struct vkd3d_shader_location loc)
{const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
- return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MAX, params->args[0], params->args[1], &loc);
return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MAX, params->args[0], params->args[1], loc); }
static bool intrinsic_pow(struct hlsl_ctx *ctx,
const struct parse_initializer *params, struct vkd3d_shader_location loc)
{ struct hlsl_ir_node *log, *exp; struct hlsl_ir_expr *mul;const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
- if (!(log = hlsl_new_unary_expr(ctx, HLSL_OP1_LOG2, params->args[0], loc)))
- if (!(log = hlsl_new_unary_expr(ctx, HLSL_OP1_LOG2, params->args[0], *loc))) return false; list_add_tail(params->instrs, &log->entry);
- if (!(mul = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MUL, params->args[1], log, &loc)))
- if (!(mul = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MUL, params->args[1], log, loc))) return false;
- if (!(exp = hlsl_new_unary_expr(ctx, HLSL_OP1_EXP2, &mul->node, loc)))
if (!(exp = hlsl_new_unary_expr(ctx, HLSL_OP1_EXP2, &mul->node, *loc))) return false; list_add_tail(params->instrs, &exp->entry); return true; }
static bool intrinsic_round(struct hlsl_ctx *ctx,
const struct parse_initializer *params, struct vkd3d_shader_location loc)
{const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
- return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_ROUND, params->args[0], &loc);
return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_ROUND, params->args[0], loc); }
static bool intrinsic_saturate(struct hlsl_ctx *ctx,
const struct parse_initializer *params, struct vkd3d_shader_location loc)
{const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
- return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_SAT, params->args[0], &loc);
return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_SAT, params->args[0], loc); }
static const struct intrinsic_function
@@ -1682,7 +1683,8 @@ static const struct intrinsic_function const char *name; int param_count; bool check_numeric;
- bool (*handler)(struct hlsl_ctx *ctx, const struct parse_initializer *params, struct vkd3d_shader_location loc);
- bool (*handler)(struct hlsl_ctx *ctx, const struct parse_initializer *params,
} intrinsic_functions[] = {const struct vkd3d_shader_location *loc);
@@ -1748,7 +1750,7 @@ static struct list *add_call(struct hlsl_ctx *ctx, const char *name, } }
if (!intrinsic->handler(ctx, params, loc))
if (!intrinsic->handler(ctx, params, &loc)) { free_parse_initializer(params); return NULL;
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- This patch looks fine, but it makes me wonder that where is probably something to fix in an earlier commit...
On 23/11/21 02:45, Zebediah Figura wrote:
@@ -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);
Here you pass the swizzle_type field to sm4_register_from_deref, as write_sm4_ld already does. However, it seems that sm4_register_from_deref currently ignores swizzle_type in its texture branch, so that's going to remain uninitialized (swizzle_type is also ignored in another branch of sm4_register_from_deref).
I guess the patch that introduced swizzle_type missed a few cases, I doubt there is a reason why textures should not have the swizzle_type field set, right?
Thanks, Giovanni.