Overall, I think this is great; the special handling for hull shaders in the SPIR-V backend has really been a pain, and getting rid of it will be a nice simplification. Two notes though:
+static void shader_register_init(struct vkd3d_shader_register *reg, + enum vkd3d_shader_register_type reg_type, enum vkd3d_data_type data_type) +{ + reg->type = reg_type; + reg->precision = VKD3D_SHADER_REGISTER_PRECISION_DEFAULT; + reg->non_uniform = false; + reg->data_type = data_type; + reg->idx[0].offset = ~0u; + reg->idx[0].rel_addr = NULL; + reg->idx[1].offset = ~0u; + reg->idx[1].rel_addr = NULL; + reg->idx[2].offset = ~0u; + reg->idx[2].rel_addr = NULL; + reg->immconst_type = VKD3D_IMMCONST_SCALAR; +}
It doesn't need to be in this series, but I think we have a couple of other places where we could use this helper as well. In particular in shader_instruction_eliminate_phase_instance_id() and a few places in d3dbc.c.
+static void shader_dst_param_normalise_outpointid(struct vkd3d_shader_dst_param *dst_param, + struct vkd3d_shader_normaliser *normaliser) +{ + struct vkd3d_shader_register *reg = &dst_param->reg; + + if (normaliser_is_in_control_point_phase(normaliser) && reg->type == VKD3DSPR_OUTPUT) + { + assert(reg->idx[1].offset == ~0u); + reg->idx[1] = reg->idx[0]; + /* The control point id param is implicit here. Avoid later complications by inserting it. */ + reg->idx[0].offset = 0; + reg->idx[0].rel_addr = normaliser->outpointid_param; + } +}
I don't think we should use assert() above, unless we first reject shaders containing these in the parser. I.e., as-is it would be possible to craft a shader that triggers an assert in vkd3d-shader, and applications using vkd3d-shader. That's undesirable because input shaders are potentially outside the control of the application, depending on the use-case.