Zebediah Figura (@zfigura) commented about libs/vkd3d-shader/hlsl_codegen.c:
-static void calculate_buffer_offset(struct hlsl_ir_var *var) +static void calculate_buffer_offset(struct hlsl_ctx *ctx, struct hlsl_ir_var *var) { + unsigned int var_reg_size = var->data_type->reg_size[HLSL_REGSET_NUMERIC]; struct hlsl_buffer *buffer = var->buffer;
- buffer->size = hlsl_type_get_sm4_offset(var->data_type, buffer->size); + if (var->offset_reservation.type == 'c') + { + unsigned int proper_offset = hlsl_type_get_sm4_offset(var->data_type, + var->offset_reservation.index); + if (proper_offset != var->offset_reservation.index) + { + hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_RESERVATION, + "Invalid packoffset() swizzle in reservation.");
Technically true, but I feel like this could be clearer. Perhaps something like "must be properly aligned"? "proper_offset" is not a very clear name for a variable. "aligned_offset" strikes me as clearer. Also, should this check be here? Note that calculate_buffer_offset() is called only for variables that are used. We don't have tests for this. -- https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/106#note_25672