vkd3d-shader: Add an option to enable child effects compilation.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
Nikolay Sivov 2024-02-24 23:47:48 +01:00 committed by Alexandre Julliard
parent 7f1fdd447c
commit 13227f3852
Notes: Alexandre Julliard 2024-03-12 22:56:09 +01:00
Approved-by: Zebediah Figura (@zfigura)
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/692
5 changed files with 31 additions and 2 deletions

View File

@ -299,6 +299,15 @@ enum vkd3d_shader_compile_option_name
* \since 1.11
*/
VKD3D_SHADER_COMPILE_OPTION_FEATURE = 0x0000000a,
/**
* If \a value is non-zero compilation will produce a child effect using
* shared object descriptions, as instructed by the "shared" modifier.
* Child effects are supported with fx_2_0, fx_4_0, and fx_4_1. This option
* and "shared" modifiers are ignored for fx_5_0 profile, and non-fx profiles.
*
* \since 1.12
*/
VKD3D_SHADER_COMPILE_OPTION_CHILD_EFFECT = 0x0000000b,
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPILE_OPTION_NAME),
};

View File

@ -3597,6 +3597,10 @@ static bool hlsl_ctx_init(struct hlsl_ctx *ctx, const struct vkd3d_shader_compil
{
ctx->semantic_compat_mapping = option->value & VKD3D_SHADER_COMPILE_OPTION_BACKCOMPAT_MAP_SEMANTIC_NAMES;
}
else if (option->name == VKD3D_SHADER_COMPILE_OPTION_CHILD_EFFECT)
{
ctx->child_effect = !!option->value;
}
}
return true;

View File

@ -922,6 +922,7 @@ struct hlsl_ctx
uint32_t found_numthreads : 1;
bool semantic_compat_mapping;
bool child_effect;
};
struct hlsl_resource_load_params

View File

@ -244,7 +244,7 @@ HRESULT WINAPI D3DCompile2(const void *data, SIZE_T data_size, const char *filen
{
struct vkd3d_shader_preprocess_info preprocess_info;
struct vkd3d_shader_hlsl_source_info hlsl_info;
struct vkd3d_shader_compile_option options[4];
struct vkd3d_shader_compile_option options[5];
struct vkd3d_shader_compile_info compile_info;
struct vkd3d_shader_compile_option *option;
struct vkd3d_shader_code byte_code;
@ -262,7 +262,7 @@ HRESULT WINAPI D3DCompile2(const void *data, SIZE_T data_size, const char *filen
if (flags & ~(D3DCOMPILE_DEBUG | D3DCOMPILE_PACK_MATRIX_ROW_MAJOR | D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR))
FIXME("Ignoring flags %#x.\n", flags);
if (effect_flags)
if (effect_flags & ~D3DCOMPILE_EFFECT_CHILD_EFFECT)
FIXME("Ignoring effect flags %#x.\n", effect_flags);
if (secondary_flags)
FIXME("Ignoring secondary flags %#x.\n", secondary_flags);
@ -330,6 +330,13 @@ HRESULT WINAPI D3DCompile2(const void *data, SIZE_T data_size, const char *filen
option->value = VKD3D_SHADER_COMPILE_OPTION_BACKCOMPAT_MAP_SEMANTIC_NAMES;
}
if (effect_flags & D3DCOMPILE_EFFECT_CHILD_EFFECT)
{
option = &options[compile_info.option_count++];
option->name = VKD3D_SHADER_COMPILE_OPTION_CHILD_EFFECT;
option->value = true;
}
ret = vkd3d_shader_compile(&compile_info, &byte_code, &messages);
if (messages && messages_blob)

View File

@ -39,6 +39,7 @@ enum
{
OPTION_HELP = CHAR_MAX + 1,
OPTION_BUFFER_UAV,
OPTION_CHILD_EFFECT,
OPTION_ENTRY,
OPTION_FRAGMENT_COORDINATE_ORIGIN,
OPTION_MATRIX_STORAGE_ORDER,
@ -186,6 +187,8 @@ static void print_usage(const char *program_name)
" --buffer-uav=<type> Specify the buffer type to use for buffer UAV bindings.\n"
" Valid values are 'buffer-texture' (default) and\n"
" 'storage-buffer'.\n"
" --child-effect Compile effect as a child effect. This option is only meaningful\n"
" for fx_2_0 and fx_4_0/fx_4_1 profiles.\n"
" -e, --entry=<name> Use <name> as the entry point (default is \"main\").\n"
" -E Preprocess the source code instead of compiling it.\n"
" --formatting=<flags> Specify the formatting options for text output.\n"
@ -479,6 +482,7 @@ static bool parse_command_line(int argc, char **argv, struct options *options)
{
{"help", no_argument, NULL, OPTION_HELP},
{"buffer-uav", required_argument, NULL, OPTION_BUFFER_UAV},
{"child-effect", no_argument, NULL, OPTION_CHILD_EFFECT},
{"entry", required_argument, NULL, OPTION_ENTRY},
{"fragment-coordinate-origin", required_argument, NULL, OPTION_FRAGMENT_COORDINATE_ORIGIN},
{"matrix-storage-order", required_argument, NULL, OPTION_MATRIX_STORAGE_ORDER},
@ -523,6 +527,10 @@ static bool parse_command_line(int argc, char **argv, struct options *options)
add_compile_option(options, VKD3D_SHADER_COMPILE_OPTION_BUFFER_UAV, buffer_uav);
break;
case OPTION_CHILD_EFFECT:
add_compile_option(options, VKD3D_SHADER_COMPILE_OPTION_CHILD_EFFECT, 1);
break;
case OPTION_ENTRY:
case 'e':
options->entry_point = optarg;