vkd3d-shader: Rename vkd3d_shader_next_stage_info to vkd3d_shader_varying_map_info.

It was originally intended that this structure could hold other information
about the next stage which compilation might depend on. For example, compilation
to GLSL needs to know the type of the next shader in some circumstances.

That was never actualized, and since the API is fixed at this point for 1.9, it
makes the most sense to rename the structure to match its actual scope.

The documentation was written and arranged to imply that the structure would
hold other information about the next shader than the varying map; this is
changed accordingly as well.
This commit is contained in:
Zebediah Figura 2023-09-19 16:04:53 -05:00 committed by Alexandre Julliard
parent 46c7f65be8
commit fd120d8f2d
Notes: Alexandre Julliard 2023-09-21 22:01:59 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/356
2 changed files with 28 additions and 30 deletions

View File

@ -91,10 +91,10 @@ enum vkd3d_shader_structure_type
*/ */
VKD3D_SHADER_STRUCTURE_TYPE_SCAN_SIGNATURE_INFO, VKD3D_SHADER_STRUCTURE_TYPE_SCAN_SIGNATURE_INFO,
/** /**
* The structure is a vkd3d_shader_next_stage_info structure. * The structure is a vkd3d_shader_varying_map_info structure.
* \since 1.9 * \since 1.9
*/ */
VKD3D_SHADER_STRUCTURE_TYPE_NEXT_STAGE_INFO, VKD3D_SHADER_STRUCTURE_TYPE_VARYING_MAP_INFO,
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_STRUCTURE_TYPE), VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_STRUCTURE_TYPE),
}; };
@ -1690,7 +1690,7 @@ struct vkd3d_shader_scan_signature_info
* Describes the mapping of a output varying register in a shader stage, * Describes the mapping of a output varying register in a shader stage,
* to an input varying register in the following shader stage. * to an input varying register in the following shader stage.
* *
* This structure is used in struct vkd3d_shader_next_stage_info. * This structure is used in struct vkd3d_shader_varying_map_info.
*/ */
struct vkd3d_shader_varying_map struct vkd3d_shader_varying_map
{ {
@ -1708,15 +1708,21 @@ struct vkd3d_shader_varying_map
}; };
/** /**
* A chained structure which describes the next shader in the pipeline. * A chained structure which describes how output varyings in this shader stage
* should be mapped to input varyings in the next stage.
* *
* This structure is optional, and should only be provided if there is in fact * This structure is optional. It should not be provided if there is no shader
* another shader in the pipeline. * stage.
* However, depending on the input and output formats, this structure may be * However, depending on the input and output formats, this structure may be
* necessary in order to generate shaders which correctly match each other. * necessary in order to generate shaders which correctly match each other.
* If the structure or its individual fields are not provided, vkd3d-shader *
* will generate shaders which may be correct in isolation, but are not * If this structure is absent, vkd3d-shader will map varyings from one stage
* guaranteed to correctly match each other. * to another based on their register index.
* For Direct3D shader model 3.0, such a default mapping will be incorrect
* unless the registers are allocated in the same order, and hence this
* field is necessary to correctly match inter-stage varyings.
* This mapping may also be necessary under other circumstances where the
* varying interface does not match exactly.
* *
* This structure is passed to vkd3d_shader_compile() and extends * This structure is passed to vkd3d_shader_compile() and extends
* vkd3d_shader_compile_info. * vkd3d_shader_compile_info.
@ -1725,9 +1731,9 @@ struct vkd3d_shader_varying_map
* *
* \since 1.9 * \since 1.9
*/ */
struct vkd3d_shader_next_stage_info struct vkd3d_shader_varying_map_info
{ {
/** Must be set to VKD3D_SHADER_STRUCTURE_TYPE_NEXT_STAGE_INFO. */ /** Must be set to VKD3D_SHADER_STRUCTURE_TYPE_VARYING_MAP_INFO. */
enum vkd3d_shader_structure_type type; enum vkd3d_shader_structure_type type;
/** Optional pointer to a structure containing further parameters. */ /** Optional pointer to a structure containing further parameters. */
const void *next; const void *next;
@ -1741,14 +1747,6 @@ struct vkd3d_shader_next_stage_info
* If this shader stage outputs a varying that is not consumed by the next * If this shader stage outputs a varying that is not consumed by the next
* shader stage, that varying should be absent from this array. * shader stage, that varying should be absent from this array.
* *
* If this field is absent, vkd3d-shader will map varyings from one stage
* to another based on their register index.
* For Direct3D shader model 3.0, such a default mapping will be incorrect
* unless the registers are allocated in the same order, and hence this
* field is necessary to correctly match inter-stage varyings.
* This mapping may also be necessary under other circumstances where the
* varying interface does not match exactly.
*
* This mapping may be constructed by vkd3d_shader_build_varying_map(). * This mapping may be constructed by vkd3d_shader_build_varying_map().
*/ */
const struct vkd3d_shader_varying_map *varying_map; const struct vkd3d_shader_varying_map *varying_map;
@ -1830,7 +1828,7 @@ VKD3D_SHADER_API const enum vkd3d_shader_target_type *vkd3d_shader_get_supported
* following chained structures: * following chained structures:
* - vkd3d_shader_hlsl_source_info * - vkd3d_shader_hlsl_source_info
* - vkd3d_shader_interface_info * - vkd3d_shader_interface_info
* - vkd3d_shader_next_stage_info * - vkd3d_shader_varying_map_info
* - vkd3d_shader_scan_descriptor_info * - vkd3d_shader_scan_descriptor_info
* - vkd3d_shader_scan_signature_info * - vkd3d_shader_scan_signature_info
* - vkd3d_shader_spirv_domain_shader_target_info * - vkd3d_shader_spirv_domain_shader_target_info
@ -2273,7 +2271,7 @@ VKD3D_SHADER_API void vkd3d_shader_free_scan_signature_info(struct vkd3d_shader_
* Build a mapping of output varyings in a shader stage to input varyings in * Build a mapping of output varyings in a shader stage to input varyings in
* the following shader stage. * the following shader stage.
* *
* This mapping should be used in struct vkd3d_shader_next_stage_info to * This mapping should be used in struct vkd3d_shader_varying_map_info to
* compile the first shader. * compile the first shader.
* *
* \param output_signature The output signature of the first shader. * \param output_signature The output signature of the first shader.

View File

@ -86,14 +86,14 @@ static void shader_instruction_eliminate_phase_instance_id(struct vkd3d_shader_i
} }
static const struct vkd3d_shader_varying_map *find_varying_map( static const struct vkd3d_shader_varying_map *find_varying_map(
const struct vkd3d_shader_next_stage_info *next_stage, unsigned int signature_idx) const struct vkd3d_shader_varying_map_info *varying_map, unsigned int signature_idx)
{ {
unsigned int i; unsigned int i;
for (i = 0; i < next_stage->varying_count; ++i) for (i = 0; i < varying_map->varying_count; ++i)
{ {
if (next_stage->varying_map[i].output_signature_index == signature_idx) if (varying_map->varying_map[i].output_signature_index == signature_idx)
return &next_stage->varying_map[i]; return &varying_map->varying_map[i];
} }
return NULL; return NULL;
@ -103,15 +103,15 @@ static enum vkd3d_result remap_output_signature(struct vkd3d_shader_parser *pars
const struct vkd3d_shader_compile_info *compile_info) const struct vkd3d_shader_compile_info *compile_info)
{ {
struct shader_signature *signature = &parser->shader_desc.output_signature; struct shader_signature *signature = &parser->shader_desc.output_signature;
const struct vkd3d_shader_next_stage_info *next_stage; const struct vkd3d_shader_varying_map_info *varying_map;
unsigned int i; unsigned int i;
if (!(next_stage = vkd3d_find_struct(compile_info->next, NEXT_STAGE_INFO))) if (!(varying_map = vkd3d_find_struct(compile_info->next, VARYING_MAP_INFO)))
return VKD3D_OK; return VKD3D_OK;
for (i = 0; i < signature->element_count; ++i) for (i = 0; i < signature->element_count; ++i)
{ {
const struct vkd3d_shader_varying_map *map = find_varying_map(next_stage, i); const struct vkd3d_shader_varying_map *map = find_varying_map(varying_map, i);
struct signature_element *e = &signature->elements[i]; struct signature_element *e = &signature->elements[i];
if (map) if (map)
@ -137,9 +137,9 @@ static enum vkd3d_result remap_output_signature(struct vkd3d_shader_parser *pars
} }
} }
for (i = 0; i < next_stage->varying_count; ++i) for (i = 0; i < varying_map->varying_count; ++i)
{ {
if (next_stage->varying_map[i].output_signature_index >= signature->element_count) if (varying_map->varying_map[i].output_signature_index >= signature->element_count)
{ {
vkd3d_shader_parser_error(parser, VKD3D_SHADER_ERROR_VSIR_NOT_IMPLEMENTED, vkd3d_shader_parser_error(parser, VKD3D_SHADER_ERROR_VSIR_NOT_IMPLEMENTED,
"Aborting due to not yet implemented feature: " "Aborting due to not yet implemented feature: "