vkd3d-shader: Introduce struct vkd3d_shader_parameter_info and struct vkd3d_shader_parameter1.

As the newly added documentation describes, this reroll serves two purposes:

* to allow shader parameters to be used for any target type (which allows using
  parameters for things like Direct3D 8-9 alpha test),

* to allow the union in struct vkd3d_shader_parameter to contain types larger
  than 32 bits (by specifying them indirectly through a pointer).
This commit is contained in:
Elizabeth Figura
2024-06-07 17:32:56 -05:00
committed by Henri Verbeet
parent bec4f413dc
commit 98def3214b
Notes: Henri Verbeet 2024-07-11 17:16:48 +02:00
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/870
8 changed files with 153 additions and 19 deletions

View File

@@ -2418,6 +2418,8 @@ struct spirv_compiler
uint32_t *descriptor_offset_ids;
struct vkd3d_push_constant_buffer_binding *push_constants;
const struct vkd3d_shader_spirv_target_info *spirv_target_info;
const struct vkd3d_shader_parameter1 *parameters;
unsigned int parameter_count;
bool prolog_emitted;
struct shader_signature input_signature;
@@ -3290,16 +3292,15 @@ 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);
}
static const struct vkd3d_shader_parameter *spirv_compiler_get_shader_parameter(
static const struct vkd3d_shader_parameter1 *spirv_compiler_get_shader_parameter(
struct spirv_compiler *compiler, enum vkd3d_shader_parameter_name name)
{
const struct vkd3d_shader_spirv_target_info *info = compiler->spirv_target_info;
unsigned int i;
for (i = 0; info && i < info->parameter_count; ++i)
for (i = 0; i < compiler->parameter_count; ++i)
{
if (info->parameters[i].name == name)
return &info->parameters[i];
if (compiler->parameters[i].name == name)
return &compiler->parameters[i];
}
return NULL;
@@ -3396,7 +3397,7 @@ static uint32_t spirv_compiler_get_spec_constant(struct spirv_compiler *compiler
static uint32_t spirv_compiler_emit_uint_shader_parameter(struct spirv_compiler *compiler,
enum vkd3d_shader_parameter_name name)
{
const struct vkd3d_shader_parameter *parameter;
const struct vkd3d_shader_parameter1 *parameter;
if (!(parameter = spirv_compiler_get_shader_parameter(compiler, name)))
{
@@ -10570,6 +10571,9 @@ static int spirv_compiler_generate_spirv(struct spirv_compiler *compiler, struct
spirv_compiler_emit_descriptor_declarations(compiler);
compiler->parameter_count = program->parameter_count;
compiler->parameters = program->parameters;
if (program->block_count && !spirv_compiler_init_blocks(compiler, program->block_count))
return VKD3D_ERROR_OUT_OF_MEMORY;