vkd3d-compiler: Introduce "dxbc-fx" as a source type.

Commit 949708450b introduced support for
effect binaries embedded in DXBC containers, but only when using
auto-detection to determine the source type. That's undesirable;
although auto-detection is convenient for interactive use, it's not
necessarily suitable for use in e.g. scripts. It also meant this wasn't
listed through --print-source-types.
This commit is contained in:
Henri Verbeet
2025-02-17 13:35:36 +01:00
parent a169ae05e8
commit 751f8b313c
Notes: Henri Verbeet 2025-02-18 17:59:15 +01:00
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1377

View File

@@ -91,6 +91,7 @@ static const struct source_type_info
const char *description; const char *description;
bool is_binary; bool is_binary;
enum vkd3d_shader_target_type default_target_type; enum vkd3d_shader_target_type default_target_type;
uint32_t dxbc_tag;
} }
source_type_info[] = source_type_info[] =
{ {
@@ -112,6 +113,9 @@ source_type_info[] =
{VKD3D_SHADER_SOURCE_FX, {VKD3D_SHADER_SOURCE_FX,
"fx", "Raw effect binary section. This type includes fx_2_0 and fx_4+ formats.\n", "fx", "Raw effect binary section. This type includes fx_2_0 and fx_4+ formats.\n",
true, VKD3D_SHADER_TARGET_D3D_ASM}, true, VKD3D_SHADER_TARGET_D3D_ASM},
{VKD3D_SHADER_SOURCE_FX,
"dxbc-fx", "An effect binary embedded in a DXBC container.\n",
true, VKD3D_SHADER_TARGET_D3D_ASM, TAG_FX10},
}; };
static const struct target_type_info static const struct target_type_info
@@ -500,7 +504,7 @@ static bool parse_dxbc_source_type(const struct vkd3d_shader_code *source,
if ((ret = vkd3d_shader_locate_dxbc_section(source, TAG_FX10, code, &messages)) >= 0) if ((ret = vkd3d_shader_locate_dxbc_section(source, TAG_FX10, code, &messages)) >= 0)
{ {
*source_type = get_source_type_info(VKD3D_SHADER_SOURCE_FX); *source_type = parse_source_type("dxbc-fx");
return true; return true;
} }
@@ -690,17 +694,22 @@ static bool parse_command_line(int argc, char **argv, struct options *options)
static void print_source_types(void) static void print_source_types(void)
{ {
const enum vkd3d_shader_source_type *source_types; const enum vkd3d_shader_source_type *source_types;
unsigned int count, i; unsigned int count, i, j;
source_types = vkd3d_shader_get_supported_source_types(&count); source_types = vkd3d_shader_get_supported_source_types(&count);
fputs("Supported source types:\n", stdout); fputs("Supported source types:\n", stdout);
for (i = 0; i < count; ++i) for (i = 0; i < count; ++i)
{ {
const struct source_type_info *type = get_source_type_info(source_types[i]); for (j = 0; j < ARRAY_SIZE(source_type_info); ++j)
if (type) {
const struct source_type_info *type = &source_type_info[j];
if (type->type != source_types[i])
continue;
fprintf(stdout, " %-12s %s", type->name, type->description); fprintf(stdout, " %-12s %s", type->name, type->description);
} }
}
} }
static void print_target_types(const struct source_type_info *source_type) static void print_target_types(const struct source_type_info *source_type)
@@ -863,6 +872,19 @@ int main(int argc, char **argv)
options.source_type = get_source_type_info(VKD3D_SHADER_SOURCE_HLSL); options.source_type = get_source_type_info(VKD3D_SHADER_SOURCE_HLSL);
} }
} }
else if (options.source_type->dxbc_tag)
{
if ((ret = vkd3d_shader_locate_dxbc_section(&source,
options.source_type->dxbc_tag, &info.source, &messages)) < 0)
{
fprintf(stderr, "Failed to locate dxbc section for source type '%s', ret %d.\n",
options.source_type->name, ret);
if (messages)
fputs(messages, stderr);
vkd3d_shader_free_messages(messages);
goto done;
}
}
if (!options.target_type && !options.preprocess_only) if (!options.target_type && !options.preprocess_only)
options.target_type = get_target_type_info(options.source_type->default_target_type); options.target_type = get_target_type_info(options.source_type->default_target_type);