[PATCH 2/3] vkd3d-shader: Normalize descriptor declaration registers to SM5.1.
Henri Verbeet
hverbeet at gmail.com
Wed Jul 7 12:31:25 CDT 2021
On Wed, 7 Jul 2021 at 03:20, Conor McCarthy <cmccarthy at codeweavers.com> wrote:
> -static void shader_dump_register(struct vkd3d_d3d_asm_compiler *compiler, const struct vkd3d_shader_register *reg)
> +static void shader_dump_register(struct vkd3d_d3d_asm_compiler *compiler, const struct vkd3d_shader_register *reg,
> + bool is_descriptor_declaration)
> {
I think technically we would only need to know whether the register is
part of a declaration; shader_dump_register() should be able to figure
out whether something is a descriptor on its own.
> @@ -1057,15 +1058,20 @@ static void shader_dump_register(struct vkd3d_d3d_asm_compiler *compiler, const
> vkd3d_string_buffer_printf(buffer, "%u%s", offset, compiler->colours.reset);
> }
>
> - /* For CBs in sm < 5.1 we move the buffer offset from idx[1] to idx[2]
> - * to normalise it with 5.1.
> - * Here we should ignore it if it's a CB in sm < 5.1. */
> - if (reg->idx[1].offset != ~0u &&
> - (reg->type != VKD3DSPR_CONSTBUFFER || shader_ver_ge(&compiler->shader_version, 5, 1)))
> - shader_print_subscript(compiler, reg->idx[1].offset, reg->idx[1].rel_addr);
> + /* For descriptors in sm < 5.1 we move the reg->idx values up one slot
> + * to normalise with 5.1. */
> + if (shader_ver_ge(&compiler->shader_version, 5, 1) && is_descriptor_declaration)
> + {
> + shader_print_subscript(compiler, reg->idx[1].offset, NULL);
> + }
> + else
> + {
> + if (reg->idx[1].offset != ~0u)
> + shader_print_subscript(compiler, reg->idx[1].offset, reg->idx[1].rel_addr);
>
> - if (reg->idx[2].offset != ~0u)
> - shader_print_subscript(compiler, reg->idx[2].offset, reg->idx[2].rel_addr);
> + if (reg->idx[2].offset != ~0u)
> + shader_print_subscript(compiler, reg->idx[2].offset, reg->idx[2].rel_addr);
> + }
> }
That doesn't do the right thing. For example:
before this patch:
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_constantBuffer cb0[1], immediateIndexed
dcl_sampler s0
dcl_resource_texturecube(float,float,float,float) t0
...
switch cb0[0].x
...
after:
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_constantBuffer cb0[0][1], immediateIndexed
dcl_sampler s0[0]
dcl_resource_texturecube(float,float,float,float) t0[0]
...
switch cb0[0][0].x
...
More information about the wine-devel
mailing list