Signed-off-by: Conor McCarthy [email protected] --- libs/vkd3d-shader/dxbc.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index 70ab70aa..181f7567 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -630,6 +630,16 @@ static unsigned int shader_sm4_map_resource_idx(struct vkd3d_shader_register *re return reg->idx[0].offset; }
+static void shader_sm4_read_descriptor_register_range(struct vkd3d_sm4_data *priv, const DWORD **ptr, + const DWORD *end, struct vkd3d_shader_register *reg, struct vkd3d_shader_register_range *range) +{ + shader_sm4_read_register_space(priv, ptr, end, &range->space); + range->first = reg->idx[shader_is_sm_5_1(priv) ? 1 : 0].offset; + range->last = reg->idx[shader_is_sm_5_1(priv) ? 2 : 0].offset; + if (range->last < range->first) + FIXME("Invalid register range [%u:%u].\n", range->first, range->last); +} + static void shader_sm4_read_dcl_resource(struct vkd3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct vkd3d_sm4_data *priv) @@ -654,8 +664,6 @@ 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.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++) @@ -676,7 +684,8 @@ 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.range.space); + shader_sm4_read_descriptor_register_range(priv, &tokens, end, &semantic->resource.reg.reg, + &semantic->resource.range); }
static void shader_sm4_read_dcl_constant_buffer(struct vkd3d_shader_instruction *ins,
Signed-off-by: Conor McCarthy [email protected] --- libs/vkd3d-shader/dxbc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index 181f7567..9bdee6f8 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -695,12 +695,10 @@ static void shader_sm4_read_dcl_constant_buffer(struct vkd3d_shader_instruction const DWORD *end = &tokens[token_count];
shader_sm4_read_src_param(priv, &tokens, end, VKD3D_DATA_FLOAT, &ins->declaration.cb.src); - ins->declaration.cb.range.first = shader_sm4_map_resource_idx(&ins->declaration.cb.src.reg, priv); if (opcode_token & VKD3D_SM4_INDEX_TYPE_MASK) ins->flags |= VKD3DSI_INDEXED_DYNAMIC;
ins->declaration.cb.size = ins->declaration.cb.src.reg.idx[2].offset; - ins->declaration.cb.range.space = 0;
if (shader_is_sm_5_1(priv)) { @@ -711,8 +709,9 @@ static void shader_sm4_read_dcl_constant_buffer(struct vkd3d_shader_instruction }
ins->declaration.cb.size = *tokens++; - shader_sm4_read_register_space(priv, &tokens, end, &ins->declaration.cb.range.space); } + shader_sm4_read_descriptor_register_range(priv, &tokens, end, &ins->declaration.cb.src.reg, + &ins->declaration.cb.range); }
static void shader_sm4_read_dcl_sampler(struct vkd3d_shader_instruction *ins,
Signed-off-by: Conor McCarthy [email protected] --- libs/vkd3d-shader/dxbc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index 9bdee6f8..56b5606c 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -724,8 +724,8 @@ static void shader_sm4_read_dcl_sampler(struct vkd3d_shader_instruction *ins, if (ins->flags & ~VKD3D_SM4_SAMPLER_COMPARISON) FIXME("Unhandled sampler mode %#x.\n", ins->flags); shader_sm4_read_src_param(priv, &tokens, end, VKD3D_DATA_SAMPLER, &ins->declaration.sampler.src); - ins->declaration.sampler.range.first = shader_sm4_map_resource_idx(&ins->declaration.sampler.src.reg, priv); - shader_sm4_read_register_space(priv, &tokens, end, &ins->declaration.sampler.range.space); + shader_sm4_read_descriptor_register_range(priv, &tokens, end, &ins->declaration.sampler.src.reg, + &ins->declaration.sampler.range); }
static void shader_sm4_read_dcl_index_range(struct vkd3d_shader_instruction *ins,
Signed-off-by: Conor McCarthy [email protected] --- libs/vkd3d-shader/dxbc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index 56b5606c..9ad3b597 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -925,10 +925,9 @@ 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.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.range.space); + shader_sm4_read_descriptor_register_range(priv, &tokens, end, + &resource->resource.reg.reg, &resource->resource.range); }
static void shader_sm5_read_dcl_uav_structured(struct vkd3d_shader_instruction *ins,
Signed-off-by: Conor McCarthy [email protected] --- libs/vkd3d-shader/dxbc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index 9ad3b597..a26581cc 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -938,13 +938,12 @@ 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.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.range.space); + shader_sm4_read_descriptor_register_range(priv, &tokens, end, + &resource->resource.reg.reg, &resource->resource.range); }
static void shader_sm5_read_dcl_tgsm_raw(struct vkd3d_shader_instruction *ins,
Signed-off-by: Conor McCarthy [email protected] --- libs/vkd3d-shader/dxbc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index a26581cc..ab8fff02 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -976,12 +976,11 @@ 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.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.range.space); + shader_sm4_read_descriptor_register_range(priv, &tokens, end, + &resource->resource.reg.reg, &resource->resource.range); }
static void shader_sm5_read_dcl_resource_raw(struct vkd3d_shader_instruction *ins,
Signed-off-by: Conor McCarthy [email protected] --- libs/vkd3d-shader/dxbc.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-)
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index ab8fff02..ce4cecff 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -622,14 +622,6 @@ static void shader_sm4_read_shader_data(struct vkd3d_shader_instruction *ins, ins->declaration.icb = &priv->icb; }
-static unsigned int shader_sm4_map_resource_idx(struct vkd3d_shader_register *reg, const struct vkd3d_sm4_data *priv) -{ - if (shader_is_sm_5_1(priv)) - return reg->idx[1].offset; - else - return reg->idx[0].offset; -} - static void shader_sm4_read_descriptor_register_range(struct vkd3d_sm4_data *priv, const DWORD **ptr, const DWORD *end, struct vkd3d_shader_register *reg, struct vkd3d_shader_register_range *range) { @@ -991,9 +983,8 @@ 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.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); + shader_sm4_read_descriptor_register_range(priv, &tokens, end, + &resource->resource.reg.reg, &resource->resource.range); }
static void shader_sm5_read_sync(struct vkd3d_shader_instruction *ins,
On Wed, 30 Jun 2021 at 05:05, Conor McCarthy [email protected] wrote:
+static void shader_sm4_read_descriptor_register_range(struct vkd3d_sm4_data *priv, const DWORD **ptr,
const DWORD *end, struct vkd3d_shader_register *reg, struct vkd3d_shader_register_range *range)
+{
- shader_sm4_read_register_space(priv, ptr, end, &range->space);
- range->first = reg->idx[shader_is_sm_5_1(priv) ? 1 : 0].offset;
- range->last = reg->idx[shader_is_sm_5_1(priv) ? 2 : 0].offset;
- if (range->last < range->first)
FIXME("Invalid register range [%u:%u].\n", range->first, range->last);
+}
That function is not reading the register range though; it first reads the register space, and then subsequently resolves the range from the previously read indices. I'd suggest to keep those separate.