From e20b63c55e0a78fd080646c0128f4b529b3d76cc Mon Sep 17 00:00:00 2001 From: Shaun Ren Date: Tue, 22 Oct 2024 22:30:13 -0400 Subject: [PATCH] vkd3d-shader: Implement scanning hull shader tessellation information. --- include/vkd3d_shader.h | 25 +++++++++++++++++++++++++ libs/vkd3d-shader/vkd3d_shader_main.c | 18 ++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/include/vkd3d_shader.h b/include/vkd3d_shader.h index f95caa2f..cb561d7f 100644 --- a/include/vkd3d_shader.h +++ b/include/vkd3d_shader.h @@ -112,6 +112,11 @@ enum vkd3d_shader_structure_type * \since 1.13 */ VKD3D_SHADER_STRUCTURE_TYPE_PARAMETER_INFO, + /** + * The structure is a vkd3d_shader_scan_hull_shader_tessellation_info structure. + * \since 1.15 + */ + VKD3D_SHADER_STRUCTURE_TYPE_SCAN_HULL_SHADER_TESSELLATION_INFO, VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_STRUCTURE_TYPE), }; @@ -2040,6 +2045,26 @@ struct vkd3d_shader_scan_combined_resource_sampler_info unsigned int combined_sampler_count; }; +/** + * A chained structure describing the tessellation information in a hull shader. + * + * This structure extends vkd3d_shader_compile_info. + * + * \since 1.15 + */ +struct vkd3d_shader_scan_hull_shader_tessellation_info +{ + /** Must be set to VKD3D_SHADER_STRUCTURE_TYPE_SCAN_HULL_SHADER_TESSELLATION_INFO. */ + enum vkd3d_shader_structure_type type; + /** Optional pointer to a structure containing further parameters. */ + const void *next; + + /** The tessellation output primitive. */ + enum vkd3d_shader_tessellator_output_primitive output_primitive; + /** The tessellation partitioning mode. */ + enum vkd3d_shader_tessellator_partitioning partitioning; +}; + /** * Data type of a shader varying, returned as part of struct * vkd3d_shader_signature_element. diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c index 94899d03..dcda7ef0 100644 --- a/libs/vkd3d-shader/vkd3d_shader_main.c +++ b/libs/vkd3d-shader/vkd3d_shader_main.c @@ -807,6 +807,9 @@ struct vkd3d_shader_scan_context struct vkd3d_shader_scan_combined_resource_sampler_info *combined_sampler_info; size_t combined_samplers_size; + + enum vkd3d_shader_tessellator_output_primitive output_primitive; + enum vkd3d_shader_tessellator_partitioning partitioning; }; static VKD3D_PRINTF_FUNC(3, 4) void vkd3d_shader_scan_error(struct vkd3d_shader_scan_context *context, @@ -1264,6 +1267,12 @@ static int vkd3d_shader_scan_instruction(struct vkd3d_shader_scan_context *conte VKD3D_SHADER_RESOURCE_BUFFER, VKD3D_SHADER_RESOURCE_DATA_UINT, 0, instruction->declaration.structured_resource.byte_stride, false, instruction->flags); break; + case VKD3DSIH_DCL_TESSELLATOR_OUTPUT_PRIMITIVE: + context->output_primitive = instruction->declaration.tessellator_output_primitive; + break; + case VKD3DSIH_DCL_TESSELLATOR_PARTITIONING: + context->partitioning = instruction->declaration.tessellator_partitioning; + break; case VKD3DSIH_IF: case VKD3DSIH_IFC: cf_info = vkd3d_shader_scan_push_cf_info(context); @@ -1504,6 +1513,7 @@ static int vsir_program_scan(struct vsir_program *program, const struct vkd3d_sh struct vkd3d_shader_scan_descriptor_info1 *descriptor_info1) { struct vkd3d_shader_scan_combined_resource_sampler_info *combined_sampler_info; + struct vkd3d_shader_scan_hull_shader_tessellation_info *tessellation_info; struct vkd3d_shader_scan_descriptor_info1 local_descriptor_info1 = {0}; struct vkd3d_shader_scan_descriptor_info *descriptor_info; struct vkd3d_shader_scan_signature_info *signature_info; @@ -1532,6 +1542,8 @@ static int vsir_program_scan(struct vsir_program *program, const struct vkd3d_sh descriptor_info1 = &local_descriptor_info1; } + tessellation_info = vkd3d_find_struct(compile_info->next, SCAN_HULL_SHADER_TESSELLATION_INFO); + vkd3d_shader_scan_context_init(&context, &program->shader_version, compile_info, descriptor_info1, combined_sampler_info, message_context); @@ -1575,6 +1587,12 @@ static int vsir_program_scan(struct vsir_program *program, const struct vkd3d_sh if (!ret && descriptor_info) ret = convert_descriptor_info(descriptor_info, descriptor_info1); + if (!ret && tessellation_info) + { + tessellation_info->output_primitive = context.output_primitive; + tessellation_info->partitioning = context.partitioning; + } + if (ret < 0) { if (combined_sampler_info)