From: Conor McCarthy cmccarthy@codeweavers.com
--- libs/vkd3d-shader/dxil.c | 2 ++ libs/vkd3d-shader/spirv.c | 10 ++++------ libs/vkd3d-shader/tpf.c | 14 ++++++++++++++ libs/vkd3d-shader/vkd3d_shader_private.h | 1 + 4 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/libs/vkd3d-shader/dxil.c b/libs/vkd3d-shader/dxil.c index ad3a92cb2..41c995a24 100644 --- a/libs/vkd3d-shader/dxil.c +++ b/libs/vkd3d-shader/dxil.c @@ -581,6 +581,7 @@ struct sm6_parser size_t descriptor_count;
unsigned int indexable_temp_count; + unsigned int icb_count;
struct sm6_value *values; size_t value_count; @@ -2433,6 +2434,7 @@ static enum vkd3d_result value_allocate_constant_array(struct sm6_value *dst, co dst->value_type = VALUE_TYPE_ICB; dst->u.icb = icb;
+ icb->register_idx = sm6->icb_count++; icb->data_type = vkd3d_data_type_from_sm6_type(elem_type); icb->element_count = type->u.array.count; icb->component_count = 1; diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 31291a285..a25322706 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -2162,6 +2162,7 @@ static void vkd3d_symbol_make_register(struct vkd3d_symbol *symbol, break;
case VKD3DSPR_IMMCONSTBUFFER: + symbol->key.reg.idx = reg->idx[0].offset; break;
default: @@ -3506,11 +3507,7 @@ static void spirv_compiler_emit_dereference_register(struct spirv_compiler *comp indexes[index_count++] = spirv_compiler_get_constant_uint(compiler, register_info->member_idx); indexes[index_count++] = spirv_compiler_emit_register_addressing(compiler, ®->idx[2]); } - else if (reg->type == VKD3DSPR_IMMCONSTBUFFER) - { - indexes[index_count++] = spirv_compiler_emit_register_addressing(compiler, ®->idx[0]); - } - else if (reg->type == VKD3DSPR_IDXTEMP) + else if (reg->type == VKD3DSPR_IMMCONSTBUFFER || reg->type == VKD3DSPR_IDXTEMP) { indexes[index_count++] = spirv_compiler_emit_register_addressing(compiler, ®->idx[1]); } @@ -5816,7 +5813,8 @@ static void spirv_compiler_emit_dcl_immediate_constant_buffer(struct spirv_compi ptr_type_id, SpvStorageClassPrivate, const_id); vkd3d_spirv_build_op_name(builder, icb_id, "icb");
- vsir_register_init(®, VKD3DSPR_IMMCONSTBUFFER, VKD3D_DATA_FLOAT, 0); + vsir_register_init(®, VKD3DSPR_IMMCONSTBUFFER, VKD3D_DATA_FLOAT, 1); + reg.idx[0].offset = icb->register_idx; vkd3d_symbol_make_register(®_symbol, ®); vkd3d_symbol_set_register_info(®_symbol, icb_id, SpvStorageClassPrivate, vkd3d_component_type_from_data_type(icb->data_type), diff --git a/libs/vkd3d-shader/tpf.c b/libs/vkd3d-shader/tpf.c index a34f9042b..d00e28db8 100644 --- a/libs/vkd3d-shader/tpf.c +++ b/libs/vkd3d-shader/tpf.c @@ -792,6 +792,7 @@ static void shader_sm4_read_shader_data(struct vkd3d_shader_instruction *ins, ui ins->handler_idx = VKD3DSIH_INVALID; return; } + icb->register_idx = 0; icb->data_type = VKD3D_DATA_FLOAT; icb->component_count = VKD3D_VEC4_SIZE; icb->element_count = icb_size / VKD3D_VEC4_SIZE; @@ -1931,6 +1932,19 @@ static bool shader_sm4_read_param(struct vkd3d_shader_sm4_parser *priv, const ui break; } } + else if (register_type == VKD3D_SM4_RT_IMMCONSTBUFFER) + { + if (param->idx_count != 1) + { + WARN("Unexpected idx count %u.\n", param->idx_count); + vkd3d_shader_parser_error(&priv->p, VKD3D_SHADER_ERROR_TPF_INVALID_REGISTER_INDEX_COUNT, + "Invalid index count %u for immediate const buffer register; expected count 1.", param->idx_count); + } + param->idx[1] = param->idx[0]; + param->idx[0].offset = 0; + param->idx[0].rel_addr = NULL; + param->idx_count = 2; + } else if (!shader_is_sm_5_1(priv) && vsir_register_is_descriptor(param)) { /* SM5.1 places a symbol identifier in idx[0] and moves diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 009b8a778..494746209 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -790,6 +790,7 @@ struct vkd3d_shader_version
struct vkd3d_shader_immediate_constant_buffer { + unsigned int register_idx; enum vkd3d_data_type data_type; /* total count is element_count * component_count */ unsigned int element_count;