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

@@ -105,6 +105,11 @@ enum vkd3d_shader_structure_type
* \since 1.10
*/
VKD3D_SHADER_STRUCTURE_TYPE_SCAN_COMBINED_RESOURCE_SAMPLER_INFO,
/**
* The structure is a vkd3d_shader_parameter_info structure.
* \since 1.13
*/
VKD3D_SHADER_STRUCTURE_TYPE_PARAMETER_INFO,
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_STRUCTURE_TYPE),
};
@@ -503,6 +508,20 @@ struct vkd3d_shader_parameter
} u;
};
struct vkd3d_shader_parameter1
{
enum vkd3d_shader_parameter_name name;
enum vkd3d_shader_parameter_type type;
enum vkd3d_shader_parameter_data_type data_type;
union
{
struct vkd3d_shader_parameter_immediate_constant immediate_constant;
struct vkd3d_shader_parameter_specialization_constant specialization_constant;
void *_pointer_pad;
uint32_t _pad[4];
} u;
};
/**
* Symbolic register indices for mapping uniform constant register sets in
* legacy Direct3D bytecode to constant buffer views in the target environment.
@@ -1994,6 +2013,44 @@ struct vkd3d_shader_varying_map_info
unsigned int varying_count;
};
/**
* Interface information regarding a builtin shader parameter.
*
* Like compile options specified with struct vkd3d_shader_compile_option,
* parameters are used to specify certain values which are not part of the
* source shader bytecode but which need to be specified in the shader bytecode
* in the target format.
* Unlike struct vkd3d_shader_compile_option, however, this structure allows
* parameters to be specified in a variety of different ways, as described by
* enum vkd3d_shader_parameter_type.
*
* This structure is an extended version of struct vkd3d_shader_parameter as
* used in struct vkd3d_shader_spirv_target_info, which allows more parameter
* types to be used, and also allows specifying parameters when compiling
* shaders to target types other than SPIR-V. If this structure is chained
* along with vkd3d_shader_spirv_target_info, any parameters specified in the
* latter structure are ignored.
*
* This structure is passed to vkd3d_shader_compile() and extends
* vkd3d_shader_compile_info.
*
* This structure contains only input parameters.
*
* \since 1.13
*/
struct vkd3d_shader_parameter_info
{
/** Must be set to VKD3D_SHADER_STRUCTURE_TYPE_PARAMETER_INFO. */
enum vkd3d_shader_structure_type type;
/** Optional pointer to a structure containing further parameters. */
const void *next;
/** Pointer to an array of dynamic parameters for this shader instance. */
const struct vkd3d_shader_parameter1 *parameters;
/** Size, in elements, of \ref parameters. */
unsigned int parameter_count;
};
#ifdef LIBVKD3D_SHADER_SOURCE
# define VKD3D_SHADER_API VKD3D_EXPORT
#else
@@ -2077,6 +2134,7 @@ VKD3D_SHADER_API const enum vkd3d_shader_target_type *vkd3d_shader_get_supported
* - vkd3d_shader_descriptor_offset_info
* - vkd3d_shader_hlsl_source_info
* - vkd3d_shader_interface_info
* - vkd3d_shader_parameter_info
* - vkd3d_shader_preprocess_info
* - vkd3d_shader_scan_combined_resource_sampler_info
* - vkd3d_shader_scan_descriptor_info