-- v2: vkd3d-shader: Handle size in bytes in spirv_compiler_emit_cbv_declaration().
From: Conor McCarthy cmccarthy@codeweavers.com
Fixes compilation failures in Cyberpunk 2077 due to missing UAV counter flag. --- libs/vkd3d-shader/vkd3d_shader_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c index 273a543a..0c3422f6 100644 --- a/libs/vkd3d-shader/vkd3d_shader_main.c +++ b/libs/vkd3d-shader/vkd3d_shader_main.c @@ -705,7 +705,8 @@ static void vkd3d_shader_scan_add_uav_flag(const struct vkd3d_shader_scan_contex
for (i = 0; i < context->scan_descriptor_info->descriptor_count; ++i) { - if (context->scan_descriptor_info->descriptors[i].register_id == range_id) + if (context->scan_descriptor_info->descriptors[i].type == VKD3D_SHADER_DESCRIPTOR_TYPE_UAV + && context->scan_descriptor_info->descriptors[i].register_id == range_id) { context->scan_descriptor_info->descriptors[i].flags |= flag; break;
From: Conor McCarthy cmccarthy@codeweavers.com
The caller passes a byte size now. --- libs/vkd3d-shader/spirv.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index f93960d6..95f6914a 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -5564,7 +5564,7 @@ static uint32_t spirv_compiler_build_descriptor_variable(struct spirv_compiler * }
static void spirv_compiler_emit_cbv_declaration(struct spirv_compiler *compiler, - const struct vkd3d_shader_register_range *range, unsigned int register_id, unsigned int size) + const struct vkd3d_shader_register_range *range, unsigned int register_id, unsigned int size_in_bytes) { struct vkd3d_spirv_builder *builder = &compiler->spirv_builder; uint32_t vec4_id, array_type_id, length_id, struct_id, var_id; @@ -5572,6 +5572,7 @@ static void spirv_compiler_emit_cbv_declaration(struct spirv_compiler *compiler, struct vkd3d_push_constant_buffer_binding *push_cb; struct vkd3d_descriptor_variable_info var_info; struct vkd3d_symbol reg_symbol; + unsigned int size;
struct vkd3d_shader_register reg = { @@ -5580,18 +5581,19 @@ static void spirv_compiler_emit_cbv_declaration(struct spirv_compiler *compiler, .idx_count = 1, };
+ size = size_in_bytes / (VKD3D_VEC4_SIZE * sizeof(uint32_t)); + if ((push_cb = spirv_compiler_find_push_constant_buffer(compiler, range))) { /* Push constant buffers are handled in * spirv_compiler_emit_push_constant_buffers(). */ - unsigned int cb_size_in_bytes = size * VKD3D_VEC4_SIZE * sizeof(uint32_t); push_cb->reg = reg; push_cb->size = size; - if (cb_size_in_bytes > push_cb->pc.size) + if (size_in_bytes > push_cb->pc.size) { WARN("Constant buffer size %u exceeds push constant size %u.\n", - cb_size_in_bytes, push_cb->pc.size); + size_in_bytes, push_cb->pc.size); } return; }
On Mon Sep 4 00:59:55 2023 +0000, Zebediah Figura wrote:
Oops, sorry about that... Wrt 2/2, my original intent was that these would eventually be exposed as API, and in that case I think byte size is a bit more intuitive to deal with than vec4 size. In that case I intended to fix spirv to treat the size as a byte size, but forgot to do that (and of course the tests didn't catch it, since it just resulted in declaring larger buffers than we actually access).
Makes sense. DXIL contains a byte size so it works well there too.
This merge request was approved by Henri Verbeet.