vkd3d-shader/tpf.c:3810:39: warning: passing argument 2 of ‘sm4_register_from_node’ from incompatible pointer type [-Wincompatible-pointer-types] vkd3d-shader/tpf.c:4750:59: warning: passing argument 3 of ‘sm4_register_from_deref’ from incompatible pointer type [-Wincompatible-pointer-types]
The other option is to change the parameter to a DWORD but this is a larger change.
-- v2: vkd3d-shader: Fix compiler warning.
From: Alistair Leslie-Hughes leslie_alistair@hotmail.com
vkd3d-shader/tpf.c:3810:39: warning: passing argument 2 of ‘sm4_register_from_node’ from incompatible pointer type [-Wincompatible-pointer-types] vkd3d-shader/tpf.c:4750:59: warning: passing argument 3 of ‘sm4_register_from_deref’ from incompatible pointer type [-Wincompatible-pointer-types]
Change to use uint32_t as requested. --- libs/vkd3d-shader/tpf.c | 17 ++++++++++------- libs/vkd3d-shader/vkd3d_shader_private.h | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/libs/vkd3d-shader/tpf.c b/libs/vkd3d-shader/tpf.c index 63771736..4ca0feae 100644 --- a/libs/vkd3d-shader/tpf.c +++ b/libs/vkd3d-shader/tpf.c @@ -3639,7 +3639,7 @@ struct sm4_instruction };
static void sm4_register_from_deref(struct hlsl_ctx *ctx, struct vkd3d_shader_register *reg, - unsigned int *writemask, enum vkd3d_sm4_swizzle_type *swizzle_type, + uint32_t *writemask, enum vkd3d_sm4_swizzle_type *swizzle_type, const struct hlsl_deref *deref) { const struct hlsl_type *data_type = hlsl_deref_get_type(ctx, deref); @@ -3781,7 +3781,8 @@ static void sm4_register_from_deref(struct hlsl_ctx *ctx, struct vkd3d_shader_re static void sm4_src_from_deref(struct hlsl_ctx *ctx, struct sm4_src_register *src, const struct hlsl_deref *deref, unsigned int map_writemask) { - unsigned int writemask, hlsl_swizzle; + uint32_t writemask; + unsigned int hlsl_swizzle;
sm4_register_from_deref(ctx, &src->reg, &writemask, &src->swizzle_type, deref); if (src->swizzle_type == VKD3D_SM4_SWIZZLE_VEC4) @@ -3791,7 +3792,7 @@ static void sm4_src_from_deref(struct hlsl_ctx *ctx, struct sm4_src_register *sr } }
-static void sm4_register_from_node(struct vkd3d_shader_register *reg, unsigned int *writemask, +static void sm4_register_from_node(struct vkd3d_shader_register *reg, uint32_t *writemask, enum vkd3d_sm4_swizzle_type *swizzle_type, const struct hlsl_ir_node *instr) { assert(instr->reg.allocated); @@ -3837,9 +3838,10 @@ static void sm4_src_from_constant_value(struct sm4_src_register *src, }
static void sm4_src_from_node(struct sm4_src_register *src, - const struct hlsl_ir_node *instr, unsigned int map_writemask) + const struct hlsl_ir_node *instr, uint32_t map_writemask) { - unsigned int writemask, hlsl_swizzle; + uint32_t writemask; + unsigned int hlsl_swizzle;
if (instr->type == HLSL_IR_CONSTANT) { @@ -5454,7 +5456,7 @@ static void write_sm4_store(const struct tpf_writer *tpf, const struct hlsl_ir_s { const struct hlsl_ir_node *rhs = store->rhs.node; struct sm4_instruction instr; - unsigned int writemask; + uint32_t writemask;
memset(&instr, 0, sizeof(instr)); instr.opcode = VKD3D_SM4_OP_MOV; @@ -5471,7 +5473,8 @@ static void write_sm4_store(const struct tpf_writer *tpf, const struct hlsl_ir_s
static void write_sm4_swizzle(const struct tpf_writer *tpf, const struct hlsl_ir_swizzle *swizzle) { - unsigned int writemask, hlsl_swizzle; + uint32_t writemask; + unsigned int hlsl_swizzle; struct sm4_instruction instr;
memset(&instr, 0, sizeof(instr)); diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index af75ef3b..f006d2db 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -758,7 +758,7 @@ void vsir_register_init(struct vkd3d_shader_register *reg, enum vkd3d_shader_reg struct vkd3d_shader_dst_param { struct vkd3d_shader_register reg; - DWORD write_mask; + uint32_t write_mask; DWORD modifiers; DWORD shift; };
On Mon Oct 2 21:48:01 2023 +0000, Henri Verbeet wrote:
No objections from me, but since Francisco is working on this it's
appropriate to have a green light from him too. In general sure, but I think this is straightforward. I'd suggest using uint32_t though, because this is a mask. More broadly, the only places in vkd3d that should use Windows types like DWORD are places where those are dictated by the API we're implementing; for vkd3d-shader that's essentially nowhere. (Because things like DWORD don't have a consistent definition between the Linux and the Windows build. We want to address that, but avoiding these types avoids the issue, and there should be few places that actually require them.)
At first I was worried about changing `vkd3d_shader_dst_param.write_mask` from DWORD to uint32_t, but your comment implies that it is okay to change them to uint32_t, so I think the change is okay.
There are several other fields in vkd3d_shader_dst_param and vkd3d_shader_src_param that also use DWORD though, should I write patches to replace those?
Francisco Casas (@fcasas) commented about libs/vkd3d-shader/tpf.c:
static void sm4_src_from_deref(struct hlsl_ctx *ctx, struct sm4_src_register *src, const struct hlsl_deref *deref, unsigned int map_writemask) {
- unsigned int writemask, hlsl_swizzle;
- uint32_t writemask;
- unsigned int hlsl_swizzle;
Our convention is that declaration lines should be from longest to shortest, so `unsigned int hlsl_swizzle;` should be first here.
Same for sm4_src_from_node() and in write_sm4_swizzle().