mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d-shader/ir: Insert hull shader control point input declarations if no control point phase is defined.
The SPIR-V backend will emit a default control point phase. Inserting inputs into the IR allows handling of declarations via the usual path instead of an ad hoc implementation which may not match later changes to input handling.
This commit is contained in:
committed by
Alexandre Julliard
parent
14295a224d
commit
98b5e2c6e0
Notes:
Alexandre Julliard
2023-04-12 22:34:30 +02:00
Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/141
@@ -319,9 +319,71 @@ static bool shader_dst_param_normalise_outpointid(struct vkd3d_shader_dst_param
|
||||
return true;
|
||||
}
|
||||
|
||||
enum vkd3d_result shader_normaliser_normalise_hull_shader_control_point_io(struct vkd3d_shader_normaliser *normaliser)
|
||||
static void shader_dst_param_io_init(struct vkd3d_shader_dst_param *param,
|
||||
const struct vkd3d_shader_signature_element *e, enum vkd3d_shader_register_type reg_type)
|
||||
{
|
||||
param->write_mask = e->mask;
|
||||
param->modifiers = 0;
|
||||
param->shift = 0;
|
||||
shader_register_init(¶m->reg, reg_type, vkd3d_data_type_from_component_type(e->component_type));
|
||||
}
|
||||
|
||||
static enum vkd3d_result shader_normaliser_emit_hs_input(struct vkd3d_shader_normaliser *normaliser,
|
||||
const struct vkd3d_shader_signature *s, unsigned int input_control_point_count, unsigned int dst)
|
||||
{
|
||||
const struct vkd3d_shader_signature_element *e;
|
||||
struct vkd3d_shader_instruction *ins;
|
||||
struct vkd3d_shader_dst_param *param;
|
||||
unsigned int i, count;
|
||||
|
||||
for (i = 0, count = 1; i < s->element_count; ++i)
|
||||
count += !!s->elements[i].used_mask;
|
||||
|
||||
if (!shader_instruction_array_reserve(&normaliser->instructions, normaliser->instructions.count + count))
|
||||
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
memmove(&normaliser->instructions.elements[dst + count], &normaliser->instructions.elements[dst],
|
||||
(normaliser->instructions.count - dst) * sizeof(*normaliser->instructions.elements));
|
||||
normaliser->instructions.count += count;
|
||||
|
||||
ins = &normaliser->instructions.elements[dst];
|
||||
shader_instruction_init(ins, VKD3DSIH_HS_CONTROL_POINT_PHASE);
|
||||
ins->flags = 1;
|
||||
++ins;
|
||||
|
||||
for (i = 0; i < s->element_count; ++i)
|
||||
{
|
||||
e = &s->elements[i];
|
||||
if (!e->used_mask)
|
||||
continue;
|
||||
|
||||
if (e->sysval_semantic != VKD3D_SHADER_SV_NONE)
|
||||
{
|
||||
shader_instruction_init(ins, VKD3DSIH_DCL_INPUT_SIV);
|
||||
param = &ins->declaration.register_semantic.reg;
|
||||
ins->declaration.register_semantic.sysval_semantic = vkd3d_siv_from_sysval(e->sysval_semantic);
|
||||
}
|
||||
else
|
||||
{
|
||||
shader_instruction_init(ins, VKD3DSIH_DCL_INPUT);
|
||||
param = &ins->declaration.dst;
|
||||
}
|
||||
|
||||
shader_dst_param_io_init(param, e, VKD3DSPR_INPUT);
|
||||
param->reg.idx[0].offset = input_control_point_count;
|
||||
param->reg.idx[1].offset = i;
|
||||
|
||||
++ins;
|
||||
}
|
||||
|
||||
return VKD3D_OK;
|
||||
}
|
||||
|
||||
enum vkd3d_result shader_normaliser_normalise_hull_shader_control_point_io(struct vkd3d_shader_normaliser *normaliser,
|
||||
const struct vkd3d_shader_signature *input_signature)
|
||||
{
|
||||
struct vkd3d_shader_instruction_array *instructions = &normaliser->instructions;
|
||||
unsigned int input_control_point_count;
|
||||
struct vkd3d_shader_instruction *ins;
|
||||
unsigned int i, j;
|
||||
|
||||
@@ -356,6 +418,28 @@ enum vkd3d_result shader_normaliser_normalise_hull_shader_control_point_io(struc
|
||||
}
|
||||
}
|
||||
|
||||
normaliser->phase = VKD3DSIH_INVALID;
|
||||
input_control_point_count = 1;
|
||||
|
||||
for (i = 0; i < instructions->count; ++i)
|
||||
{
|
||||
ins = &instructions->elements[i];
|
||||
|
||||
switch (ins->handler_idx)
|
||||
{
|
||||
case VKD3DSIH_DCL_INPUT_CONTROL_POINT_COUNT:
|
||||
input_control_point_count = ins->declaration.count;
|
||||
break;
|
||||
case VKD3DSIH_HS_CONTROL_POINT_PHASE:
|
||||
return VKD3D_OK;
|
||||
case VKD3DSIH_HS_FORK_PHASE:
|
||||
case VKD3DSIH_HS_JOIN_PHASE:
|
||||
return shader_normaliser_emit_hs_input(normaliser, input_signature, input_control_point_count, i);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return VKD3D_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user