Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- libs/vkd3d-shader/dxbc.c | 25 ++++++++++++++---------- libs/vkd3d-shader/spirv.c | 8 ++++---- libs/vkd3d-shader/trace.c | 10 +++++----- libs/vkd3d-shader/vkd3d_shader_main.c | 4 ++-- libs/vkd3d-shader/vkd3d_shader_private.h | 9 +++++++-- 5 files changed, 33 insertions(+), 23 deletions(-)
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index d2cf87e3..61acf77b 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -654,7 +654,8 @@ static void shader_sm4_read_dcl_resource(struct vkd3d_shader_instruction *ins, } reg_data_type = opcode == VKD3D_SM4_OP_DCL_RESOURCE ? VKD3D_DATA_RESOURCE : VKD3D_DATA_UAV; shader_sm4_read_dst_param(priv, &tokens, end, reg_data_type, &semantic->resource.reg); - semantic->resource.register_index = shader_sm4_map_resource_idx(&semantic->resource.reg.reg, priv); + semantic->resource.range.first = shader_sm4_map_resource_idx(&semantic->resource.reg.reg, priv); + semantic->resource.range.last = semantic->resource.range.first;
components = *tokens++; for (i = 0; i < VKD3D_VEC4_SIZE; i++) @@ -675,7 +676,7 @@ static void shader_sm4_read_dcl_resource(struct vkd3d_shader_instruction *ins, if (reg_data_type == VKD3D_DATA_UAV) ins->flags = (opcode_token & VKD3D_SM5_UAV_FLAGS_MASK) >> VKD3D_SM5_UAV_FLAGS_SHIFT;
- shader_sm4_read_register_space(priv, &tokens, end, &semantic->resource.register_space); + shader_sm4_read_register_space(priv, &tokens, end, &semantic->resource.range.space); }
static void shader_sm4_read_dcl_constant_buffer(struct vkd3d_shader_instruction *ins, @@ -916,9 +917,10 @@ static void shader_sm5_read_dcl_uav_raw(struct vkd3d_shader_instruction *ins, const DWORD *end = &tokens[token_count];
shader_sm4_read_dst_param(priv, &tokens, end, VKD3D_DATA_UAV, &resource->resource.reg); - resource->resource.register_index = shader_sm4_map_resource_idx(&resource->resource.reg.reg, priv); + resource->resource.range.first = shader_sm4_map_resource_idx(&resource->resource.reg.reg, priv); + resource->resource.range.last = resource->resource.range.first; ins->flags = (opcode_token & VKD3D_SM5_UAV_FLAGS_MASK) >> VKD3D_SM5_UAV_FLAGS_SHIFT; - shader_sm4_read_register_space(priv, &tokens, end, &resource->resource.register_space); + shader_sm4_read_register_space(priv, &tokens, end, &resource->resource.range.space); }
static void shader_sm5_read_dcl_uav_structured(struct vkd3d_shader_instruction *ins, @@ -929,12 +931,13 @@ static void shader_sm5_read_dcl_uav_structured(struct vkd3d_shader_instruction * const DWORD *end = &tokens[token_count];
shader_sm4_read_dst_param(priv, &tokens, end, VKD3D_DATA_UAV, &resource->resource.reg); - resource->resource.register_index = shader_sm4_map_resource_idx(&resource->resource.reg.reg, priv); + resource->resource.range.first = shader_sm4_map_resource_idx(&resource->resource.reg.reg, priv); + resource->resource.range.last = resource->resource.range.first; ins->flags = (opcode_token & VKD3D_SM5_UAV_FLAGS_MASK) >> VKD3D_SM5_UAV_FLAGS_SHIFT; resource->byte_stride = *tokens++; if (resource->byte_stride % 4) FIXME("Byte stride %u is not multiple of 4.\n", resource->byte_stride); - shader_sm4_read_register_space(priv, &tokens, end, &resource->resource.register_space); + shader_sm4_read_register_space(priv, &tokens, end, &resource->resource.range.space); }
static void shader_sm5_read_dcl_tgsm_raw(struct vkd3d_shader_instruction *ins, @@ -967,11 +970,12 @@ static void shader_sm5_read_dcl_resource_structured(struct vkd3d_shader_instruct const DWORD *end = &tokens[token_count];
shader_sm4_read_dst_param(priv, &tokens, end, VKD3D_DATA_RESOURCE, &resource->resource.reg); - resource->resource.register_index = shader_sm4_map_resource_idx(&resource->resource.reg.reg, priv); + resource->resource.range.first = shader_sm4_map_resource_idx(&resource->resource.reg.reg, priv); + resource->resource.range.last = resource->resource.range.first; resource->byte_stride = *tokens++; if (resource->byte_stride % 4) FIXME("Byte stride %u is not multiple of 4.\n", resource->byte_stride); - shader_sm4_read_register_space(priv, &tokens, end, &resource->resource.register_space); + shader_sm4_read_register_space(priv, &tokens, end, &resource->resource.range.space); }
static void shader_sm5_read_dcl_resource_raw(struct vkd3d_shader_instruction *ins, @@ -982,8 +986,9 @@ static void shader_sm5_read_dcl_resource_raw(struct vkd3d_shader_instruction *in const DWORD *end = &tokens[token_count];
shader_sm4_read_dst_param(priv, &tokens, end, VKD3D_DATA_RESOURCE, &resource->resource.reg); - resource->resource.register_index = shader_sm4_map_resource_idx(&resource->resource.reg.reg, priv); - shader_sm4_read_register_space(priv, &tokens, end, &resource->resource.register_space); + resource->resource.range.first = shader_sm4_map_resource_idx(&resource->resource.reg.reg, priv); + resource->resource.range.last = resource->resource.range.first; + shader_sm4_read_register_space(priv, &tokens, end, &resource->resource.range.space); }
static void shader_sm5_read_sync(struct vkd3d_shader_instruction *ins, diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 0e75b0ae..7a23d315 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -2441,8 +2441,8 @@ static bool vkd3d_dxbc_compiler_has_combined_sampler(const struct vkd3d_dxbc_com if (!vkd3d_dxbc_compiler_check_shader_visibility(compiler, combined_sampler->shader_visibility)) continue;
- if ((!resource || (combined_sampler->resource_space == resource->register_space - && combined_sampler->resource_index == resource->register_index)) + if ((!resource || (combined_sampler->resource_space == resource->range.space + && combined_sampler->resource_index == resource->range.first)) && (!sampler || (combined_sampler->sampler_space == sampler->register_space && combined_sampler->sampler_index == sampler->register_index))) return true; @@ -5554,8 +5554,8 @@ static void vkd3d_dxbc_compiler_emit_resource_declaration(struct vkd3d_dxbc_comp SpvStorageClass storage_class = SpvStorageClassUniformConstant; const struct vkd3d_shader_register *reg = &resource->reg.reg; const struct vkd3d_spirv_resource_type *resource_type_info; - unsigned int register_space = resource->register_space; - unsigned int register_index = resource->register_index; + unsigned int register_space = resource->range.space; + unsigned int register_index = resource->range.first; enum vkd3d_shader_component_type sampled_type; struct vkd3d_symbol resource_symbol; bool is_uav; diff --git a/libs/vkd3d-shader/trace.c b/libs/vkd3d-shader/trace.c index 4e355118..c35179a8 100644 --- a/libs/vkd3d-shader/trace.c +++ b/libs/vkd3d-shader/trace.c @@ -1428,7 +1428,7 @@ static void shader_dump_instruction(struct vkd3d_d3d_asm_compiler *compiler, shader_dump_ins_modifiers(compiler, &ins->declaration.semantic.resource.reg); vkd3d_string_buffer_printf(buffer, "%s ", compiler->colours.reset); shader_dump_register(compiler, &ins->declaration.semantic.resource.reg.reg); - shader_dump_register_space(compiler, ins->declaration.semantic.resource.register_space); + shader_dump_register_space(compiler, ins->declaration.semantic.resource.range.space); break;
case VKD3DSIH_DCL_CONSTANT_BUFFER: @@ -1531,14 +1531,14 @@ static void shader_dump_instruction(struct vkd3d_d3d_asm_compiler *compiler, case VKD3DSIH_DCL_RESOURCE_RAW: vkd3d_string_buffer_printf(buffer, " "); shader_dump_dst_param(compiler, &ins->declaration.raw_resource.resource.reg); - shader_dump_register_space(compiler, ins->declaration.raw_resource.resource.register_space); + shader_dump_register_space(compiler, ins->declaration.raw_resource.resource.range.space); break;
case VKD3DSIH_DCL_RESOURCE_STRUCTURED: vkd3d_string_buffer_printf(buffer, " "); shader_dump_dst_param(compiler, &ins->declaration.structured_resource.resource.reg); shader_print_uint_literal(compiler, ", ", ins->declaration.structured_resource.byte_stride, ""); - shader_dump_register_space(compiler, ins->declaration.structured_resource.resource.register_space); + shader_dump_register_space(compiler, ins->declaration.structured_resource.resource.range.space); break;
case VKD3DSIH_DCL_SAMPLER: @@ -1597,7 +1597,7 @@ static void shader_dump_instruction(struct vkd3d_d3d_asm_compiler *compiler, shader_dump_uav_flags(compiler, ins->flags); shader_addline(buffer, " "); shader_dump_dst_param(compiler, &ins->declaration.raw_resource.resource.reg); - shader_dump_register_space(compiler, ins->declaration.raw_resource.resource.register_space); + shader_dump_register_space(compiler, ins->declaration.raw_resource.resource.range.space); break;
case VKD3DSIH_DCL_UAV_STRUCTURED: @@ -1605,7 +1605,7 @@ static void shader_dump_instruction(struct vkd3d_d3d_asm_compiler *compiler, shader_addline(buffer, " "); shader_dump_dst_param(compiler, &ins->declaration.structured_resource.resource.reg); shader_print_uint_literal(compiler, ", ", ins->declaration.structured_resource.byte_stride, ""); - shader_dump_register_space(compiler, ins->declaration.structured_resource.resource.register_space); + shader_dump_register_space(compiler, ins->declaration.structured_resource.resource.range.space); break;
case VKD3DSIH_DEF: diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c index 2308b894..df811d37 100644 --- a/libs/vkd3d-shader/vkd3d_shader_main.c +++ b/libs/vkd3d-shader/vkd3d_shader_main.c @@ -666,8 +666,8 @@ static void vkd3d_shader_scan_resource_declaration(struct vkd3d_shader_scan_cont type = VKD3D_SHADER_DESCRIPTOR_TYPE_UAV; else type = VKD3D_SHADER_DESCRIPTOR_TYPE_SRV; - vkd3d_shader_scan_add_descriptor(context, type, resource->register_space, - resource->register_index, resource_type, resource_data_type, 0); + vkd3d_shader_scan_add_descriptor(context, type, resource->range.space, + resource->range.first, resource_type, resource_data_type, 0); if (type == VKD3D_SHADER_DESCRIPTOR_TYPE_UAV) vkd3d_shader_scan_add_uav_range(context, resource->reg.reg.idx[0].offset, context->scan_descriptor_info->descriptor_count - 1); diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 6d756e40..cddb3d27 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -636,11 +636,16 @@ struct vkd3d_shader_index_range unsigned int register_count; };
+struct vkd3d_shader_register_range +{ + unsigned int space; + unsigned int first, last; +}; + struct vkd3d_shader_resource { struct vkd3d_shader_dst_param reg; - unsigned int register_space; - unsigned int register_index; + struct vkd3d_shader_register_range range; };
enum vkd3d_decl_usage