mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/tpf: Write the patch constant function in hull shaders.
We use a single hs_fork_phase here for the patch constant function.
This commit is contained in:
parent
f771f081d9
commit
1ed5f1a4d0
Notes:
Henri Verbeet
2024-10-16 21:47:54 +02:00
Approved-by: Elizabeth Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1187
@ -6281,29 +6281,24 @@ void hlsl_run_const_passes(struct hlsl_ctx *ctx, struct hlsl_block *body)
|
|||||||
} while (progress);
|
} while (progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void generate_vsir_signature_entry(struct hlsl_ctx *ctx,
|
static void generate_vsir_signature_entry(struct hlsl_ctx *ctx, struct vsir_program *program,
|
||||||
struct vsir_program *program, bool output, struct hlsl_ir_var *var)
|
struct shader_signature *signature, bool output, struct hlsl_ir_var *var)
|
||||||
{
|
{
|
||||||
enum vkd3d_shader_sysval_semantic sysval = VKD3D_SHADER_SV_NONE;
|
enum vkd3d_shader_sysval_semantic sysval = VKD3D_SHADER_SV_NONE;
|
||||||
enum vkd3d_shader_component_type component_type;
|
enum vkd3d_shader_component_type component_type;
|
||||||
unsigned int register_index, mask, use_mask;
|
unsigned int register_index, mask, use_mask;
|
||||||
const char *name = var->semantic.name;
|
const char *name = var->semantic.name;
|
||||||
enum vkd3d_shader_register_type type;
|
enum vkd3d_shader_register_type type;
|
||||||
struct shader_signature *signature;
|
|
||||||
struct signature_element *element;
|
struct signature_element *element;
|
||||||
|
|
||||||
if (output)
|
|
||||||
signature = &program->output_signature;
|
|
||||||
else
|
|
||||||
signature = &program->input_signature;
|
|
||||||
|
|
||||||
if (hlsl_version_ge(ctx, 4, 0))
|
if (hlsl_version_ge(ctx, 4, 0))
|
||||||
{
|
{
|
||||||
struct vkd3d_string_buffer *string;
|
struct vkd3d_string_buffer *string;
|
||||||
bool has_idx, ret;
|
bool has_idx, ret;
|
||||||
|
|
||||||
ret = sm4_sysval_semantic_from_semantic_name(&sysval, &program->shader_version,
|
ret = sm4_sysval_semantic_from_semantic_name(&sysval, &program->shader_version,
|
||||||
ctx->semantic_compat_mapping, ctx->domain, var->semantic.name, var->semantic.index, output, false);
|
ctx->semantic_compat_mapping, ctx->domain, var->semantic.name, var->semantic.index,
|
||||||
|
output, signature == &program->patch_constant_signature);
|
||||||
VKD3D_ASSERT(ret);
|
VKD3D_ASSERT(ret);
|
||||||
if (sysval == ~0u)
|
if (sysval == ~0u)
|
||||||
return;
|
return;
|
||||||
@ -6418,11 +6413,19 @@ static void generate_vsir_signature(struct hlsl_ctx *ctx,
|
|||||||
struct hlsl_ir_var *var;
|
struct hlsl_ir_var *var;
|
||||||
|
|
||||||
LIST_FOR_EACH_ENTRY(var, &func->extern_vars, struct hlsl_ir_var, extern_entry)
|
LIST_FOR_EACH_ENTRY(var, &func->extern_vars, struct hlsl_ir_var, extern_entry)
|
||||||
|
{
|
||||||
|
if (func == ctx->patch_constant_func)
|
||||||
|
{
|
||||||
|
generate_vsir_signature_entry(ctx, program,
|
||||||
|
&program->patch_constant_signature, var->is_output_semantic, var);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (var->is_input_semantic)
|
if (var->is_input_semantic)
|
||||||
generate_vsir_signature_entry(ctx, program, false, var);
|
generate_vsir_signature_entry(ctx, program, &program->input_signature, false, var);
|
||||||
if (var->is_output_semantic)
|
if (var->is_output_semantic)
|
||||||
generate_vsir_signature_entry(ctx, program, true, var);
|
generate_vsir_signature_entry(ctx, program, &program->output_signature, true, var);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7408,6 +7411,8 @@ static void sm4_generate_vsir(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl
|
|||||||
}
|
}
|
||||||
|
|
||||||
generate_vsir_signature(ctx, program, entry_func);
|
generate_vsir_signature(ctx, program, entry_func);
|
||||||
|
if (version.type == VKD3D_SHADER_TYPE_HULL)
|
||||||
|
generate_vsir_signature(ctx, program, ctx->patch_constant_func);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct hlsl_ir_jump *loop_unrolling_find_jump(struct hlsl_block *block, struct hlsl_ir_node *stop_point,
|
static struct hlsl_ir_jump *loop_unrolling_find_jump(struct hlsl_block *block, struct hlsl_ir_node *stop_point,
|
||||||
|
@ -3212,18 +3212,12 @@ static void add_section(struct hlsl_ctx *ctx, struct dxbc_writer *dxbc,
|
|||||||
ctx->result = buffer->status;
|
ctx->result = buffer->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tpf_write_signature(struct tpf_compiler *tpf, bool output)
|
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;
|
||||||
struct vkd3d_bytecode_buffer buffer = {0};
|
struct vkd3d_bytecode_buffer buffer = {0};
|
||||||
struct shader_signature *signature;
|
|
||||||
struct hlsl_ctx *ctx = tpf->ctx;
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if (output)
|
|
||||||
signature = &tpf->program->output_signature;
|
|
||||||
else
|
|
||||||
signature = &tpf->program->input_signature;
|
|
||||||
|
|
||||||
put_u32(&buffer, signature->element_count);
|
put_u32(&buffer, signature->element_count);
|
||||||
put_u32(&buffer, 8); /* unknown */
|
put_u32(&buffer, 8); /* unknown */
|
||||||
|
|
||||||
@ -3257,7 +3251,7 @@ static void tpf_write_signature(struct tpf_compiler *tpf, bool output)
|
|||||||
set_u32(&buffer, (2 + i * 6) * sizeof(uint32_t), string_offset);
|
set_u32(&buffer, (2 + i * 6) * sizeof(uint32_t), string_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
add_section(ctx, &tpf->dxbc, output ? TAG_OSGN : TAG_ISGN, &buffer);
|
add_section(tpf->ctx, &tpf->dxbc, tag, &buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static D3D_SHADER_VARIABLE_CLASS sm4_class(const struct hlsl_type *type)
|
static D3D_SHADER_VARIABLE_CLASS sm4_class(const struct hlsl_type *type)
|
||||||
@ -4794,7 +4788,8 @@ static void write_sm4_dcl_textures(const struct tpf_compiler *tpf, const struct
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void write_sm4_dcl_semantic(const struct tpf_compiler *tpf, const struct hlsl_ir_var *var)
|
static void tpf_write_dcl_semantic(const struct tpf_compiler *tpf,
|
||||||
|
const struct hlsl_ir_var *var, bool is_patch_constant_func)
|
||||||
{
|
{
|
||||||
const struct vkd3d_shader_version *version = &tpf->program->shader_version;
|
const struct vkd3d_shader_version *version = &tpf->program->shader_version;
|
||||||
const bool output = var->is_output_semantic;
|
const bool output = var->is_output_semantic;
|
||||||
@ -4832,7 +4827,7 @@ static void write_sm4_dcl_semantic(const struct tpf_compiler *tpf, const struct
|
|||||||
instr.dsts[0].reg.dimension = VSIR_DIMENSION_SCALAR;
|
instr.dsts[0].reg.dimension = VSIR_DIMENSION_SCALAR;
|
||||||
|
|
||||||
sm4_sysval_semantic_from_semantic_name(&semantic, version, tpf->ctx->semantic_compat_mapping,
|
sm4_sysval_semantic_from_semantic_name(&semantic, version, tpf->ctx->semantic_compat_mapping,
|
||||||
tpf->ctx->domain, var->semantic.name, var->semantic.index, output, false);
|
tpf->ctx->domain, var->semantic.name, var->semantic.index, output, is_patch_constant_func);
|
||||||
if (semantic == ~0u)
|
if (semantic == ~0u)
|
||||||
semantic = VKD3D_SHADER_SV_NONE;
|
semantic = VKD3D_SHADER_SV_NONE;
|
||||||
|
|
||||||
@ -4997,6 +4992,16 @@ static void tpf_write_hs_control_point_phase(const struct tpf_compiler *tpf)
|
|||||||
write_sm4_instruction(tpf, &instr);
|
write_sm4_instruction(tpf, &instr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void tpf_write_hs_fork_phase(const struct tpf_compiler *tpf)
|
||||||
|
{
|
||||||
|
struct sm4_instruction instr =
|
||||||
|
{
|
||||||
|
.opcode = VKD3D_SM5_OP_HS_FORK_PHASE,
|
||||||
|
};
|
||||||
|
|
||||||
|
write_sm4_instruction(tpf, &instr);
|
||||||
|
}
|
||||||
|
|
||||||
static void tpf_write_dcl_input_control_point_count(const struct tpf_compiler *tpf, const uint32_t count)
|
static void tpf_write_dcl_input_control_point_count(const struct tpf_compiler *tpf, const uint32_t count)
|
||||||
{
|
{
|
||||||
struct sm4_instruction instr =
|
struct sm4_instruction instr =
|
||||||
@ -6513,7 +6518,7 @@ static void tpf_write_shader_function(struct tpf_compiler *tpf, struct hlsl_ir_f
|
|||||||
{
|
{
|
||||||
if ((var->is_input_semantic && var->last_read)
|
if ((var->is_input_semantic && var->last_read)
|
||||||
|| (var->is_output_semantic && var->first_write))
|
|| (var->is_output_semantic && var->first_write))
|
||||||
write_sm4_dcl_semantic(tpf, var);
|
tpf_write_dcl_semantic(tpf, var, func == ctx->patch_constant_func);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tpf->program->shader_version.type == VKD3D_SHADER_TYPE_COMPUTE)
|
if (tpf->program->shader_version.type == VKD3D_SHADER_TYPE_COMPUTE)
|
||||||
@ -6613,6 +6618,12 @@ static void tpf_write_shdr(struct tpf_compiler *tpf, struct hlsl_ir_function_dec
|
|||||||
|
|
||||||
tpf_write_shader_function(tpf, entry_func);
|
tpf_write_shader_function(tpf, entry_func);
|
||||||
|
|
||||||
|
if (version->type == VKD3D_SHADER_TYPE_HULL)
|
||||||
|
{
|
||||||
|
tpf_write_hs_fork_phase(tpf);
|
||||||
|
tpf_write_shader_function(tpf, ctx->patch_constant_func);
|
||||||
|
}
|
||||||
|
|
||||||
set_u32(&buffer, token_count_position, bytecode_get_size(&buffer) / sizeof(uint32_t));
|
set_u32(&buffer, token_count_position, bytecode_get_size(&buffer) / sizeof(uint32_t));
|
||||||
|
|
||||||
add_section(ctx, &tpf->dxbc, TAG_SHDR, &buffer);
|
add_section(ctx, &tpf->dxbc, TAG_SHDR, &buffer);
|
||||||
@ -6717,8 +6728,10 @@ int tpf_compile(struct vsir_program *program, uint64_t config_flags,
|
|||||||
init_sm4_lookup_tables(&tpf.lookup);
|
init_sm4_lookup_tables(&tpf.lookup);
|
||||||
dxbc_writer_init(&tpf.dxbc);
|
dxbc_writer_init(&tpf.dxbc);
|
||||||
|
|
||||||
tpf_write_signature(&tpf, false);
|
tpf_write_signature(&tpf, &program->input_signature, TAG_ISGN);
|
||||||
tpf_write_signature(&tpf, true);
|
tpf_write_signature(&tpf, &program->output_signature, TAG_OSGN);
|
||||||
|
if (ctx->profile->type == VKD3D_SHADER_TYPE_HULL)
|
||||||
|
tpf_write_signature(&tpf, &program->patch_constant_signature, TAG_PCSG);
|
||||||
write_sm4_rdef(ctx, &tpf.dxbc);
|
write_sm4_rdef(ctx, &tpf.dxbc);
|
||||||
tpf_write_shdr(&tpf, entry_func);
|
tpf_write_shdr(&tpf, entry_func);
|
||||||
tpf_write_sfi0(&tpf);
|
tpf_write_sfi0(&tpf);
|
||||||
|
@ -1924,7 +1924,7 @@ static inline void *vkd3d_find_struct_(const struct vkd3d_struct *chain,
|
|||||||
#define VKD3D_DXBC_HEADER_SIZE (8 * sizeof(uint32_t))
|
#define VKD3D_DXBC_HEADER_SIZE (8 * sizeof(uint32_t))
|
||||||
#define VKD3D_DXBC_CHUNK_ALIGNMENT sizeof(uint32_t)
|
#define VKD3D_DXBC_CHUNK_ALIGNMENT sizeof(uint32_t)
|
||||||
|
|
||||||
#define DXBC_MAX_SECTION_COUNT 6
|
#define DXBC_MAX_SECTION_COUNT 7
|
||||||
|
|
||||||
struct dxbc_writer
|
struct dxbc_writer
|
||||||
{
|
{
|
||||||
|
@ -512,9 +512,12 @@ static HRESULT STDMETHODCALLTYPE d3d12_reflection_GetOutputParameterDesc(
|
|||||||
static HRESULT STDMETHODCALLTYPE d3d12_reflection_GetPatchConstantParameterDesc(
|
static HRESULT STDMETHODCALLTYPE d3d12_reflection_GetPatchConstantParameterDesc(
|
||||||
ID3D12ShaderReflection *iface, UINT index, D3D12_SIGNATURE_PARAMETER_DESC *desc)
|
ID3D12ShaderReflection *iface, UINT index, D3D12_SIGNATURE_PARAMETER_DESC *desc)
|
||||||
{
|
{
|
||||||
FIXME("iface %p, index %u, desc %p stub!\n", iface, index, desc);
|
struct d3d12_reflection *reflection = impl_from_ID3D12ShaderReflection(iface);
|
||||||
|
|
||||||
return E_NOTIMPL;
|
TRACE("iface %p, index %u, desc %p.\n", iface, index, desc);
|
||||||
|
|
||||||
|
return get_signature_parameter(&reflection->signature_info.patch_constant, index, desc,
|
||||||
|
/* FIXME: check shader type */true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct ID3D12ShaderReflectionVariable * STDMETHODCALLTYPE d3d12_reflection_GetVariableByName(
|
static struct ID3D12ShaderReflectionVariable * STDMETHODCALLTYPE d3d12_reflection_GetVariableByName(
|
||||||
|
@ -2589,7 +2589,6 @@ static void test_signature_reflection(void)
|
|||||||
"Got %u input parameters.\n", shader_desc.InputParameters);
|
"Got %u input parameters.\n", shader_desc.InputParameters);
|
||||||
ok(shader_desc.OutputParameters == tests[i].output_count,
|
ok(shader_desc.OutputParameters == tests[i].output_count,
|
||||||
"Got %u output parameters.\n", shader_desc.OutputParameters);
|
"Got %u output parameters.\n", shader_desc.OutputParameters);
|
||||||
todo_if(tests[i].patch_constant_count != 0)
|
|
||||||
ok(shader_desc.PatchConstantParameters == tests[i].patch_constant_count,
|
ok(shader_desc.PatchConstantParameters == tests[i].patch_constant_count,
|
||||||
"Got %u patch constant parameters.\n", shader_desc.PatchConstantParameters);
|
"Got %u patch constant parameters.\n", shader_desc.PatchConstantParameters);
|
||||||
|
|
||||||
@ -2621,13 +2620,13 @@ static void test_signature_reflection(void)
|
|||||||
{
|
{
|
||||||
vkd3d_test_push_context("Patch constant %u", j);
|
vkd3d_test_push_context("Patch constant %u", j);
|
||||||
hr = reflection->lpVtbl->GetPatchConstantParameterDesc(reflection, j, &desc);
|
hr = reflection->lpVtbl->GetPatchConstantParameterDesc(reflection, j, &desc);
|
||||||
todo ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||||
check_signature_element(&desc, &tests[i].patch_constants[j], tests[i].signature_elements_todo);
|
check_signature_element(&desc, &tests[i].patch_constants[j], tests[i].signature_elements_todo);
|
||||||
vkd3d_test_pop_context();
|
vkd3d_test_pop_context();
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = reflection->lpVtbl->GetPatchConstantParameterDesc(reflection, shader_desc.PatchConstantParameters, &desc);
|
hr = reflection->lpVtbl->GetPatchConstantParameterDesc(reflection, shader_desc.PatchConstantParameters, &desc);
|
||||||
todo ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
|
ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
|
||||||
|
|
||||||
ID3D10Blob_Release(code);
|
ID3D10Blob_Release(code);
|
||||||
refcount = reflection->lpVtbl->Release(reflection);
|
refcount = reflection->lpVtbl->Release(reflection);
|
||||||
|
Loading…
Reference in New Issue
Block a user