[PATCH] vkd3d: Fix handling of SM 5.1 register spaces.
Hans-Kristian Arntzen
post at arntzen-software.no
Fri Nov 1 08:36:37 CDT 2019
The resource index is not found in idx[0], but idx[1] when using SM 5.1,
and register space information depends on resource type.
Pass down space/index information directly to resource declaration
functions instead rather than relying on this information being in
reg.idx[0].
Signed-off-by: Hans-Kristian Arntzen <post at arntzen-software.no>
---
include/vkd3d_shader.h | 3 ++
libs/vkd3d-shader/dxbc.c | 31 ++++++++++++
libs/vkd3d-shader/spirv.c | 63 ++++++++++++++----------
libs/vkd3d-shader/vkd3d_shader_private.h | 5 ++
libs/vkd3d/state.c | 24 +++++----
libs/vkd3d/vkd3d_private.h | 1 +
6 files changed, 87 insertions(+), 40 deletions(-)
diff --git a/include/vkd3d_shader.h b/include/vkd3d_shader.h
index 6b4d3f5..8f43d66 100644
--- a/include/vkd3d_shader.h
+++ b/include/vkd3d_shader.h
@@ -138,6 +138,7 @@ struct vkd3d_shader_parameter
struct vkd3d_shader_resource_binding
{
enum vkd3d_shader_descriptor_type type;
+ unsigned int register_space;
unsigned int register_index;
enum vkd3d_shader_visibility shader_visibility;
unsigned int flags; /* vkd3d_shader_binding_flags */
@@ -159,6 +160,7 @@ struct vkd3d_shader_combined_resource_sampler
struct vkd3d_shader_uav_counter_binding
{
+ unsigned int register_space;
unsigned int register_index; /* u# */
enum vkd3d_shader_visibility shader_visibility;
@@ -168,6 +170,7 @@ struct vkd3d_shader_uav_counter_binding
struct vkd3d_shader_push_constant_buffer
{
+ unsigned int register_space;
unsigned int register_index;
enum vkd3d_shader_visibility shader_visibility;
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c
index 98c51e4..f9f6614 100644
--- a/libs/vkd3d-shader/dxbc.c
+++ b/libs/vkd3d-shader/dxbc.c
@@ -624,6 +624,10 @@ static void shader_sm4_read_dcl_resource(struct vkd3d_shader_instruction *ins,
ins->flags = (opcode_token & VKD3D_SM5_UAV_FLAGS_MASK) >> VKD3D_SM5_UAV_FLAGS_SHIFT;
shader_sm4_read_register_space(priv, &tokens, end, &ins->declaration.semantic.register_space);
+ if (shader_is_sm_5_1(priv))
+ ins->declaration.semantic.register_index = ins->declaration.semantic.reg.reg.idx[1].offset;
+ else
+ ins->declaration.semantic.register_index = ins->declaration.semantic.reg.reg.idx[0].offset;
}
static void shader_sm4_read_dcl_constant_buffer(struct vkd3d_shader_instruction *ins,
@@ -647,9 +651,14 @@ static void shader_sm4_read_dcl_constant_buffer(struct vkd3d_shader_instruction
return;
}
+ /* Apparently both idx[1] and idx[2] contain the range for indexed resources,
+ * but only support plain CBV here and ignore idx[2]. */
+ ins->declaration.cb.register_index = ins->declaration.cb.src.reg.idx[1].offset;
ins->declaration.cb.size = *tokens++;
shader_sm4_read_register_space(priv, &tokens, end, &ins->declaration.cb.register_space);
}
+ else
+ ins->declaration.cb.register_index = ins->declaration.cb.src.reg.idx[0].offset;
}
static void shader_sm4_read_dcl_sampler(struct vkd3d_shader_instruction *ins,
@@ -663,6 +672,10 @@ static void shader_sm4_read_dcl_sampler(struct vkd3d_shader_instruction *ins,
FIXME("Unhandled sampler mode %#x.\n", ins->flags);
shader_sm4_read_src_param(priv, &tokens, end, VKD3D_DATA_SAMPLER, &ins->declaration.sampler.src);
shader_sm4_read_register_space(priv, &tokens, end, &ins->declaration.sampler.register_space);
+ if (shader_is_sm_5_1(priv))
+ ins->declaration.sampler.register_index = ins->declaration.sampler.src.reg.idx[1].offset;
+ else
+ ins->declaration.sampler.register_index = ins->declaration.sampler.src.reg.idx[0].offset;
}
static void shader_sm4_read_dcl_index_range(struct vkd3d_shader_instruction *ins,
@@ -863,6 +876,10 @@ static void shader_sm5_read_dcl_uav_raw(struct vkd3d_shader_instruction *ins,
shader_sm4_read_dst_param(priv, &tokens, end, VKD3D_DATA_UAV, &ins->declaration.raw_resource.dst);
ins->flags = (opcode_token & VKD3D_SM5_UAV_FLAGS_MASK) >> VKD3D_SM5_UAV_FLAGS_SHIFT;
shader_sm4_read_register_space(priv, &tokens, end, &ins->declaration.raw_resource.register_space);
+ if (shader_is_sm_5_1(priv))
+ ins->declaration.raw_resource.register_index = ins->declaration.raw_resource.dst.reg.idx[1].offset;
+ else
+ ins->declaration.raw_resource.register_index = ins->declaration.raw_resource.dst.reg.idx[0].offset;
}
static void shader_sm5_read_dcl_uav_structured(struct vkd3d_shader_instruction *ins,
@@ -874,9 +891,14 @@ static void shader_sm5_read_dcl_uav_structured(struct vkd3d_shader_instruction *
shader_sm4_read_dst_param(priv, &tokens, end, VKD3D_DATA_UAV, &ins->declaration.structured_resource.reg);
ins->flags = (opcode_token & VKD3D_SM5_UAV_FLAGS_MASK) >> VKD3D_SM5_UAV_FLAGS_SHIFT;
ins->declaration.structured_resource.byte_stride = *tokens;
+ tokens++;
if (ins->declaration.structured_resource.byte_stride % 4)
FIXME("Byte stride %u is not multiple of 4.\n", ins->declaration.structured_resource.byte_stride);
shader_sm4_read_register_space(priv, &tokens, end, &ins->declaration.structured_resource.register_space);
+ if (shader_is_sm_5_1(priv))
+ ins->declaration.structured_resource.register_index = ins->declaration.structured_resource.reg.reg.idx[1].offset;
+ else
+ ins->declaration.structured_resource.register_index = ins->declaration.structured_resource.reg.reg.idx[0].offset;
}
static void shader_sm5_read_dcl_tgsm_raw(struct vkd3d_shader_instruction *ins,
@@ -909,9 +931,14 @@ static void shader_sm5_read_dcl_resource_structured(struct vkd3d_shader_instruct
shader_sm4_read_dst_param(priv, &tokens, end, VKD3D_DATA_RESOURCE, &ins->declaration.structured_resource.reg);
ins->declaration.structured_resource.byte_stride = *tokens;
+ tokens++;
if (ins->declaration.structured_resource.byte_stride % 4)
FIXME("Byte stride %u is not multiple of 4.\n", ins->declaration.structured_resource.byte_stride);
shader_sm4_read_register_space(priv, &tokens, end, &ins->declaration.structured_resource.register_space);
+ if (shader_is_sm_5_1(priv))
+ ins->declaration.structured_resource.register_index = ins->declaration.structured_resource.reg.reg.idx[1].offset;
+ else
+ ins->declaration.structured_resource.register_index = ins->declaration.structured_resource.reg.reg.idx[0].offset;
}
static void shader_sm5_read_dcl_resource_raw(struct vkd3d_shader_instruction *ins,
@@ -922,6 +949,10 @@ static void shader_sm5_read_dcl_resource_raw(struct vkd3d_shader_instruction *in
shader_sm4_read_dst_param(priv, &tokens, end, VKD3D_DATA_RESOURCE, &ins->declaration.dst);
shader_sm4_read_register_space(priv, &tokens, end, &ins->declaration.raw_resource.register_space);
+ if (shader_is_sm_5_1(priv))
+ ins->declaration.raw_resource.register_index = ins->declaration.dst.reg.idx[1].offset;
+ else
+ ins->declaration.raw_resource.register_index = ins->declaration.dst.reg.idx[0].offset;
}
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 a949e4a..aaae1b6 100644
--- a/libs/vkd3d-shader/spirv.c
+++ b/libs/vkd3d-shader/spirv.c
@@ -2052,6 +2052,7 @@ struct vkd3d_hull_shader_variables
struct vkd3d_dxbc_compiler
{
+ struct vkd3d_shader_version shader_version;
struct vkd3d_spirv_builder spirv_builder;
uint32_t options;
@@ -2107,6 +2108,11 @@ struct vkd3d_dxbc_compiler
size_t spec_constants_size;
};
+static bool shader_is_sm_5_1(const struct vkd3d_dxbc_compiler *compiler)
+{
+ return (compiler->shader_version.major * 100 + compiler->shader_version.minor) >= 501;
+}
+
static bool is_control_point_phase(const struct vkd3d_shader_phase *phase)
{
return phase && phase->type == VKD3DSIH_HS_CONTROL_POINT_PHASE;
@@ -2131,6 +2137,8 @@ struct vkd3d_dxbc_compiler *vkd3d_dxbc_compiler_create(const struct vkd3d_shader
memset(compiler, 0, sizeof(*compiler));
+ compiler->shader_version = *shader_version;
+
max_element_count = max(output_signature->element_count, patch_constant_signature->element_count);
if (!(compiler->output_info = vkd3d_calloc(max_element_count, sizeof(*compiler->output_info))))
{
@@ -2227,9 +2235,10 @@ static bool vkd3d_dxbc_compiler_check_shader_visibility(const struct vkd3d_dxbc_
}
static struct vkd3d_push_constant_buffer_binding *vkd3d_dxbc_compiler_find_push_constant_buffer(
- const struct vkd3d_dxbc_compiler *compiler, const struct vkd3d_shader_register *reg)
+ const struct vkd3d_dxbc_compiler *compiler, const struct vkd3d_shader_constant_buffer *cb)
{
- unsigned int reg_idx = reg->idx[0].offset;
+ unsigned int reg_idx = cb->register_index;
+ unsigned int reg_space = cb->register_space;
unsigned int i;
for (i = 0; i < compiler->shader_interface.push_constant_buffer_count; ++i)
@@ -2239,7 +2248,7 @@ static struct vkd3d_push_constant_buffer_binding *vkd3d_dxbc_compiler_find_push_
if (!vkd3d_dxbc_compiler_check_shader_visibility(compiler, current->pc.shader_visibility))
continue;
- if (current->pc.register_index == reg_idx)
+ if (current->pc.register_index == reg_idx && current->pc.register_space == reg_space)
return current;
}
@@ -2276,13 +2285,13 @@ static bool vkd3d_dxbc_compiler_has_combined_sampler(const struct vkd3d_dxbc_com
static struct vkd3d_shader_descriptor_binding vkd3d_dxbc_compiler_get_descriptor_binding(
struct vkd3d_dxbc_compiler *compiler, const struct vkd3d_shader_register *reg,
+ unsigned int reg_idx, unsigned int reg_space,
enum vkd3d_shader_resource_type resource_type, bool is_uav_counter)
{
const struct vkd3d_shader_interface_info *shader_interface = &compiler->shader_interface;
enum vkd3d_shader_descriptor_type descriptor_type;
enum vkd3d_shader_binding_flag resource_type_flag;
struct vkd3d_shader_descriptor_binding binding;
- unsigned int reg_idx = reg->idx[0].offset;
unsigned int i;
descriptor_type = VKD3D_SHADER_DESCRIPTOR_TYPE_UNKNOWN;
@@ -2313,7 +2322,7 @@ static struct vkd3d_shader_descriptor_binding vkd3d_dxbc_compiler_get_descriptor
if (current->offset)
FIXME("Atomic counter offsets are not supported yet.\n");
- if (current->register_index == reg_idx)
+ if (current->register_index == reg_idx && current->register_space == reg_space)
return current->binding;
}
if (shader_interface->uav_counter_count)
@@ -2331,7 +2340,7 @@ static struct vkd3d_shader_descriptor_binding vkd3d_dxbc_compiler_get_descriptor
if (!vkd3d_dxbc_compiler_check_shader_visibility(compiler, current->shader_visibility))
continue;
- if (current->type == descriptor_type && current->register_index == reg_idx)
+ if (current->type == descriptor_type && current->register_index == reg_idx && current->register_space == reg_space)
return current->binding;
}
if (shader_interface->binding_count)
@@ -2354,12 +2363,12 @@ static void vkd3d_dxbc_compiler_emit_descriptor_binding(struct vkd3d_dxbc_compil
}
static void vkd3d_dxbc_compiler_emit_descriptor_binding_for_reg(struct vkd3d_dxbc_compiler *compiler,
- uint32_t variable_id, const struct vkd3d_shader_register *reg,
+ uint32_t variable_id, const struct vkd3d_shader_register *reg, unsigned int reg_idx, unsigned int reg_space,
enum vkd3d_shader_resource_type resource_type, bool is_uav_counter)
{
struct vkd3d_shader_descriptor_binding binding;
- binding = vkd3d_dxbc_compiler_get_descriptor_binding(compiler, reg, resource_type, is_uav_counter);
+ binding = vkd3d_dxbc_compiler_get_descriptor_binding(compiler, reg, reg_idx, reg_space, resource_type, is_uav_counter);
vkd3d_dxbc_compiler_emit_descriptor_binding(compiler, variable_id, &binding);
}
@@ -2825,7 +2834,8 @@ static void vkd3d_dxbc_compiler_emit_dereference_register(struct vkd3d_dxbc_comp
{
assert(!reg->idx[0].rel_addr);
indexes[index_count++] = vkd3d_dxbc_compiler_get_constant_uint(compiler, register_info->member_idx);
- indexes[index_count++] = vkd3d_dxbc_compiler_emit_register_addressing(compiler, ®->idx[1]);
+ indexes[index_count++] = vkd3d_dxbc_compiler_emit_register_addressing(compiler,
+ ®->idx[shader_is_sm_5_1(compiler) ? 2 : 1]);
}
else if (reg->type == VKD3DSPR_IMMCONSTBUFFER)
{
@@ -2835,6 +2845,11 @@ static void vkd3d_dxbc_compiler_emit_dereference_register(struct vkd3d_dxbc_comp
{
indexes[index_count++] = vkd3d_dxbc_compiler_emit_register_addressing(compiler, ®->idx[1]);
}
+ else if (reg->type == VKD3DSPR_SAMPLER)
+ {
+ /* SM 5.1 will have an index here referring to something which we throw away. */
+ index_count = 0;
+ }
else if (register_info->is_aggregate)
{
struct vkd3d_shader_register_index reg_idx = reg->idx[0];
@@ -4957,10 +4972,7 @@ static void vkd3d_dxbc_compiler_emit_dcl_constant_buffer(struct vkd3d_dxbc_compi
assert(!(instruction->flags & ~VKD3DSI_INDEXED_DYNAMIC));
- if (cb->register_space)
- FIXME("Unhandled register space %u.\n", cb->register_space);
-
- if ((push_cb = vkd3d_dxbc_compiler_find_push_constant_buffer(compiler, reg)))
+ if ((push_cb = vkd3d_dxbc_compiler_find_push_constant_buffer(compiler, cb)))
{
/* Push constant buffers are handled in
* vkd3d_dxbc_compiler_emit_push_constant_buffers().
@@ -4990,7 +5002,7 @@ static void vkd3d_dxbc_compiler_emit_dcl_constant_buffer(struct vkd3d_dxbc_compi
pointer_type_id, storage_class, 0);
vkd3d_dxbc_compiler_emit_descriptor_binding_for_reg(compiler,
- var_id, reg, VKD3D_SHADER_RESOURCE_BUFFER, false);
+ var_id, reg, cb->register_index, cb->register_space, VKD3D_SHADER_RESOURCE_BUFFER, false);
vkd3d_dxbc_compiler_emit_register_debug_name(builder, var_id, reg);
@@ -5042,9 +5054,6 @@ static void vkd3d_dxbc_compiler_emit_dcl_sampler(struct vkd3d_dxbc_compiler *com
uint32_t type_id, ptr_type_id, var_id;
struct vkd3d_symbol reg_symbol;
- if (instruction->declaration.sampler.register_space)
- FIXME("Unhandled register space %u.\n", instruction->declaration.sampler.register_space);
-
if (vkd3d_dxbc_compiler_has_combined_sampler(compiler, NULL, reg))
return;
@@ -5054,7 +5063,9 @@ static void vkd3d_dxbc_compiler_emit_dcl_sampler(struct vkd3d_dxbc_compiler *com
ptr_type_id, storage_class, 0);
vkd3d_dxbc_compiler_emit_descriptor_binding_for_reg(compiler,
- var_id, reg, VKD3D_SHADER_RESOURCE_NONE, false);
+ var_id, reg,
+ instruction->declaration.sampler.register_index, instruction->declaration.sampler.register_space,
+ VKD3D_SHADER_RESOURCE_NONE, false);
vkd3d_dxbc_compiler_emit_register_debug_name(builder, var_id, reg);
@@ -5185,7 +5196,8 @@ static void vkd3d_dxbc_compiler_emit_combined_sampler_declarations(struct vkd3d_
}
static void vkd3d_dxbc_compiler_emit_resource_declaration(struct vkd3d_dxbc_compiler *compiler,
- const struct vkd3d_shader_register *reg, enum vkd3d_shader_resource_type resource_type,
+ const struct vkd3d_shader_register *reg, unsigned int reg_idx, unsigned reg_space,
+ enum vkd3d_shader_resource_type resource_type,
enum vkd3d_data_type resource_data_type, unsigned int structure_stride, bool raw)
{
uint32_t counter_type_id, type_id, ptr_type_id, var_id, counter_var_id = 0;
@@ -5220,7 +5232,7 @@ static void vkd3d_dxbc_compiler_emit_resource_declaration(struct vkd3d_dxbc_comp
var_id = vkd3d_spirv_build_op_variable(builder, &builder->global_stream,
ptr_type_id, storage_class, 0);
- vkd3d_dxbc_compiler_emit_descriptor_binding_for_reg(compiler, var_id, reg, resource_type, false);
+ vkd3d_dxbc_compiler_emit_descriptor_binding_for_reg(compiler, var_id, reg, reg_idx, reg_space, resource_type, false);
vkd3d_dxbc_compiler_emit_register_debug_name(builder, var_id, reg);
@@ -5243,7 +5255,7 @@ static void vkd3d_dxbc_compiler_emit_resource_declaration(struct vkd3d_dxbc_comp
ptr_type_id, storage_class, 0);
vkd3d_dxbc_compiler_emit_descriptor_binding_for_reg(compiler,
- counter_var_id, reg, resource_type, true);
+ counter_var_id, reg, reg_idx, reg_space, resource_type, true);
vkd3d_spirv_build_op_name(builder, counter_var_id, "u%u_counter", reg->idx[0].offset);
}
@@ -5264,12 +5276,11 @@ static void vkd3d_dxbc_compiler_emit_dcl_resource(struct vkd3d_dxbc_compiler *co
{
const struct vkd3d_shader_semantic *semantic = &instruction->declaration.semantic;
- if (semantic->register_space)
- FIXME("Unhandled register space %u.\n", semantic->register_space);
if (instruction->flags)
FIXME("Unhandled UAV flags %#x.\n", instruction->flags);
vkd3d_dxbc_compiler_emit_resource_declaration(compiler, &semantic->reg.reg,
+ semantic->register_index, semantic->register_space,
semantic->resource_type, semantic->resource_data_type, 0, false);
}
@@ -5278,12 +5289,11 @@ static void vkd3d_dxbc_compiler_emit_dcl_resource_raw(struct vkd3d_dxbc_compiler
{
const struct vkd3d_shader_raw_resource *resource = &instruction->declaration.raw_resource;
- if (resource->register_space)
- FIXME("Unhandled register space %u.\n", resource->register_space);
if (instruction->flags)
FIXME("Unhandled UAV flags %#x.\n", instruction->flags);
vkd3d_dxbc_compiler_emit_resource_declaration(compiler, &resource->dst.reg,
+ resource->register_index, resource->register_space,
VKD3D_SHADER_RESOURCE_BUFFER, VKD3D_DATA_UINT, 0, true);
}
@@ -5294,12 +5304,11 @@ static void vkd3d_dxbc_compiler_emit_dcl_resource_structured(struct vkd3d_dxbc_c
const struct vkd3d_shader_register *reg = &resource->reg.reg;
unsigned int stride = resource->byte_stride;
- if (resource->register_space)
- FIXME("Unhandled register space %u.\n", resource->register_space);
if (instruction->flags)
FIXME("Unhandled UAV flags %#x.\n", instruction->flags);
vkd3d_dxbc_compiler_emit_resource_declaration(compiler, reg,
+ resource->register_index, resource->register_space,
VKD3D_SHADER_RESOURCE_BUFFER, VKD3D_DATA_UINT, stride / 4, false);
}
diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h
index 940cb76..1c052a0 100644
--- a/libs/vkd3d-shader/vkd3d_shader_private.h
+++ b/libs/vkd3d-shader/vkd3d_shader_private.h
@@ -615,6 +615,7 @@ struct vkd3d_shader_semantic
enum vkd3d_data_type resource_data_type;
struct vkd3d_shader_dst_param reg;
unsigned int register_space;
+ unsigned int register_index;
};
enum vkd3d_shader_input_sysval_semantic
@@ -662,6 +663,7 @@ struct vkd3d_shader_register_semantic
struct vkd3d_shader_sampler
{
struct vkd3d_shader_src_param src;
+ unsigned int register_index;
unsigned int register_space;
};
@@ -669,6 +671,7 @@ struct vkd3d_shader_constant_buffer
{
struct vkd3d_shader_src_param src;
unsigned int size;
+ unsigned int register_index;
unsigned int register_space;
};
@@ -676,12 +679,14 @@ struct vkd3d_shader_structured_resource
{
struct vkd3d_shader_dst_param reg;
unsigned int byte_stride;
+ unsigned int register_index;
unsigned int register_space;
};
struct vkd3d_shader_raw_resource
{
struct vkd3d_shader_dst_param dst;
+ unsigned int register_index;
unsigned int register_space;
};
diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c
index 50cff1f..ed20de7 100644
--- a/libs/vkd3d/state.c
+++ b/libs/vkd3d/state.c
@@ -308,12 +308,6 @@ static bool vk_binding_from_d3d12_descriptor_range(struct VkDescriptorSetLayoutB
= vk_descriptor_type_from_d3d12_range_type(descriptor_range->RangeType, is_buffer);
binding_desc->descriptorCount = 1;
- if (descriptor_range->RegisterSpace)
- {
- FIXME("Unhandled register space %u.\n", descriptor_range->RegisterSpace);
- return false;
- }
-
binding_desc->stageFlags = stage_flags_from_visibility(shader_visibility);
binding_desc->pImmutableSamplers = NULL;
@@ -509,6 +503,7 @@ static HRESULT d3d12_root_signature_init_push_constants(struct d3d12_root_signat
? push_constants[0].stageFlags : stage_flags_from_visibility(p->ShaderVisibility);
root_constant->offset = offset;
+ root_signature->root_constants[j].register_space = p->u.Constants.RegisterSpace;
root_signature->root_constants[j].register_index = p->u.Constants.ShaderRegister;
root_signature->root_constants[j].shader_visibility
= vkd3d_shader_visibility_from_d3d12(p->ShaderVisibility);
@@ -532,7 +527,7 @@ struct vkd3d_descriptor_set_context
};
static void d3d12_root_signature_append_vk_binding(struct d3d12_root_signature *root_signature,
- enum vkd3d_shader_descriptor_type descriptor_type, unsigned int register_idx,
+ enum vkd3d_shader_descriptor_type descriptor_type, unsigned int register_space, unsigned int register_idx,
bool buffer_descriptor, enum vkd3d_shader_visibility shader_visibility,
struct vkd3d_descriptor_set_context *context)
{
@@ -540,6 +535,7 @@ static void d3d12_root_signature_append_vk_binding(struct d3d12_root_signature *
= &root_signature->descriptor_mapping[context->descriptor_index++];
mapping->type = descriptor_type;
+ mapping->register_space = register_space;
mapping->register_index = register_idx;
mapping->shader_visibility = shader_visibility;
mapping->flags = buffer_descriptor ? VKD3D_SHADER_BINDING_FLAG_BUFFER : VKD3D_SHADER_BINDING_FLAG_IMAGE;
@@ -548,7 +544,7 @@ static void d3d12_root_signature_append_vk_binding(struct d3d12_root_signature *
}
static uint32_t d3d12_root_signature_assign_vk_bindings(struct d3d12_root_signature *root_signature,
- enum vkd3d_shader_descriptor_type descriptor_type, unsigned int base_register_idx,
+ enum vkd3d_shader_descriptor_type descriptor_type, unsigned int register_space, unsigned int base_register_idx,
unsigned int binding_count, bool is_buffer_descriptor, bool duplicate_descriptors,
enum vkd3d_shader_visibility shader_visibility, struct vkd3d_descriptor_set_context *context)
{
@@ -565,10 +561,10 @@ static uint32_t d3d12_root_signature_assign_vk_bindings(struct d3d12_root_signat
{
if (duplicate_descriptors)
d3d12_root_signature_append_vk_binding(root_signature, descriptor_type,
- base_register_idx + i, true, shader_visibility, context);
+ register_space, base_register_idx + i, true, shader_visibility, context);
d3d12_root_signature_append_vk_binding(root_signature, descriptor_type,
- base_register_idx + i, is_buffer_descriptor, shader_visibility, context);
+ register_space, base_register_idx + i, is_buffer_descriptor, shader_visibility, context);
}
return first_binding;
}
@@ -624,7 +620,7 @@ static HRESULT d3d12_root_signature_init_root_descriptor_tables(struct d3d12_roo
vk_binding = d3d12_root_signature_assign_vk_bindings(root_signature,
vkd3d_descriptor_type_from_d3d12_range_type(range->RangeType),
- range->BaseShaderRegister, range->NumDescriptors, false, true,
+ range->RegisterSpace, range->BaseShaderRegister, range->NumDescriptors, false, true,
vkd3d_shader_visibility_from_d3d12(p->ShaderVisibility), context);
/* Unroll descriptor range. */
@@ -657,6 +653,7 @@ static HRESULT d3d12_root_signature_init_root_descriptor_tables(struct d3d12_roo
table->ranges[j].binding = vk_binding;
table->ranges[j].descriptor_magic = vkd3d_descriptor_magic_from_d3d12(range->RangeType);
table->ranges[j].base_register_idx = range->BaseShaderRegister;
+ table->ranges[j].register_space = range->RegisterSpace;
}
}
@@ -690,7 +687,7 @@ static HRESULT d3d12_root_signature_init_root_descriptors(struct d3d12_root_sign
cur_binding->binding = d3d12_root_signature_assign_vk_bindings(root_signature,
vkd3d_descriptor_type_from_d3d12_root_parameter_type(p->ParameterType),
- p->u.Descriptor.ShaderRegister, 1, true, false,
+ p->u.Descriptor.RegisterSpace, p->u.Descriptor.ShaderRegister, 1, true, false,
vkd3d_shader_visibility_from_d3d12(p->ShaderVisibility), context);
cur_binding->descriptorType = vk_descriptor_type_from_d3d12_root_parameter(p->ParameterType);
cur_binding->descriptorCount = 1;
@@ -727,7 +724,7 @@ static HRESULT d3d12_root_signature_init_static_samplers(struct d3d12_root_signa
return hr;
cur_binding->binding = d3d12_root_signature_assign_vk_bindings(root_signature,
- VKD3D_SHADER_DESCRIPTOR_TYPE_SAMPLER, s->ShaderRegister, 1, false, false,
+ VKD3D_SHADER_DESCRIPTOR_TYPE_SAMPLER, s->RegisterSpace, s->ShaderRegister, 1, false, false,
vkd3d_shader_visibility_from_d3d12(s->ShaderVisibility), context);
cur_binding->descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER;
cur_binding->descriptorCount = 1;
@@ -1441,6 +1438,7 @@ static HRESULT d3d12_pipeline_state_init_compute_uav_counters(struct d3d12_pipel
if (!(shader_info->uav_counter_mask & (1u << i)))
continue;
+ state->uav_counters[j].register_space = 0;
state->uav_counters[j].register_index = i;
state->uav_counters[j].shader_visibility = VKD3D_SHADER_VISIBILITY_COMPUTE;
state->uav_counters[j].binding.set = context.set_index;
diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h
index 58e9aa9..bd54c67 100644
--- a/libs/vkd3d/vkd3d_private.h
+++ b/libs/vkd3d/vkd3d_private.h
@@ -634,6 +634,7 @@ struct d3d12_root_descriptor_table_range
uint32_t descriptor_magic;
unsigned int base_register_idx;
+ unsigned int register_space;
};
struct d3d12_root_descriptor_table
--
2.23.0
More information about the wine-devel
mailing list