vkd3d-shader/hlsl: Store hull and domain shader properties in vsir_program.

The alternative to adding the vsir_program->tess_output_primitive and
vsir_program->tess_partitioning fields would be to emit the vsir
DCL_TESSELLATOR_OUTPUT_PRIMITIVE and DCL_TESSELLATOR_PARTITIONING
instructions, like DXIL does, but I think that the preference is to store
these kind of data directly in the vsir_program.
This commit is contained in:
Francisco Casas 2024-11-26 17:50:19 -03:00 committed by Henri Verbeet
parent 347e7a396d
commit f22729461e
Notes: Henri Verbeet 2024-12-10 15:58:38 +01:00
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1308
4 changed files with 34 additions and 11 deletions

View File

@ -9745,6 +9745,8 @@ static void sm6_parser_emit_dcl_tessellator_partitioning(struct sm6_parser *sm6,
ins = sm6_parser_add_instruction(sm6, VKD3DSIH_DCL_TESSELLATOR_PARTITIONING);
ins->declaration.tessellator_partitioning = tessellator_partitioning;
sm6->p.program->tess_partitioning = tessellator_partitioning;
}
static void sm6_parser_emit_dcl_tessellator_output_primitive(struct sm6_parser *sm6,
@ -9761,6 +9763,8 @@ static void sm6_parser_emit_dcl_tessellator_output_primitive(struct sm6_parser *
ins = sm6_parser_add_instruction(sm6, VKD3DSIH_DCL_TESSELLATOR_OUTPUT_PRIMITIVE);
ins->declaration.tessellator_output_primitive = primitive;
sm6->p.program->tess_output_primitive = primitive;
}
static void sm6_parser_emit_dcl_max_tessellation_factor(struct sm6_parser *sm6, struct sm6_metadata_value *m)

View File

@ -9902,6 +9902,19 @@ static void sm4_generate_vsir(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl
program->thread_group_size.y = ctx->thread_count[1];
program->thread_group_size.z = ctx->thread_count[2];
}
else if (version.type == VKD3D_SHADER_TYPE_HULL)
{
program->input_control_point_count = 1; /* TODO: Obtain from InputPatch */
program->output_control_point_count = ctx->output_control_point_count;
program->tess_domain = ctx->domain;
program->tess_partitioning = ctx->partitioning;
program->tess_output_primitive = ctx->output_primitive;
}
else if (version.type == VKD3D_SHADER_TYPE_DOMAIN)
{
program->input_control_point_count = 0; /* TODO: Obtain from OutputPatch */
program->tess_domain = ctx->domain;
}
LIST_FOR_EACH_ENTRY(cbuffer, &ctx->buffers, struct hlsl_buffer, entry)
{

View File

@ -1262,6 +1262,7 @@ static void shader_sm5_read_dcl_tessellator_partitioning(struct vkd3d_shader_ins
{
ins->declaration.tessellator_partitioning = (opcode_token & VKD3D_SM5_TESSELLATOR_MASK)
>> VKD3D_SM5_TESSELLATOR_SHIFT;
priv->p.program->tess_partitioning = ins->declaration.tessellator_partitioning;
}
static void shader_sm5_read_dcl_tessellator_output_primitive(struct vkd3d_shader_instruction *ins, uint32_t opcode,
@ -1269,6 +1270,7 @@ static void shader_sm5_read_dcl_tessellator_output_primitive(struct vkd3d_shader
{
ins->declaration.tessellator_output_primitive = (opcode_token & VKD3D_SM5_TESSELLATOR_MASK)
>> VKD3D_SM5_TESSELLATOR_SHIFT;
priv->p.program->tess_output_primitive = ins->declaration.tessellator_output_primitive;
}
static void shader_sm5_read_dcl_hs_max_tessfactor(struct vkd3d_shader_instruction *ins, uint32_t opcode,
@ -4842,7 +4844,8 @@ static void tpf_write_program(struct tpf_compiler *tpf, const struct vsir_progra
static void tpf_write_shdr(struct tpf_compiler *tpf, struct hlsl_ir_function_decl *entry_func)
{
const struct vkd3d_shader_version *version = &tpf->program->shader_version;
const struct vsir_program *program = tpf->program;
const struct vkd3d_shader_version *version;
struct vkd3d_bytecode_buffer buffer = {0};
struct hlsl_ctx *ctx = tpf->ctx;
size_t token_count_position;
@ -4862,29 +4865,30 @@ static void tpf_write_shdr(struct tpf_compiler *tpf, struct hlsl_ir_function_dec
tpf->buffer = &buffer;
version = &program->shader_version;
put_u32(&buffer, vkd3d_make_u32((version->major << 4) | version->minor, shader_types[version->type]));
token_count_position = put_u32(&buffer, 0);
if (tpf->program->global_flags)
write_sm4_dcl_global_flags(tpf, tpf->program->global_flags);
if (program->global_flags)
write_sm4_dcl_global_flags(tpf, program->global_flags);
if (version->type == VKD3D_SHADER_TYPE_HULL)
{
tpf_write_hs_decls(tpf);
tpf_write_dcl_input_control_point_count(tpf, 1); /* TODO: Obtain from InputPatch */
tpf_write_dcl_output_control_point_count(tpf, ctx->output_control_point_count);
tpf_write_dcl_tessellator_domain(tpf, ctx->domain);
tpf_write_dcl_tessellator_partitioning(tpf, ctx->partitioning);
tpf_write_dcl_tessellator_output_primitive(tpf, ctx->output_primitive);
tpf_write_dcl_input_control_point_count(tpf, program->input_control_point_count);
tpf_write_dcl_output_control_point_count(tpf, program->output_control_point_count);
tpf_write_dcl_tessellator_domain(tpf, program->tess_domain);
tpf_write_dcl_tessellator_partitioning(tpf, program->tess_partitioning);
tpf_write_dcl_tessellator_output_primitive(tpf, program->tess_output_primitive);
}
else if (version->type == VKD3D_SHADER_TYPE_DOMAIN)
{
tpf_write_dcl_input_control_point_count(tpf, 0); /* TODO: Obtain from OutputPatch */
tpf_write_dcl_tessellator_domain(tpf, ctx->domain);
tpf_write_dcl_input_control_point_count(tpf, program->input_control_point_count);
tpf_write_dcl_tessellator_domain(tpf, program->tess_domain);
}
tpf_write_program(tpf, tpf->program);
tpf_write_program(tpf, program);
set_u32(&buffer, token_count_position, bytecode_get_size(&buffer) / sizeof(uint32_t));

View File

@ -1444,6 +1444,8 @@ struct vsir_program
enum vsir_control_flow_type cf_type;
enum vsir_normalisation_level normalisation_level;
enum vkd3d_tessellator_domain tess_domain;
enum vkd3d_shader_tessellator_partitioning tess_partitioning;
enum vkd3d_shader_tessellator_output_primitive tess_output_primitive;
uint32_t io_dcls[VKD3D_BITMAP_SIZE(VKD3DSPR_COUNT)];
struct vsir_features features;