vkd3d-shader/spirv: Write spirv_compiler_emit_variable() in terms of spirv_compiler_emit_array_variable().

Essentially for code clarity, so that it's more obvious that a
non-array variable is indeed an array variable with no indices.
This commit is contained in:
Giovanni Mascellani 2024-10-08 22:14:53 +02:00 committed by Henri Verbeet
parent aba45d0386
commit 9cb4207c92
Notes: Henri Verbeet 2024-10-09 13:19:55 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1163

View File

@ -3267,18 +3267,6 @@ static void spirv_compiler_emit_register_debug_name(struct vkd3d_spirv_builder *
vkd3d_spirv_build_op_name(builder, id, "%s", debug_name); vkd3d_spirv_build_op_name(builder, id, "%s", debug_name);
} }
static uint32_t spirv_compiler_emit_variable(struct spirv_compiler *compiler,
struct vkd3d_spirv_stream *stream, SpvStorageClass storage_class,
enum vkd3d_shader_component_type component_type, unsigned int component_count)
{
struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
uint32_t type_id, ptr_type_id;
type_id = vkd3d_spirv_get_type_id(builder, component_type, component_count);
ptr_type_id = vkd3d_spirv_get_op_type_pointer(builder, storage_class, type_id);
return vkd3d_spirv_build_op_variable(builder, stream, ptr_type_id, storage_class, 0);
}
static uint32_t spirv_compiler_emit_array_variable(struct spirv_compiler *compiler, static uint32_t spirv_compiler_emit_array_variable(struct spirv_compiler *compiler,
struct vkd3d_spirv_stream *stream, SpvStorageClass storage_class, struct vkd3d_spirv_stream *stream, SpvStorageClass storage_class,
enum vkd3d_shader_component_type component_type, unsigned int component_count, enum vkd3d_shader_component_type component_type, unsigned int component_count,
@ -3288,10 +3276,6 @@ static uint32_t spirv_compiler_emit_array_variable(struct spirv_compiler *compil
uint32_t type_id, length_id, ptr_type_id; uint32_t type_id, length_id, ptr_type_id;
unsigned int i; unsigned int i;
if (!length_count)
return spirv_compiler_emit_variable(compiler,
stream, storage_class, component_type, component_count);
type_id = vkd3d_spirv_get_type_id(builder, component_type, component_count); type_id = vkd3d_spirv_get_type_id(builder, component_type, component_count);
for (i = 0; i < length_count; ++i) for (i = 0; i < length_count; ++i)
{ {
@ -3305,6 +3289,14 @@ static uint32_t spirv_compiler_emit_array_variable(struct spirv_compiler *compil
return vkd3d_spirv_build_op_variable(builder, stream, ptr_type_id, storage_class, 0); return vkd3d_spirv_build_op_variable(builder, stream, ptr_type_id, storage_class, 0);
} }
static uint32_t spirv_compiler_emit_variable(struct spirv_compiler *compiler,
struct vkd3d_spirv_stream *stream, SpvStorageClass storage_class,
enum vkd3d_shader_component_type component_type, unsigned int component_count)
{
return spirv_compiler_emit_array_variable(compiler, stream, storage_class,
component_type, component_count, NULL, 0);
}
static const struct vkd3d_spec_constant_info static const struct vkd3d_spec_constant_info
{ {
enum vkd3d_shader_parameter_name name; enum vkd3d_shader_parameter_name name;