From a0fc2a20f3ffd8fcab6cee4127258530e06978bb Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Tue, 27 Jul 2021 16:06:46 -0500 Subject: [PATCH] vkd3d-shader: Use vkd3d_bytecode_buffer helpers directly in shader_write_descriptor_ranges(). Signed-off-by: Zebediah Figura Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- libs/vkd3d-shader/dxbc.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index c076b0fe..21518695 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -2986,7 +2986,7 @@ static void shader_write_root_signature_header(struct root_signature_writer_cont context->chunk_position = bytecode_get_size(buffer); } -static int shader_write_descriptor_ranges(struct root_signature_writer_context *context, +static void shader_write_descriptor_ranges(struct vkd3d_bytecode_buffer *buffer, const struct vkd3d_shader_root_descriptor_table *table) { const struct vkd3d_shader_descriptor_range *ranges = table->descriptor_ranges; @@ -2994,24 +2994,12 @@ static int shader_write_descriptor_ranges(struct root_signature_writer_context * for (i = 0; i < table->descriptor_range_count; ++i) { - if (!write_dword(context, ranges[i].range_type)) - goto fail; - if (!write_dword(context, ranges[i].descriptor_count)) - goto fail; - if (!write_dword(context, ranges[i].base_shader_register)) - goto fail; - if (!write_dword(context, ranges[i].register_space)) - goto fail; - if (!write_dword(context, ranges[i].descriptor_table_offset)) - goto fail; + put_u32(buffer, ranges[i].range_type); + put_u32(buffer, ranges[i].descriptor_count); + put_u32(buffer, ranges[i].base_shader_register); + put_u32(buffer, ranges[i].register_space); + put_u32(buffer, ranges[i].descriptor_table_offset); } - - return VKD3D_OK; - -fail: - vkd3d_shader_error(&context->message_context, NULL, VKD3D_SHADER_ERROR_RS_OUT_OF_MEMORY, - "Out of memory while writing root signature descriptor ranges."); - return VKD3D_ERROR_OUT_OF_MEMORY; } static int shader_write_descriptor_ranges1(struct root_signature_writer_context *context, @@ -3047,12 +3035,15 @@ fail: static int shader_write_descriptor_table(struct root_signature_writer_context *context, const struct vkd3d_shader_root_descriptor_table *table) { + struct vkd3d_bytecode_buffer *buffer = &context->buffer; + if (!write_dword(context, table->descriptor_range_count)) goto fail; if (!write_dword(context, get_chunk_offset(context) + sizeof(DWORD))) /* offset */ goto fail; - return shader_write_descriptor_ranges(context, table); + shader_write_descriptor_ranges(buffer, table); + return VKD3D_OK; fail: vkd3d_shader_error(&context->message_context, NULL, VKD3D_SHADER_ERROR_RS_OUT_OF_MEMORY,