mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d-shader: Add a compile option to control whether implicit truncation warnings are printed.
d3dcompiler and d3dx9 versions before 42 don't emit this error; this will be necessary to emulate that behaviour. Other warnings exist that are introduced in different d3dcompiler versions, although there are not very many distinct HLSL warnings to begin with. We could of course group all these together under a single compiler option, but I find that using separate top-level options is unilaterally friendlier to an API consumer, and simpler to implement as well. It also in some sense maps conceptually to e.g. "-Wno-implicit-conversion".
This commit is contained in:
committed by
Alexandre Julliard
parent
b382d1843d
commit
6b6e4bc212
Notes:
Alexandre Julliard
2024-03-27 23:08:04 +01:00
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/735
@@ -1642,6 +1642,57 @@ static void test_emit_signature(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void test_warning_options(void)
|
||||
{
|
||||
struct vkd3d_shader_hlsl_source_info hlsl_info = {.type = VKD3D_SHADER_STRUCTURE_TYPE_HLSL_SOURCE_INFO};
|
||||
struct vkd3d_shader_compile_info info = {.type = VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO};
|
||||
struct vkd3d_shader_compile_option options[1];
|
||||
struct vkd3d_shader_code d3dbc;
|
||||
char *messages;
|
||||
int rc;
|
||||
|
||||
static const char ps_source[] =
|
||||
"float4 main(uniform float4 u) : color\n"
|
||||
"{\n"
|
||||
" float3 x = u;\n"
|
||||
" return 0;\n"
|
||||
"}\n";
|
||||
|
||||
hlsl_info.profile = "ps_2_0";
|
||||
|
||||
info.next = &hlsl_info;
|
||||
info.source.code = ps_source;
|
||||
info.source.size = ARRAY_SIZE(ps_source);
|
||||
info.source_type = VKD3D_SHADER_SOURCE_HLSL;
|
||||
info.target_type = VKD3D_SHADER_TARGET_D3D_BYTECODE;
|
||||
info.log_level = VKD3D_SHADER_LOG_INFO;
|
||||
|
||||
rc = vkd3d_shader_compile(&info, &d3dbc, &messages);
|
||||
ok(rc == VKD3D_OK, "Got rc %d.\n", rc);
|
||||
ok(messages, "Expected messages.\n");
|
||||
vkd3d_shader_free_shader_code(&d3dbc);
|
||||
vkd3d_shader_free_messages(messages);
|
||||
|
||||
info.options = options;
|
||||
info.option_count = ARRAY_SIZE(options);
|
||||
options[0].name = VKD3D_SHADER_COMPILE_OPTION_WARN_IMPLICIT_TRUNCATION;
|
||||
options[0].value = 0;
|
||||
|
||||
rc = vkd3d_shader_compile(&info, &d3dbc, &messages);
|
||||
ok(rc == VKD3D_OK, "Got rc %d.\n", rc);
|
||||
ok(!messages, "Expected no messages.\n");
|
||||
vkd3d_shader_free_shader_code(&d3dbc);
|
||||
vkd3d_shader_free_messages(messages);
|
||||
|
||||
options[0].value = 1;
|
||||
|
||||
rc = vkd3d_shader_compile(&info, &d3dbc, &messages);
|
||||
ok(rc == VKD3D_OK, "Got rc %d.\n", rc);
|
||||
ok(messages, "Expected messages.\n");
|
||||
vkd3d_shader_free_shader_code(&d3dbc);
|
||||
vkd3d_shader_free_messages(messages);
|
||||
}
|
||||
|
||||
START_TEST(vkd3d_shader_api)
|
||||
{
|
||||
setlocale(LC_ALL, "");
|
||||
@@ -1656,4 +1707,5 @@ START_TEST(vkd3d_shader_api)
|
||||
run_test(test_build_varying_map);
|
||||
run_test(test_scan_combined_resource_samplers);
|
||||
run_test(test_emit_signature);
|
||||
run_test(test_warning_options);
|
||||
}
|
||||
|
Reference in New Issue
Block a user