On Fri, Aug 20, 2021 at 1:45 AM Zebediah Figura zfigura@codeweavers.com wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
libs/vkd3d-shader/hlsl.h | 2 +- libs/vkd3d-shader/hlsl_codegen.c | 4 +- libs/vkd3d-shader/hlsl_sm4.c | 117 ++++++++++++++++++++++++++++++- 3 files changed, 118 insertions(+), 5 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index 029dc3de..92f854c0 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c
@@ -658,11 +671,103 @@ static void write_sm4_dcl_constant_buffer(struct vkd3d_bytecode_buffer *buffer, write_sm4_instruction(buffer, &instr); }
+static void write_sm4_dcl_semantic(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_var *var) +{
- const struct hlsl_profile_info *profile = ctx->profile;
- const bool output = var->is_output_semantic;
- D3D_NAME usage;
- bool has_idx;
- struct sm4_instruction instr =
- {
.dst.reg.dim = VKD3D_SM4_DIMENSION_VEC4,
.has_dst = 1,
- };
- if (hlsl_sm4_register_from_semantic(ctx, &var->semantic, output, &instr.dst.reg.type, &has_idx))
- {
if (has_idx)
{
instr.dst.reg.idx[0] = var->semantic.index;
instr.dst.reg.idx_count = 1;
}
else
{
instr.dst.reg.idx_count = 0;
}
instr.dst.writemask = (1 << var->data_type->dimx) - 1;
- }
- else
- {
instr.dst.reg.type = output ? VKD3D_SM4_RT_OUTPUT : VKD3D_SM4_RT_INPUT;
instr.dst.reg.idx[0] = var->reg.id;
instr.dst.reg.idx_count = 1;
instr.dst.writemask = var->reg.writemask;
- }
- if (instr.dst.reg.type == VKD3D_SM4_RT_DEPTHOUT)
instr.dst.reg.dim = VKD3D_SM4_DIMENSION_SCALAR;
- hlsl_sm4_usage_from_semantic(ctx, &var->semantic, output, &usage);
- if (var->is_input_semantic)
- {
switch (usage)
{
case D3D_NAME_UNDEFINED:
instr.opcode = (profile->type == VKD3D_SHADER_TYPE_PIXEL)
? VKD3D_SM4_OP_DCL_INPUT_PS : VKD3D_SM4_OP_DCL_INPUT;
break;
case D3D_NAME_INSTANCE_ID:
case D3D_NAME_PRIMITIVE_ID:
case D3D_NAME_VERTEX_ID:
instr.opcode = (profile->type == VKD3D_SHADER_TYPE_PIXEL)
? VKD3D_SM4_OP_DCL_INPUT_PS_SGV : VKD3D_SM4_OP_DCL_INPUT_SGV;
break;
default:
instr.opcode = (profile->type == VKD3D_SHADER_TYPE_PIXEL)
? VKD3D_SM4_OP_DCL_INPUT_PS_SIV : VKD3D_SM4_OP_DCL_INPUT_SIV;
break;
}
if (profile->type == VKD3D_SHADER_TYPE_PIXEL)
instr.opcode |= VKD3DSIM_LINEAR << VKD3D_SM4_INTERPOLATION_MODE_SHIFT;
This probably deserves a FIXME I guess?
Mostly unrelated to the patch, I see that we currently don't parse the centroid modifier. Just mentioning it for a possible, separate follow up patch.