mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader: Also match the register space when looking up bindings.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
e53496f6fd
commit
87364057da
@ -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;
|
||||
|
||||
|
@ -2234,6 +2234,7 @@ 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_constant_buffer *cb)
|
||||
{
|
||||
unsigned int register_space = cb->register_space;
|
||||
unsigned int reg_idx = cb->register_index;
|
||||
unsigned int i;
|
||||
|
||||
@ -2244,7 +2245,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_space == register_space && current->pc.register_index == reg_idx)
|
||||
return current;
|
||||
}
|
||||
|
||||
@ -2280,7 +2281,7 @@ 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,
|
||||
struct vkd3d_dxbc_compiler *compiler, const struct vkd3d_shader_register *reg, unsigned int register_space,
|
||||
unsigned int reg_idx, enum vkd3d_shader_resource_type resource_type, bool is_uav_counter)
|
||||
{
|
||||
const struct vkd3d_shader_interface_info *shader_interface = &compiler->shader_interface;
|
||||
@ -2317,11 +2318,11 @@ 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_space == register_space && current->register_index == reg_idx)
|
||||
return current->binding;
|
||||
}
|
||||
if (shader_interface->uav_counter_count)
|
||||
FIXME("Could not find descriptor binding for UAV counter %u.\n", reg_idx);
|
||||
FIXME("Could not find descriptor binding for UAV counter %u, space %u.\n", reg_idx, register_space);
|
||||
}
|
||||
else if (descriptor_type != VKD3D_SHADER_DESCRIPTOR_TYPE_UNKNOWN)
|
||||
{
|
||||
@ -2335,12 +2336,13 @@ 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_space == register_space
|
||||
&& current->register_index == reg_idx)
|
||||
return current->binding;
|
||||
}
|
||||
if (shader_interface->binding_count)
|
||||
FIXME("Could not find binding for type %#x, register %u, shader type %#x.\n",
|
||||
descriptor_type, reg_idx, compiler->shader_type);
|
||||
FIXME("Could not find binding for type %#x, space %u, register %u, shader type %#x.\n",
|
||||
descriptor_type, register_space, reg_idx, compiler->shader_type);
|
||||
}
|
||||
|
||||
binding.set = 0;
|
||||
@ -2358,12 +2360,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 register_space,
|
||||
unsigned int register_index, 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,
|
||||
binding = vkd3d_dxbc_compiler_get_descriptor_binding(compiler, reg, register_space,
|
||||
register_index, resource_type, is_uav_counter);
|
||||
vkd3d_dxbc_compiler_emit_descriptor_binding(compiler, variable_id, &binding);
|
||||
}
|
||||
@ -4984,9 +4986,6 @@ 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, cb)))
|
||||
{
|
||||
/* Push constant buffers are handled in
|
||||
@ -5018,7 +5017,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, cb->register_index, VKD3D_SHADER_RESOURCE_BUFFER, false);
|
||||
var_id, reg, cb->register_space, cb->register_index, VKD3D_SHADER_RESOURCE_BUFFER, false);
|
||||
|
||||
vkd3d_dxbc_compiler_emit_register_debug_name(builder, var_id, reg);
|
||||
|
||||
@ -5064,15 +5063,13 @@ static void vkd3d_dxbc_compiler_emit_dcl_immediate_constant_buffer(struct vkd3d_
|
||||
static void vkd3d_dxbc_compiler_emit_dcl_sampler(struct vkd3d_dxbc_compiler *compiler,
|
||||
const struct vkd3d_shader_instruction *instruction)
|
||||
{
|
||||
const struct vkd3d_shader_register *reg = &instruction->declaration.sampler.src.reg;
|
||||
const struct vkd3d_shader_sampler *sampler = &instruction->declaration.sampler;
|
||||
const SpvStorageClass storage_class = SpvStorageClassUniformConstant;
|
||||
struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
|
||||
const struct vkd3d_shader_register *reg = &sampler->src.reg;
|
||||
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;
|
||||
|
||||
@ -5082,7 +5079,7 @@ 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,
|
||||
instruction->declaration.sampler.register_index, VKD3D_SHADER_RESOURCE_NONE, false);
|
||||
sampler->register_space, sampler->register_index, VKD3D_SHADER_RESOURCE_NONE, false);
|
||||
|
||||
vkd3d_dxbc_compiler_emit_register_debug_name(builder, var_id, reg);
|
||||
|
||||
@ -5213,7 +5210,7 @@ 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, unsigned int register_index,
|
||||
const struct vkd3d_shader_register *reg, unsigned int register_space, unsigned int register_index,
|
||||
enum vkd3d_shader_resource_type resource_type, enum vkd3d_data_type resource_data_type,
|
||||
unsigned int structure_stride, bool raw)
|
||||
{
|
||||
@ -5249,7 +5246,8 @@ 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, register_index, resource_type, false);
|
||||
vkd3d_dxbc_compiler_emit_descriptor_binding_for_reg(compiler, var_id, reg,
|
||||
register_space, register_index, resource_type, false);
|
||||
|
||||
vkd3d_dxbc_compiler_emit_register_debug_name(builder, var_id, reg);
|
||||
|
||||
@ -5272,7 +5270,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, register_index, resource_type, true);
|
||||
counter_var_id, reg, register_space, register_index, resource_type, true);
|
||||
|
||||
vkd3d_spirv_build_op_name(builder, counter_var_id, "u%u_counter", reg->idx[0].offset);
|
||||
}
|
||||
@ -5293,12 +5291,10 @@ 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,
|
||||
vkd3d_dxbc_compiler_emit_resource_declaration(compiler, &semantic->reg.reg, semantic->register_space,
|
||||
semantic->register_index, semantic->resource_type, semantic->resource_data_type, 0, false);
|
||||
}
|
||||
|
||||
@ -5307,12 +5303,10 @@ 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,
|
||||
vkd3d_dxbc_compiler_emit_resource_declaration(compiler, &resource->dst.reg, resource->register_space,
|
||||
resource->register_index, VKD3D_SHADER_RESOURCE_BUFFER, VKD3D_DATA_UINT, 0, true);
|
||||
}
|
||||
|
||||
@ -5323,12 +5317,10 @@ 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,
|
||||
vkd3d_dxbc_compiler_emit_resource_declaration(compiler, reg, resource->register_space,
|
||||
resource->register_index, VKD3D_SHADER_RESOURCE_BUFFER, VKD3D_DATA_UINT, stride / 4, false);
|
||||
}
|
||||
|
||||
|
@ -510,6 +510,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 = 0;
|
||||
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);
|
||||
@ -541,6 +542,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 = 0;
|
||||
mapping->register_index = register_idx;
|
||||
mapping->shader_visibility = shader_visibility;
|
||||
mapping->flags = buffer_descriptor ? VKD3D_SHADER_BINDING_FLAG_BUFFER : VKD3D_SHADER_BINDING_FLAG_IMAGE;
|
||||
@ -1451,6 +1453,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;
|
||||
@ -2910,6 +2913,7 @@ HRESULT vkd3d_uav_clear_state_init(struct vkd3d_uav_clear_state *state, struct d
|
||||
set_binding.pImmutableSamplers = NULL;
|
||||
|
||||
binding.type = VKD3D_SHADER_DESCRIPTOR_TYPE_UAV;
|
||||
binding.register_space = 0;
|
||||
binding.register_index = 0;
|
||||
binding.shader_visibility = VKD3D_SHADER_VISIBILITY_COMPUTE;
|
||||
binding.binding.set = 0;
|
||||
@ -2919,6 +2923,7 @@ HRESULT vkd3d_uav_clear_state_init(struct vkd3d_uav_clear_state *state, struct d
|
||||
push_constant_range.offset = 0;
|
||||
push_constant_range.size = sizeof(struct vkd3d_uav_clear_args);
|
||||
|
||||
push_constant.register_space = 0;
|
||||
push_constant.register_index = 0;
|
||||
push_constant.shader_visibility = VKD3D_SHADER_VISIBILITY_COMPUTE;
|
||||
push_constant.offset = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user