From bb41947fc64b237995c275e614ba7b24227182bd Mon Sep 17 00:00:00 2001 From: Elizabeth Figura Date: Tue, 29 Aug 2023 12:47:03 -0500 Subject: [PATCH] vkd3d-shader: Write SM5.1 register spaces. --- libs/vkd3d-shader/tpf.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/libs/vkd3d-shader/tpf.c b/libs/vkd3d-shader/tpf.c index c839f26e..c387c814 100644 --- a/libs/vkd3d-shader/tpf.c +++ b/libs/vkd3d-shader/tpf.c @@ -3185,7 +3185,7 @@ struct extern_resource bool is_user_packed; enum hlsl_regset regset; - unsigned int id, index, bind_count; + unsigned int id, space, index, bind_count; }; static int sm4_compare_extern_resources(const void *a, const void *b) @@ -3282,6 +3282,7 @@ static struct extern_resource *sm4_get_extern_resources(struct hlsl_ctx *ctx, un extern_resources[*count].regset = regset; extern_resources[*count].id = var->regs[regset].id; + extern_resources[*count].space = var->regs[regset].space; extern_resources[*count].index = var->regs[regset].index + regset_offset; extern_resources[*count].bind_count = 1; @@ -3325,6 +3326,7 @@ static struct extern_resource *sm4_get_extern_resources(struct hlsl_ctx *ctx, un extern_resources[*count].regset = r; extern_resources[*count].id = var->regs[r].id; + extern_resources[*count].space = var->regs[r].space; extern_resources[*count].index = var->regs[r].index; extern_resources[*count].bind_count = var->bind_count[r]; @@ -3362,6 +3364,7 @@ static struct extern_resource *sm4_get_extern_resources(struct hlsl_ctx *ctx, un extern_resources[*count].regset = HLSL_REGSET_NUMERIC; extern_resources[*count].id = buffer->reg.id; + extern_resources[*count].space = buffer->reg.space; extern_resources[*count].index = buffer->reg.index; extern_resources[*count].bind_count = 1; @@ -4233,7 +4236,8 @@ static void write_sm4_dcl_constant_buffer(const struct tpf_writer *tpf, const st instr.srcs[0].reg.idx_count = 3; instr.idx[0] = size; - instr.idx_count = 1; + instr.idx[1] = cbuffer->reg.space; + instr.idx_count = 2; } else { @@ -4276,6 +4280,9 @@ static void write_sm4_dcl_samplers(const struct tpf_writer *tpf, const struct ex instr.dsts[0].reg.idx[1].offset = resource->index; instr.dsts[0].reg.idx[2].offset = resource->index; /* FIXME: array end */ instr.dsts[0].reg.idx_count = 3; + + instr.idx[0] = resource->space; + instr.idx_count = 1; } else { @@ -4321,6 +4328,9 @@ static void write_sm4_dcl_textures(const struct tpf_writer *tpf, const struct ex instr.dsts[0].reg.idx[1].offset = resource->index; instr.dsts[0].reg.idx[2].offset = resource->index; /* FIXME: array end */ instr.dsts[0].reg.idx_count = 3; + + instr.idx[1] = resource->space; + instr.idx_count = 2; } else { @@ -5915,22 +5925,13 @@ static void write_sm4_shdr(struct hlsl_ctx *ctx, LIST_FOR_EACH_ENTRY(cbuffer, &ctx->buffers, struct hlsl_buffer, entry) { if (cbuffer->reg.allocated) - { - if (hlsl_version_ge(ctx, 5, 1)) - hlsl_fixme(ctx, &cbuffer->loc, "Shader model 5.1 resource definition."); - write_sm4_dcl_constant_buffer(&tpf, cbuffer); - } } for (i = 0; i < extern_resources_count; ++i) { const struct extern_resource *resource = &extern_resources[i]; - if (hlsl_version_ge(ctx, 5, 1)) - hlsl_fixme(ctx, resource->buffer ? &resource->buffer->loc : &resource->var->loc, - "Shader model 5.1 resource declaration."); - if (resource->regset == HLSL_REGSET_SAMPLERS) write_sm4_dcl_samplers(&tpf, resource); else if (resource->regset == HLSL_REGSET_TEXTURES)