vkd3d-shader/tpf: Write the input signature of domain shaders as PCSG.

This commit is contained in:
Shaun Ren 2024-10-16 17:08:59 -04:00 committed by Henri Verbeet
parent 768b19d410
commit 2b897296a1
Notes: Henri Verbeet 2024-10-21 18:41:50 +02:00
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1194
2 changed files with 21 additions and 14 deletions

View File

@ -6282,7 +6282,7 @@ void hlsl_run_const_passes(struct hlsl_ctx *ctx, struct hlsl_block *body)
}
static void generate_vsir_signature_entry(struct hlsl_ctx *ctx, struct vsir_program *program,
struct shader_signature *signature, bool output, struct hlsl_ir_var *var)
struct shader_signature *signature, bool output, bool is_patch_constant_func, struct hlsl_ir_var *var)
{
enum vkd3d_shader_sysval_semantic sysval = VKD3D_SHADER_SV_NONE;
enum vkd3d_shader_component_type component_type;
@ -6296,9 +6296,8 @@ static void generate_vsir_signature_entry(struct hlsl_ctx *ctx, struct vsir_prog
struct vkd3d_string_buffer *string;
bool has_idx, ret;
ret = sm4_sysval_semantic_from_semantic_name(&sysval, &program->shader_version,
ctx->semantic_compat_mapping, ctx->domain, var->semantic.name, var->semantic.index,
output, signature == &program->patch_constant_signature);
ret = sm4_sysval_semantic_from_semantic_name(&sysval, &program->shader_version, ctx->semantic_compat_mapping,
ctx->domain, var->semantic.name, var->semantic.index, output, is_patch_constant_func);
VKD3D_ASSERT(ret);
if (sysval == ~0u)
return;
@ -6410,21 +6409,27 @@ static void generate_vsir_signature_entry(struct hlsl_ctx *ctx, struct vsir_prog
static void generate_vsir_signature(struct hlsl_ctx *ctx,
struct vsir_program *program, struct hlsl_ir_function_decl *func)
{
bool is_domain = program->shader_version.type == VKD3D_SHADER_TYPE_DOMAIN;
bool is_patch_constant_func = func == ctx->patch_constant_func;
struct hlsl_ir_var *var;
LIST_FOR_EACH_ENTRY(var, &func->extern_vars, struct hlsl_ir_var, extern_entry)
{
if (func == ctx->patch_constant_func)
if (var->is_input_semantic)
{
generate_vsir_signature_entry(ctx, program,
&program->patch_constant_signature, var->is_output_semantic, var);
if (is_patch_constant_func)
generate_vsir_signature_entry(ctx, program, &program->patch_constant_signature, false, true, var);
else if (is_domain)
generate_vsir_signature_entry(ctx, program, &program->patch_constant_signature, false, false, var);
else
generate_vsir_signature_entry(ctx, program, &program->input_signature, false, false, var);
}
else
if (var->is_output_semantic)
{
if (var->is_input_semantic)
generate_vsir_signature_entry(ctx, program, &program->input_signature, false, var);
if (var->is_output_semantic)
generate_vsir_signature_entry(ctx, program, &program->output_signature, true, var);
if (is_patch_constant_func)
generate_vsir_signature_entry(ctx, program, &program->patch_constant_signature, true, true, var);
else
generate_vsir_signature_entry(ctx, program, &program->output_signature, true, false, var);
}
}
}

View File

@ -3215,7 +3215,8 @@ static void add_section(struct hlsl_ctx *ctx, struct dxbc_writer *dxbc,
static void tpf_write_signature(struct tpf_compiler *tpf, const struct shader_signature *signature, uint32_t tag)
{
bool output = tag == TAG_OSGN || tag == TAG_PCSG;
bool output = tag == TAG_OSGN || (tag == TAG_PCSG
&& tpf->program->shader_version.type == VKD3D_SHADER_TYPE_HULL);
struct vkd3d_bytecode_buffer buffer = {0};
unsigned int i;
@ -6717,6 +6718,7 @@ int tpf_compile(struct vsir_program *program, uint64_t config_flags,
struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context,
struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func)
{
enum vkd3d_shader_type shader_type = program->shader_version.type;
struct tpf_compiler tpf = {0};
struct sm4_stat stat = {0};
size_t i;
@ -6731,7 +6733,7 @@ int tpf_compile(struct vsir_program *program, uint64_t config_flags,
tpf_write_signature(&tpf, &program->input_signature, TAG_ISGN);
tpf_write_signature(&tpf, &program->output_signature, TAG_OSGN);
if (ctx->profile->type == VKD3D_SHADER_TYPE_HULL)
if (shader_type == VKD3D_SHADER_TYPE_HULL || shader_type == VKD3D_SHADER_TYPE_DOMAIN)
tpf_write_signature(&tpf, &program->patch_constant_signature, TAG_PCSG);
write_sm4_rdef(ctx, &tpf.dxbc);
tpf_write_shdr(&tpf, entry_func);