From 760bafd62042523aacc5c322cd5a702f58356300 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Thu, 25 Jun 2020 10:48:28 +0430 Subject: [PATCH] vkd3d-shader: Store sampler comparison mode information in the descriptor scan info. Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- include/vkd3d_shader.h | 6 +++--- libs/vkd3d-shader/spirv.c | 6 ++++-- libs/vkd3d-shader/vkd3d_shader_main.c | 26 ++++++++++++-------------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/include/vkd3d_shader.h b/include/vkd3d_shader.h index 6647d47a..e155663a 100644 --- a/include/vkd3d_shader.h +++ b/include/vkd3d_shader.h @@ -615,8 +615,9 @@ enum vkd3d_shader_resource_data_type enum vkd3d_shader_descriptor_info_flag { - VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_UAV_COUNTER = 0x00000001, - VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_UAV_READ = 0x00000002, + VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_UAV_COUNTER = 0x00000001, + VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_UAV_READ = 0x00000002, + VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_SAMPLER_COMPARISON_MODE = 0x00000004, VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_DESCRIPTOR_INFO_FLAG), }; @@ -640,7 +641,6 @@ struct vkd3d_shader_scan_info struct vkd3d_shader_descriptor_info *descriptors; unsigned int descriptor_count; - unsigned int sampler_comparison_mode_mask; /* 16 */ bool use_vocp; }; diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 7af08d92..0baa1912 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -5218,12 +5218,12 @@ static void vkd3d_dxbc_compiler_emit_combined_sampler_declarations(struct vkd3d_ unsigned int structure_stride, bool raw, const struct vkd3d_spirv_resource_type *resource_type_info) { const struct vkd3d_shader_interface_info *shader_interface = &compiler->shader_interface; - const struct vkd3d_shader_scan_info *scan_info = compiler->scan_info; const SpvStorageClass storage_class = SpvStorageClassUniformConstant; struct vkd3d_spirv_builder *builder = &compiler->spirv_builder; const struct vkd3d_shader_combined_resource_sampler *current; uint32_t image_type_id, type_id, ptr_type_id, var_id; enum vkd3d_shader_binding_flag resource_type_flag; + const struct vkd3d_shader_descriptor_info *d; struct vkd3d_symbol symbol; unsigned int i; bool depth; @@ -5244,8 +5244,10 @@ static void vkd3d_dxbc_compiler_emit_combined_sampler_declarations(struct vkd3d_ if (!vkd3d_dxbc_compiler_check_shader_visibility(compiler, current->shader_visibility)) continue; + d = vkd3d_dxbc_compiler_get_descriptor_info(compiler, + VKD3D_SHADER_DESCRIPTOR_TYPE_SAMPLER, 0, current->sampler_index); depth = current->sampler_index != VKD3D_DUMMY_SAMPLER_INDEX - && scan_info->sampler_comparison_mode_mask & (1u << current->sampler_index); + && (d->flags & VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_SAMPLER_COMPARISON_MODE); image_type_id = vkd3d_dxbc_compiler_get_image_type_id(compiler, resource, resource_space, resource_index, resource_type_info, sampled_type, structure_stride || raw, depth); diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c index 20e9e026..ed673506 100644 --- a/libs/vkd3d-shader/vkd3d_shader_main.c +++ b/libs/vkd3d-shader/vkd3d_shader_main.c @@ -253,7 +253,8 @@ static void vkd3d_shader_scan_record_uav_counter(struct vkd3d_shader_scan_contex static bool vkd3d_shader_scan_add_descriptor(struct vkd3d_shader_scan_context *context, enum vkd3d_shader_descriptor_type type, unsigned int register_space, unsigned int register_index, - enum vkd3d_shader_resource_type resource_type, enum vkd3d_shader_resource_data_type resource_data_type) + enum vkd3d_shader_resource_type resource_type, enum vkd3d_shader_resource_data_type resource_data_type, + unsigned int flags) { struct vkd3d_shader_scan_info *scan_info = context->scan_info; struct vkd3d_shader_descriptor_info *d; @@ -271,7 +272,7 @@ static bool vkd3d_shader_scan_add_descriptor(struct vkd3d_shader_scan_context *c d->register_index = register_index; d->resource_type = resource_type; d->resource_data_type = resource_data_type; - d->flags = 0; + d->flags = flags; d->count = 1; ++scan_info->descriptor_count; @@ -301,7 +302,7 @@ static void vkd3d_shader_scan_constant_buffer_declaration(struct vkd3d_shader_sc const struct vkd3d_shader_constant_buffer *cb = &instruction->declaration.cb; vkd3d_shader_scan_add_descriptor(context, VKD3D_SHADER_DESCRIPTOR_TYPE_CBV, cb->register_space, - cb->register_index, VKD3D_SHADER_RESOURCE_BUFFER, VKD3D_SHADER_RESOURCE_DATA_UINT); + cb->register_index, VKD3D_SHADER_RESOURCE_BUFFER, VKD3D_SHADER_RESOURCE_DATA_UINT, 0); } static void vkd3d_shader_scan_input_declaration(struct vkd3d_shader_scan_info *scan_info, @@ -317,17 +318,14 @@ static void vkd3d_shader_scan_sampler_declaration(struct vkd3d_shader_scan_conte const struct vkd3d_shader_instruction *instruction) { const struct vkd3d_shader_sampler *sampler = &instruction->declaration.sampler; - struct vkd3d_shader_scan_info *scan_info = context->scan_info; - unsigned int sampler_index = sampler->register_index; + unsigned int flags; if (instruction->flags & VKD3DSI_SAMPLER_COMPARISON_MODE) - { - assert(sampler_index < CHAR_BIT * sizeof(scan_info->sampler_comparison_mode_mask)); - scan_info->sampler_comparison_mode_mask |= 1u << sampler_index; - } - + flags = VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_SAMPLER_COMPARISON_MODE; + else + flags = 0; vkd3d_shader_scan_add_descriptor(context, VKD3D_SHADER_DESCRIPTOR_TYPE_SAMPLER, sampler->register_space, - sampler->register_index, VKD3D_SHADER_RESOURCE_NONE, VKD3D_SHADER_RESOURCE_DATA_UINT); + sampler->register_index, VKD3D_SHADER_RESOURCE_NONE, VKD3D_SHADER_RESOURCE_DATA_UINT, flags); } static void vkd3d_shader_scan_resource_declaration(struct vkd3d_shader_scan_context *context, @@ -364,7 +362,7 @@ static void vkd3d_shader_scan_resource_declaration(struct vkd3d_shader_scan_cont break; } vkd3d_shader_scan_add_descriptor(context, type, semantic->register_space, - semantic->register_index, semantic->resource_type, resource_data_type); + semantic->register_index, semantic->resource_type, resource_data_type, 0); if (type == VKD3D_SHADER_DESCRIPTOR_TYPE_UAV) vkd3d_shader_scan_add_uav_range(context, semantic->reg.reg.idx[0].offset, context->scan_info->descriptor_count - 1); @@ -381,7 +379,7 @@ static void vkd3d_shader_scan_resource_declaration_raw(struct vkd3d_shader_scan_ else type = VKD3D_SHADER_DESCRIPTOR_TYPE_SRV; vkd3d_shader_scan_add_descriptor(context, type, resource->register_space, - resource->register_index, VKD3D_SHADER_RESOURCE_BUFFER, VKD3D_SHADER_RESOURCE_DATA_UINT); + resource->register_index, VKD3D_SHADER_RESOURCE_BUFFER, VKD3D_SHADER_RESOURCE_DATA_UINT, 0); if (type == VKD3D_SHADER_DESCRIPTOR_TYPE_UAV) vkd3d_shader_scan_add_uav_range(context, resource->dst.reg.idx[0].offset, context->scan_info->descriptor_count - 1); @@ -398,7 +396,7 @@ static void vkd3d_shader_scan_resource_declaration_structured(struct vkd3d_shade else type = VKD3D_SHADER_DESCRIPTOR_TYPE_SRV; vkd3d_shader_scan_add_descriptor(context, type, resource->register_space, - resource->register_index, VKD3D_SHADER_RESOURCE_BUFFER, VKD3D_SHADER_RESOURCE_DATA_UINT); + resource->register_index, VKD3D_SHADER_RESOURCE_BUFFER, VKD3D_SHADER_RESOURCE_DATA_UINT, 0); if (type == VKD3D_SHADER_DESCRIPTOR_TYPE_UAV) vkd3d_shader_scan_add_uav_range(context, resource->reg.reg.idx[0].offset, context->scan_info->descriptor_count - 1);