tests/hlsl: Add some arithmetic uint16 shader tests.

This commit is contained in:
Conor McCarthy 2025-01-18 00:35:05 +10:00 committed by Henri Verbeet
parent a5d4cbddac
commit 033a0d29c5
Notes: Henri Verbeet 2025-01-28 13:19:48 +01:00
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Giovanni Mascellani (@giomasce)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1344
5 changed files with 62 additions and 8 deletions

View File

@ -88,3 +88,42 @@ float4 main() : SV_TARGET
uniform 0 uint 7 uniform 0 uint 7
todo(msl) draw quad todo(msl) draw quad
probe (0, 0) rgba(38.0, 5.0, 7.0, 0.0) probe (0, 0) rgba(38.0, 5.0, 7.0, 0.0)
[require]
shader model >= 6.2
native-16-bit
[pixel shader]
uniform uint16_t2 u;
uint4 main() : sv_target
{
uint16_t i = 0x7fff, j = 0xffff;
return uint4(u.x + i, u.y + j, 0, 0);
}
[test]
uniform 0 uint4 0 0 0 0
draw quad
probe (0, 0) rgbaui(0x7fff, 0xffff, 0, 0)
uniform 0 uint4 0xffff0001 0 0 0
draw quad
probe (0, 0) rgbaui(0x8000, 0xfffe, 0, 0)
[pixel shader]
uniform uint16_t4 u;
uniform uint i;
uint4 main() : sv_target
{
uint16_t arr[4] = {1, 2, 0x7fff, 0xffff};
return uint4(u.x + arr[i], u.y + arr[i + 1], 0, 0);
}
[test]
uniform 0 uint4 0xfffe0002 0 2 0
draw quad
probe (0, 0) rgbaui(0x8001, 0xfffd, 0, 0)
uniform 0 uint4 0 0 0 0
draw quad
probe (0, 0) rgbaui(1, 2, 0, 0)

View File

@ -79,6 +79,7 @@ static const char *const model_strings[] =
[SHADER_MODEL_5_0] = "5.0", [SHADER_MODEL_5_0] = "5.0",
[SHADER_MODEL_5_1] = "5.1", [SHADER_MODEL_5_1] = "5.1",
[SHADER_MODEL_6_0] = "6.0", [SHADER_MODEL_6_0] = "6.0",
[SHADER_MODEL_6_2] = "6.2",
}; };
void fatal_error(const char *format, ...) void fatal_error(const char *format, ...)
@ -356,6 +357,7 @@ static const char *const shader_cap_strings[] =
[SHADER_CAP_FOG] = "fog", [SHADER_CAP_FOG] = "fog",
[SHADER_CAP_GEOMETRY_SHADER] = "geometry-shader", [SHADER_CAP_GEOMETRY_SHADER] = "geometry-shader",
[SHADER_CAP_INT64] = "int64", [SHADER_CAP_INT64] = "int64",
[SHADER_CAP_NATIVE_16_BIT] = "native-16-bit",
[SHADER_CAP_POINT_SIZE] = "point-size", [SHADER_CAP_POINT_SIZE] = "point-size",
[SHADER_CAP_ROV] = "rov", [SHADER_CAP_ROV] = "rov",
[SHADER_CAP_RT_VP_ARRAY_INDEX] = "rt-vp-array-index", [SHADER_CAP_RT_VP_ARRAY_INDEX] = "rt-vp-array-index",
@ -1613,7 +1615,7 @@ static HRESULT d3d10_blob_from_vkd3d_shader_code(const struct vkd3d_shader_code
} }
static HRESULT dxc_compiler_compile_shader(void *dxc_compiler, const char *profile, static HRESULT dxc_compiler_compile_shader(void *dxc_compiler, const char *profile,
unsigned int compile_options, const char *hlsl, ID3D10Blob **blob_out) unsigned int compile_options, bool enable_16bit_types, const char *hlsl, ID3D10Blob **blob_out)
{ {
struct vkd3d_shader_code blob; struct vkd3d_shader_code blob;
WCHAR wprofile[7]; WCHAR wprofile[7];
@ -1622,7 +1624,7 @@ static HRESULT dxc_compiler_compile_shader(void *dxc_compiler, const char *profi
*blob_out = NULL; *blob_out = NULL;
swprintf(wprofile, sizeof(wprofile), L"%hs", profile); swprintf(wprofile, sizeof(wprofile), L"%hs", profile);
if (FAILED(hr = dxc_compile(dxc_compiler, wprofile, compile_options, hlsl, &blob))) if (FAILED(hr = dxc_compile(dxc_compiler, wprofile, compile_options, enable_16bit_types, hlsl, &blob)))
return hr; return hr;
hr = d3d10_blob_from_vkd3d_shader_code(&blob, blob_out); hr = d3d10_blob_from_vkd3d_shader_code(&blob, blob_out);
@ -1648,6 +1650,7 @@ ID3D10Blob *compile_hlsl(const struct shader_runner *runner, enum shader_type ty
[SHADER_MODEL_5_0] = "5_0", [SHADER_MODEL_5_0] = "5_0",
[SHADER_MODEL_5_1] = "5_1", [SHADER_MODEL_5_1] = "5_1",
[SHADER_MODEL_6_0] = "6_0", [SHADER_MODEL_6_0] = "6_0",
[SHADER_MODEL_6_2] = "6_2",
}; };
/* Behaviour is inconsistent between different versions of /* Behaviour is inconsistent between different versions of
@ -1662,7 +1665,8 @@ ID3D10Blob *compile_hlsl(const struct shader_runner *runner, enum shader_type ty
if (runner->minimum_shader_model >= SHADER_MODEL_6_0) if (runner->minimum_shader_model >= SHADER_MODEL_6_0)
{ {
assert(runner->dxc_compiler); assert(runner->dxc_compiler);
hr = dxc_compiler_compile_shader(runner->dxc_compiler, profile, options, source, &blob); hr = dxc_compiler_compile_shader(runner->dxc_compiler, profile, options,
runner->require_shader_caps[SHADER_CAP_NATIVE_16_BIT], source, &blob);
} }
else else
{ {
@ -1700,6 +1704,7 @@ static void compile_shader(struct shader_runner *runner, const char *source,
[SHADER_MODEL_5_0] = "5_0", [SHADER_MODEL_5_0] = "5_0",
[SHADER_MODEL_5_1] = "5_1", [SHADER_MODEL_5_1] = "5_1",
[SHADER_MODEL_6_0] = "6_0", [SHADER_MODEL_6_0] = "6_0",
[SHADER_MODEL_6_2] = "6_2",
}; };
static const char *const effect_models[] = static const char *const effect_models[] =
@ -1732,7 +1737,8 @@ static void compile_shader(struct shader_runner *runner, const char *source,
if (use_dxcompiler) if (use_dxcompiler)
{ {
assert(runner->dxc_compiler); assert(runner->dxc_compiler);
hr = dxc_compiler_compile_shader(runner->dxc_compiler, profile, options, source, &blob); hr = dxc_compiler_compile_shader(runner->dxc_compiler, profile, options,
runner->require_shader_caps[SHADER_CAP_NATIVE_16_BIT], source, &blob);
} }
else else
{ {

View File

@ -39,7 +39,8 @@ enum shader_model
SHADER_MODEL_5_0, SHADER_MODEL_5_0,
SHADER_MODEL_5_1, SHADER_MODEL_5_1,
SHADER_MODEL_6_0, SHADER_MODEL_6_0,
SHADER_MODEL_MAX = SHADER_MODEL_6_0, SHADER_MODEL_6_2,
SHADER_MODEL_MAX = SHADER_MODEL_6_2,
}; };
enum shader_type enum shader_type
@ -146,6 +147,7 @@ enum shader_cap
SHADER_CAP_FOG, SHADER_CAP_FOG,
SHADER_CAP_GEOMETRY_SHADER, SHADER_CAP_GEOMETRY_SHADER,
SHADER_CAP_INT64, SHADER_CAP_INT64,
SHADER_CAP_NATIVE_16_BIT,
SHADER_CAP_POINT_SIZE, SHADER_CAP_POINT_SIZE,
SHADER_CAP_ROV, SHADER_CAP_ROV,
SHADER_CAP_RT_VP_ARRAY_INDEX, SHADER_CAP_RT_VP_ARRAY_INDEX,

View File

@ -988,6 +988,7 @@ static void d3d12_runner_init_caps(struct d3d12_shader_runner *runner,
enum shader_model minimum_shader_model, enum shader_model maximum_shader_model) enum shader_model minimum_shader_model, enum shader_model maximum_shader_model)
{ {
ID3D12Device *device = runner->test_context.device; ID3D12Device *device = runner->test_context.device;
D3D12_FEATURE_DATA_D3D12_OPTIONS4 options4;
D3D12_FEATURE_DATA_D3D12_OPTIONS2 options2; D3D12_FEATURE_DATA_D3D12_OPTIONS2 options2;
D3D12_FEATURE_DATA_D3D12_OPTIONS1 options1; D3D12_FEATURE_DATA_D3D12_OPTIONS1 options1;
D3D12_FEATURE_DATA_D3D12_OPTIONS options; D3D12_FEATURE_DATA_D3D12_OPTIONS options;
@ -1022,6 +1023,8 @@ static void d3d12_runner_init_caps(struct d3d12_shader_runner *runner,
ok(hr == S_OK, "Failed to check feature options1 support, hr %#x.\n", hr); ok(hr == S_OK, "Failed to check feature options1 support, hr %#x.\n", hr);
hr = ID3D12Device_CheckFeatureSupport(device, D3D12_FEATURE_D3D12_OPTIONS2, &options2, sizeof(options2)); hr = ID3D12Device_CheckFeatureSupport(device, D3D12_FEATURE_D3D12_OPTIONS2, &options2, sizeof(options2));
ok(hr == S_OK, "Failed to check feature options2 support, hr %#x.\n", hr); ok(hr == S_OK, "Failed to check feature options2 support, hr %#x.\n", hr);
hr = ID3D12Device_CheckFeatureSupport(device, D3D12_FEATURE_D3D12_OPTIONS4, &options4, sizeof(options4));
ok(hr == S_OK, "Failed to check feature options4 support, hr %#x.\n", hr);
#ifdef VKD3D_CROSSTEST #ifdef VKD3D_CROSSTEST
runner->caps.runner = "d3d12.dll"; runner->caps.runner = "d3d12.dll";
@ -1038,6 +1041,7 @@ static void d3d12_runner_init_caps(struct d3d12_shader_runner *runner,
runner->caps.shader_caps[SHADER_CAP_RT_VP_ARRAY_INDEX] runner->caps.shader_caps[SHADER_CAP_RT_VP_ARRAY_INDEX]
= options.VPAndRTArrayIndexFromAnyShaderFeedingRasterizerSupportedWithoutGSEmulation; = options.VPAndRTArrayIndexFromAnyShaderFeedingRasterizerSupportedWithoutGSEmulation;
runner->caps.shader_caps[SHADER_CAP_WAVE_OPS] = options1.WaveOps; runner->caps.shader_caps[SHADER_CAP_WAVE_OPS] = options1.WaveOps;
runner->caps.shader_caps[SHADER_CAP_NATIVE_16_BIT] = options4.Native16BitShaderOpsSupported;
runner->caps.tag_count = 0; runner->caps.tag_count = 0;
runner->caps.tags[runner->caps.tag_count++] = "d3d12"; runner->caps.tags[runner->caps.tag_count++] = "d3d12";
@ -1134,5 +1138,5 @@ void run_shader_tests_d3d12(void *dxc_compiler)
run_shader_tests_for_model_range(NULL, SHADER_MODEL_4_0, SHADER_MODEL_5_1); run_shader_tests_for_model_range(NULL, SHADER_MODEL_4_0, SHADER_MODEL_5_1);
if (dxc_compiler) if (dxc_compiler)
run_shader_tests_for_model_range(dxc_compiler, SHADER_MODEL_6_0, SHADER_MODEL_6_0); run_shader_tests_for_model_range(dxc_compiler, SHADER_MODEL_6_0, SHADER_MODEL_6_2);
} }

View File

@ -584,7 +584,7 @@ static inline HRESULT vkd3d_shader_code_from_dxc_blob(IDxcBlob *blob, struct vkd
} }
static inline HRESULT dxc_compile(void *dxc_compiler, const WCHAR *profile, static inline HRESULT dxc_compile(void *dxc_compiler, const WCHAR *profile,
unsigned int compile_options, const char *hlsl, struct vkd3d_shader_code *blob_out) unsigned int compile_options, bool enable_16bit_types, const char *hlsl, struct vkd3d_shader_code *blob_out)
{ {
DxcBuffer src_buf = {hlsl, strlen(hlsl), 65001}; DxcBuffer src_buf = {hlsl, strlen(hlsl), 65001};
IDxcCompiler3 *compiler = dxc_compiler; IDxcCompiler3 *compiler = dxc_compiler;
@ -606,17 +606,20 @@ static inline HRESULT dxc_compile(void *dxc_compiler, const WCHAR *profile,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL,
}; };
memset(blob_out, 0, sizeof(*blob_out)); memset(blob_out, 0, sizeof(*blob_out));
arg_count = ARRAY_SIZE(args) - 3; arg_count = ARRAY_SIZE(args) - 4;
if (compile_options & D3DCOMPILE_PACK_MATRIX_ROW_MAJOR) if (compile_options & D3DCOMPILE_PACK_MATRIX_ROW_MAJOR)
args[arg_count++] = L"/Zpr"; args[arg_count++] = L"/Zpr";
if (compile_options & D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR) if (compile_options & D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR)
args[arg_count++] = L"/Zpc"; args[arg_count++] = L"/Zpc";
if (compile_options & D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY) if (compile_options & D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY)
args[arg_count++] = L"/Gec"; args[arg_count++] = L"/Gec";
if (enable_16bit_types)
args[arg_count++] = L"/enable-16bit-types";
if (FAILED(hr = IDxcCompiler3_Compile(compiler, &src_buf, args, if (FAILED(hr = IDxcCompiler3_Compile(compiler, &src_buf, args,
arg_count, NULL, &IID_IDxcResult, (void **)&result))) arg_count, NULL, &IID_IDxcResult, (void **)&result)))