Giovanni Mascellani (@giomasce) commented about libs/vkd3d-shader/dxbc.c:
+int shader_detect_dxbc_source_type(const struct vkd3d_shader_code *dxbc,
struct vkd3d_shader_message_context *message_context, enum vkd3d_shader_source_type *type)
+{
- int ret;
- *type = VKD3D_SHADER_SOURCE_NONE;
- if ((ret = for_each_dxbc_section(dxbc, message_context, NULL, autodetect_handler, type)) < 0)
- {
ERR("Failed to parse source type.\n");
return ret;
- }
- /* A TPF section exists if for_each_dxbc_section() succeeds. */
- if (*type == VKD3D_SHADER_SOURCE_NONE)
*type = VKD3D_SHADER_SOURCE_DXBC_TPF;
It's probably not a big deal, but I'd use a more symmetric (and robust) approach. Both TPF and DXIL should be positively detected, and if neither or both are found an error should be emitted.
Also, maybe you could already some some simple TPF autodetection test in `tests/vkd3d_shader_api.c` (and then add a DXIL test as soon as you can do something that does not result in an error with it).