Module: vkd3d Branch: master Commit: dbb715a160e12206ee9e762656f9d006507396bf URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=dbb715a160e12206ee9e7626...
Author: Conor McCarthy cmccarthy@codeweavers.com Date: Tue Jul 27 23:39:57 2021 +1000
vkd3d-shader: Include register ranges in descriptor binding error messages.
Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com Signed-off-by: Henri Verbeet hverbeet@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
libs/vkd3d-shader/spirv.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 0407f50..23d1fcc 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -2236,6 +2236,8 @@ struct vkd3d_dxbc_compiler struct vkd3d_shader_spec_constant *spec_constants; size_t spec_constants_size; enum vkd3d_shader_compile_option_formatting_flags formatting; + + struct vkd3d_string_buffer_cache string_buffers; };
static bool is_control_point_phase(const struct vkd3d_shader_phase *phase) @@ -2358,6 +2360,8 @@ struct vkd3d_dxbc_compiler *vkd3d_dxbc_compiler_create(const struct vkd3d_shader
compiler->scan_descriptor_info = scan_descriptor_info;
+ vkd3d_string_buffer_cache_init(&compiler->string_buffers); + vkd3d_dxbc_compiler_emit_initial_declarations(compiler);
return compiler; @@ -2484,6 +2488,22 @@ static void VKD3D_PRINTF_FUNC(3, 4) vkd3d_dxbc_compiler_error(struct vkd3d_dxbc_ compiler->failed = true; }
+static struct vkd3d_string_buffer *vkd3d_shader_register_range_string(struct vkd3d_dxbc_compiler *compiler, + const struct vkd3d_shader_register_range *range) +{ + struct vkd3d_string_buffer *buffer = vkd3d_string_buffer_get(&compiler->string_buffers); + + if (!buffer) + return NULL; + + if (range->last != ~0u) + vkd3d_string_buffer_printf(buffer, "[%u:%u]", range->first, range->last); + else + vkd3d_string_buffer_printf(buffer, "[%u:*]", range->first); + + return buffer; +} + static struct vkd3d_shader_descriptor_binding vkd3d_dxbc_compiler_get_descriptor_binding( struct vkd3d_dxbc_compiler *compiler, const struct vkd3d_shader_register *reg, const struct vkd3d_shader_register_range *range, enum vkd3d_shader_resource_type resource_type, @@ -2576,11 +2596,14 @@ static struct vkd3d_shader_descriptor_binding vkd3d_dxbc_compiler_get_descriptor } if (shader_interface->binding_count) { - FIXME("Could not find binding for type %#x, space %u, register %u, shader type %#x.\n", - descriptor_type, range->space, range->first, compiler->shader_type); + struct vkd3d_string_buffer *buffer = vkd3d_shader_register_range_string(compiler, range); + const char *range_str = buffer ? buffer->buffer : ""; + FIXME("Could not find descriptor binding for type %#x, space %u, registers %s, shader type %#x.\n", + descriptor_type, range->space, range_str, compiler->shader_type); vkd3d_dxbc_compiler_error(compiler, VKD3D_SHADER_ERROR_SPV_DESCRIPTOR_BINDING_NOT_FOUND, - "Could not find descriptor binding for type %#x, space %u, register %u, shader type %#x.", - descriptor_type, range->space, range->first, compiler->shader_type); + "Could not find descriptor binding for type %#x, space %u, registers %s, shader type %#x.", + descriptor_type, range->space, range_str, compiler->shader_type); + vkd3d_string_buffer_release(&compiler->string_buffers, buffer); } }
@@ -9611,5 +9634,7 @@ void vkd3d_dxbc_compiler_destroy(struct vkd3d_dxbc_compiler *compiler) vkd3d_free(compiler->shader_phases); vkd3d_free(compiler->spec_constants);
+ vkd3d_string_buffer_cache_cleanup(&compiler->string_buffers); + vkd3d_free(compiler); }