Goes atop MR 346, 400, 372, and 388. The last six commits belong to this MR.
-- v2: vkd3d-shader/dxil: Implement the DXIL EXTRACTVAL instruction. vkd3d-shader/dxil: Implement DX instruction CBufferLoadLegacy. vkd3d-shader/dxil: Implement DX instruction CreateHandle. vkd3d-shader/dxil: Read CBV descriptors. vkd3d-shader/spirv: Align constant buffer sizes to 16 bytes. vkd3d-shader/spirv: Support scalar swizzle of vector SSA registers. vkd3d-shader/dxil: Read DXIL compute shader thread group dimensions. vkd3d-shader/dxil: Read DXIL global flags. vkd3d-shader: Define more global flags. vkd3d-shader/dxil: Handle multi-row signature elements. vkd3d-shader/dxil: Handle signature element additional tag/value pairs. vkd3d-shader/dxil: Read the DXIL input and output signatures. vkd3d-shader/dxil: Validate the entry point info. vkd3d-shader/dxil: Read DXIL metadata named nodes. vkd3d-shader/dxil: Read DXIL metadata kinds. vkd3d-shader/dxil: Read DXIL metadata values. vkd3d-shader/dxil: Read DXIL metadata nodes. vkd3d-shader/dxil: Read DXIL metadata strings. vkd3d-shader/dxil: Emit an error on allocation failure in dxil_record_to_string(). vkd3d-shader/dxil: Read global constants in sm6_parser_globals_init(). vkd3d-shader/dxil: Read immediate constant arrays. tests/shader-runner: Test shaders with dxcompiler.
From: Conor McCarthy cmccarthy@codeweavers.com
Matching all possible combinations of keywords becomes too complex if more keywords are added. --- tests/shader_runner.c | 123 +++++++++++++++++++++--------------------- 1 file changed, 62 insertions(+), 61 deletions(-)
diff --git a/tests/shader_runner.c b/tests/shader_runner.c index 05edf5daf..8185df504 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -109,6 +109,24 @@ static bool match_string(const char *line, const char *token, const char **const return true; }
+static bool match_directive_substring(const char *line, const char *token, const char **const rest) +{ + size_t len = strlen(token); + + while (isspace(*line) || *line == ']') + ++line; + + if (strncmp(line, token, len) || !(isspace(line[len]) || line[len] == ']')) + return false; + if (rest) + { + *rest = line + len; + while (isspace(**rest)) + ++*rest; + } + return true; +} + static void parse_require_directive(struct shader_runner *runner, const char *line) { unsigned int i; @@ -809,6 +827,40 @@ static void compile_shader(struct shader_runner *runner, const char *source, siz } }
+static enum parse_state read_shader_directive(struct shader_runner *runner, enum parse_state state, const char *line, + const char *src, HRESULT *expect_hr) +{ + while (*src && *src != ']') + { + if (match_directive_substring(src, "todo", &src)) + { + if (state == STATE_SHADER_COMPUTE) + state = STATE_SHADER_COMPUTE_TODO; + else if (state == STATE_SHADER_PIXEL) + state = STATE_SHADER_PIXEL_TODO; + else + state = STATE_SHADER_VERTEX_TODO; + } + else if (match_directive_substring(src, "fail", &src)) + { + *expect_hr = E_FAIL; + } + else if (match_directive_substring(src, "notimpl", &src)) + { + *expect_hr = E_NOTIMPL; + } + else + { + fatal_error("Malformed line '%s'.\n", line); + } + } + + if (strcmp(src, "]\n")) + fatal_error("Malformed line '%s'.\n", line); + + return state; +} + void run_shader_tests(struct shader_runner *runner, const struct shader_runner_ops *ops) { size_t shader_source_size = 0, shader_source_len = 0; @@ -818,7 +870,7 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_o unsigned int i, line_number = 0; char *shader_source = NULL; HRESULT expect_hr = S_OK; - char line[256]; + char line_buffer[256]; FILE *f;
if (!test_options.filename) @@ -833,7 +885,8 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_o
for (;;) { - char *ret = fgets(line, sizeof(line), f); + char *ret = fgets(line_buffer, sizeof(line_buffer), f); + const char *line = line_buffer;
++line_number;
@@ -957,59 +1010,21 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_o { unsigned int index;
- if (!strcmp(line, "[compute shader]\n")) + if (match_directive_substring(line, "[compute shader", &line)) { state = STATE_SHADER_COMPUTE; expect_hr = S_OK; - } - else if (!strcmp(line, "[compute shader todo]\n")) - { - state = STATE_SHADER_COMPUTE_TODO; - expect_hr = S_OK; - } - else if (!strcmp(line, "[compute shader fail]\n")) - { - state = STATE_SHADER_COMPUTE; - expect_hr = E_FAIL; - } - else if (!strcmp(line, "[compute shader fail todo]\n")) - { - state = STATE_SHADER_COMPUTE_TODO; - expect_hr = E_FAIL; + state = read_shader_directive(runner, state, line_buffer, line, &expect_hr); } else if (!strcmp(line, "[require]\n")) { state = STATE_REQUIRE; } - else if (!strcmp(line, "[pixel shader]\n")) + else if (match_directive_substring(line, "[pixel shader", &line)) { state = STATE_SHADER_PIXEL; expect_hr = S_OK; - } - else if (!strcmp(line, "[pixel shader todo]\n")) - { - state = STATE_SHADER_PIXEL_TODO; - expect_hr = S_OK; - } - else if (!strcmp(line, "[pixel shader fail]\n")) - { - state = STATE_SHADER_PIXEL; - expect_hr = E_FAIL; - } - else if (!strcmp(line, "[pixel shader fail todo]\n")) - { - state = STATE_SHADER_PIXEL_TODO; - expect_hr = E_FAIL; - } - else if (!strcmp(line, "[pixel shader notimpl]\n")) - { - state = STATE_SHADER_PIXEL; - expect_hr = E_NOTIMPL; - } - else if (!strcmp(line, "[pixel shader notimpl todo]\n")) - { - state = STATE_SHADER_PIXEL_TODO; - expect_hr = E_NOTIMPL; + state = read_shader_directive(runner, state, line_buffer, line, &expect_hr); } else if (sscanf(line, "[sampler %u]\n", &index)) { @@ -1103,25 +1118,11 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_o { state = STATE_PREPROC_INVALID; } - else if (!strcmp(line, "[vertex shader]\n")) + else if (match_directive_substring(line, "[vertex shader", &line)) { state = STATE_SHADER_VERTEX; expect_hr = S_OK; - } - else if (!strcmp(line, "[vertex shader todo]\n")) - { - state = STATE_SHADER_VERTEX_TODO; - expect_hr = S_OK; - } - else if (!strcmp(line, "[vertex shader fail]\n")) - { - state = STATE_SHADER_VERTEX; - expect_hr = E_FAIL; - } - else if (!strcmp(line, "[vertex shader fail todo]\n")) - { - state = STATE_SHADER_VERTEX_TODO; - expect_hr = E_FAIL; + state = read_shader_directive(runner, state, line_buffer, line, &expect_hr); } else if (!strcmp(line, "[input layout]\n")) { @@ -1132,7 +1133,7 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_o runner->input_element_count = 0; }
- vkd3d_test_push_context("Section %.*s, line %u", strlen(line) - 1, line, line_number); + vkd3d_test_push_context("Section %.*s, line %u", strlen(line_buffer) - 1, line_buffer, line_number); } else if (line[0] != '%' && line[0] != '\n') {
From: Conor McCarthy cmccarthy@codeweavers.com
Tests are skipped until the next 'require' directive, which restores the defaults before the new requirements are read. --- tests/shader_runner.c | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-)
diff --git a/tests/shader_runner.c b/tests/shader_runner.c index 8185df504..87502f010 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -870,6 +870,7 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_o unsigned int i, line_number = 0; char *shader_source = NULL; HRESULT expect_hr = S_OK; + bool skip_tests = false; char line_buffer[256]; FILE *f;
@@ -903,8 +904,7 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_o case STATE_REQUIRE: if (runner->ops->check_requirements && !runner->ops->check_requirements(runner)) { - vkd3d_test_pop_context(); - goto out; + skip_tests = true; } break;
@@ -915,8 +915,11 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_o
case STATE_SHADER_COMPUTE: case STATE_SHADER_COMPUTE_TODO: - todo_if (state == STATE_SHADER_COMPUTE_TODO) - compile_shader(runner, shader_source, shader_source_len, "cs", expect_hr); + if (!skip_tests) + { + todo_if (state == STATE_SHADER_COMPUTE_TODO) + compile_shader(runner, shader_source, shader_source_len, "cs", expect_hr); + } free(runner->cs_source); runner->cs_source = shader_source; shader_source = NULL; @@ -926,8 +929,11 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_o
case STATE_SHADER_PIXEL: case STATE_SHADER_PIXEL_TODO: - todo_if (state == STATE_SHADER_PIXEL_TODO) - compile_shader(runner, shader_source, shader_source_len, "ps", expect_hr); + if (!skip_tests) + { + todo_if (state == STATE_SHADER_PIXEL_TODO) + compile_shader(runner, shader_source, shader_source_len, "ps", expect_hr); + } free(runner->ps_source); runner->ps_source = shader_source; shader_source = NULL; @@ -937,8 +943,11 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_o
case STATE_SHADER_VERTEX: case STATE_SHADER_VERTEX_TODO: - todo_if (state == STATE_SHADER_VERTEX_TODO) - compile_shader(runner, shader_source, shader_source_len, "vs", expect_hr); + if (!skip_tests) + { + todo_if (state == STATE_SHADER_VERTEX_TODO) + compile_shader(runner, shader_source, shader_source_len, "vs", expect_hr); + } free(runner->vs_source); runner->vs_source = shader_source; shader_source = NULL; @@ -951,6 +960,9 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_o ID3D10Blob *blob = NULL, *errors = NULL; HRESULT hr;
+ if (skip_tests) + break; + hr = D3DPreprocess(shader_source, strlen(shader_source), NULL, NULL, NULL, &blob, &errors); ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); ok(!blob, "Expected no compiled shader blob.\n"); @@ -974,6 +986,9 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_o HRESULT hr; char *text;
+ if (skip_tests) + break; + hr = D3DPreprocess(shader_source, strlen(shader_source), NULL, NULL, NULL, &blob, &errors); ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); if (hr == S_OK) @@ -1019,6 +1034,9 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_o else if (!strcmp(line, "[require]\n")) { state = STATE_REQUIRE; + runner->minimum_shader_model = SHADER_MODEL_2_0; + runner->compile_options = 0; + skip_tests = false; } else if (match_directive_substring(line, "[pixel shader", &line)) { @@ -1177,13 +1195,13 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_o break;
case STATE_TEST: - parse_test_directive(runner, line); + if (!skip_tests) + parse_test_directive(runner, line); break; } } }
-out: for (i = 0; i < runner->input_element_count; ++i) free(runner->input_elements[i].name); free(runner->input_elements);
From: Conor McCarthy cmccarthy@codeweavers.com
--- tests/shader_runner.c | 23 ++++++++++++++++++----- tests/shader_runner.h | 9 +++++++++ tests/shader_runner_d3d12.c | 10 +++++----- 3 files changed, 32 insertions(+), 10 deletions(-)
diff --git a/tests/shader_runner.c b/tests/shader_runner.c index 87502f010..bec08d7e7 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -790,7 +790,20 @@ static HRESULT map_unidentified_hrs(HRESULT hr) return hr; }
-static void compile_shader(struct shader_runner *runner, const char *source, size_t len, const char *type, HRESULT expect) +const char *shader_type_string(enum shader_type type) +{ + static const char *const shader_types[] = + { + [SHADER_TYPE_CS] = "cs", + [SHADER_TYPE_PS] = "ps", + [SHADER_TYPE_VS] = "vs", + }; + assert(type < ARRAY_SIZE(shader_types)); + return shader_types[type]; +} + +static void compile_shader(struct shader_runner *runner, const char *source, size_t len, enum shader_type type, + HRESULT expect) { ID3D10Blob *blob = NULL, *errors = NULL; char profile[7]; @@ -806,7 +819,7 @@ static void compile_shader(struct shader_runner *runner, const char *source, siz [SHADER_MODEL_5_1] = "5_1", };
- sprintf(profile, "%s_%s", type, shader_models[runner->minimum_shader_model]); + sprintf(profile, "%s_%s", shader_type_string(type), shader_models[runner->minimum_shader_model]); hr = D3DCompile(source, len, NULL, NULL, NULL, "main", profile, runner->compile_options, 0, &blob, &errors); hr = map_unidentified_hrs(hr); ok(hr == expect, "Got unexpected hr %#x.\n", hr); @@ -918,7 +931,7 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_o if (!skip_tests) { todo_if (state == STATE_SHADER_COMPUTE_TODO) - compile_shader(runner, shader_source, shader_source_len, "cs", expect_hr); + compile_shader(runner, shader_source, shader_source_len, SHADER_TYPE_CS, expect_hr); } free(runner->cs_source); runner->cs_source = shader_source; @@ -932,7 +945,7 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_o if (!skip_tests) { todo_if (state == STATE_SHADER_PIXEL_TODO) - compile_shader(runner, shader_source, shader_source_len, "ps", expect_hr); + compile_shader(runner, shader_source, shader_source_len, SHADER_TYPE_PS, expect_hr); } free(runner->ps_source); runner->ps_source = shader_source; @@ -946,7 +959,7 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_o if (!skip_tests) { todo_if (state == STATE_SHADER_VERTEX_TODO) - compile_shader(runner, shader_source, shader_source_len, "vs", expect_hr); + compile_shader(runner, shader_source, shader_source_len, SHADER_TYPE_VS, expect_hr); } free(runner->vs_source); runner->vs_source = shader_source; diff --git a/tests/shader_runner.h b/tests/shader_runner.h index 0844943da..6591143e6 100644 --- a/tests/shader_runner.h +++ b/tests/shader_runner.h @@ -38,6 +38,15 @@ enum shader_model SHADER_MODEL_5_1, };
+enum shader_type +{ + SHADER_TYPE_CS, + SHADER_TYPE_PS, + SHADER_TYPE_VS, +}; + +const char *shader_type_string(enum shader_type type); + enum texture_data_type { TEXTURE_DATA_FLOAT, diff --git a/tests/shader_runner_d3d12.c b/tests/shader_runner_d3d12.c index d620f1e2d..925bdca99 100644 --- a/tests/shader_runner_d3d12.c +++ b/tests/shader_runner_d3d12.c @@ -56,7 +56,7 @@ static struct d3d12_shader_runner *d3d12_shader_runner(struct shader_runner *r) return CONTAINING_RECORD(r, struct d3d12_shader_runner, r); }
-static ID3D10Blob *compile_shader(const struct d3d12_shader_runner *runner, const char *source, const char *type) +static ID3D10Blob *compile_shader(const struct d3d12_shader_runner *runner, const char *source, enum shader_type type) { ID3D10Blob *blob = NULL, *errors = NULL; char profile[7]; @@ -72,7 +72,7 @@ static ID3D10Blob *compile_shader(const struct d3d12_shader_runner *runner, cons [SHADER_MODEL_5_1] = "5_1", };
- sprintf(profile, "%s_%s", type, shader_models[runner->r.minimum_shader_model]); + sprintf(profile, "%s_%s", shader_type_string(type), shader_models[runner->r.minimum_shader_model]); hr = D3DCompile(source, strlen(source), NULL, NULL, NULL, "main", profile, runner->r.compile_options, 0, &blob, &errors); ok(FAILED(hr) == !blob, "Got unexpected hr %#x, blob %p.\n", hr, blob); if (errors) @@ -310,7 +310,7 @@ static bool d3d12_runner_dispatch(struct shader_runner *r, unsigned int x, unsig HRESULT hr; size_t i;
- cs_code = compile_shader(runner, runner->r.cs_source, "cs"); + cs_code = compile_shader(runner, runner->r.cs_source, SHADER_TYPE_CS); todo_if (runner->r.is_todo) ok(cs_code, "Failed to compile shader.\n"); if (!cs_code) return false; @@ -385,8 +385,8 @@ static bool d3d12_runner_draw(struct shader_runner *r, HRESULT hr; size_t i;
- ps_code = compile_shader(runner, runner->r.ps_source, "ps"); - vs_code = compile_shader(runner, runner->r.vs_source, "vs"); + ps_code = compile_shader(runner, runner->r.ps_source, SHADER_TYPE_PS); + vs_code = compile_shader(runner, runner->r.vs_source, SHADER_TYPE_VS); todo_if (runner->r.is_todo) ok(ps_code && vs_code, "Failed to compile shaders.\n");
if (!ps_code || !vs_code)
From: Conor McCarthy cmccarthy@codeweavers.com
The location of dxcompiler should be set during configuration with 'DXCOMPILER_LIBS=-L/path/to/dxcompiler', and then at runtime with LD_LIBRARY_PATH, WINEPATH or PATH as applicable.
A new 'fail(sm<6)' decoration is needed on many shader declarations because dxcompiler succeeds on many shaders which fail with fxc. The opposite case is less common and is flagged with 'fail(sm>=6)'. A few tests cause dxcompiler to crash or hang, so these are avoided using [require], which now skips tests until reset instead of exiting. Also, 'todo(sm<6)' and 'todo(sm>=6)' are used to separate checking of results. --- Makefile.am | 10 +- README | 10 + configure.ac | 7 + tests/dxcompiler.idl | 168 ++++++++++++ tests/hlsl/abs.shader_test | 8 +- tests/hlsl/all.shader_test | 14 +- tests/hlsl/any.shader_test | 36 +-- .../hlsl/arithmetic-float-uniform.shader_test | 12 +- tests/hlsl/arithmetic-float.shader_test | 2 +- tests/hlsl/arithmetic-int-uniform.shader_test | 16 +- tests/hlsl/arithmetic-int.shader_test | 17 +- tests/hlsl/arithmetic-uint.shader_test | 12 +- tests/hlsl/array-dimension.shader_test | 7 +- tests/hlsl/array-index-expr.shader_test | 16 +- tests/hlsl/array-parameters.shader_test | 2 +- tests/hlsl/array-size-expr.shader_test | 2 +- tests/hlsl/asfloat.shader_test | 16 +- tests/hlsl/asuint.shader_test | 14 +- tests/hlsl/attributes.shader_test | 20 +- tests/hlsl/bool-cast.shader_test | 4 +- tests/hlsl/bool-semantics.shader_test | 2 +- .../cast-componentwise-compatible.shader_test | 14 +- .../hlsl/cast-componentwise-equal.shader_test | 10 +- tests/hlsl/cast-to-float.shader_test | 9 +- tests/hlsl/cast-to-half.shader_test | 8 +- tests/hlsl/cast-to-int.shader_test | 8 +- tests/hlsl/cast-to-uint.shader_test | 8 +- tests/hlsl/cbuffer.shader_test | 56 ++-- tests/hlsl/clamp.shader_test | 6 +- tests/hlsl/clip.shader_test | 8 +- tests/hlsl/combined-samplers.shader_test | 3 + tests/hlsl/compute.shader_test | 2 +- tests/hlsl/conditional.shader_test | 26 +- tests/hlsl/const.shader_test | 4 +- tests/hlsl/cross.shader_test | 13 +- tests/hlsl/d3dcolor-to-ubyte4.shader_test | 12 +- tests/hlsl/ddxddy.shader_test | 8 +- tests/hlsl/discard.shader_test | 4 +- tests/hlsl/distance.shader_test | 2 +- tests/hlsl/dot.shader_test | 10 +- tests/hlsl/duplicate-modifiers.shader_test | 4 + tests/hlsl/entry-point-semantics.shader_test | 22 +- tests/hlsl/exp.shader_test | 4 +- tests/hlsl/expr-indexing.shader_test | 14 +- tests/hlsl/floor.shader_test | 18 +- tests/hlsl/fmod.shader_test | 16 +- tests/hlsl/for.shader_test | 4 +- tests/hlsl/frac.shader_test | 2 +- tests/hlsl/function-cast.shader_test | 9 +- tests/hlsl/function-overload.shader_test | 2 +- tests/hlsl/function-return.shader_test | 24 +- tests/hlsl/function.shader_test | 8 +- tests/hlsl/fwidth.shader_test | 2 +- tests/hlsl/gather-offset.shader_test | 12 +- tests/hlsl/gather.shader_test | 12 +- tests/hlsl/getdimensions.shader_test | 4 +- .../initializer-implicit-array.shader_test | 55 ++-- tests/hlsl/initializer-objects.shader_test | 4 +- tests/hlsl/intrinsic-override.shader_test | 24 +- tests/hlsl/invalid.shader_test | 12 +- tests/hlsl/is-front-face.shader_test | 4 +- tests/hlsl/ldexp.shader_test | 4 +- tests/hlsl/length.shader_test | 10 +- tests/hlsl/lerp.shader_test | 4 +- tests/hlsl/lit.shader_test | 37 ++- tests/hlsl/load-level.shader_test | 6 +- tests/hlsl/log.shader_test | 6 +- tests/hlsl/loop.shader_test | 8 +- tests/hlsl/majority-pragma.shader_test | 30 +- tests/hlsl/majority-syntax.shader_test | 4 +- tests/hlsl/majority-typedef.shader_test | 2 +- tests/hlsl/math.shader_test | 7 +- tests/hlsl/matrix-indexing.shader_test | 10 +- tests/hlsl/matrix-semantics.shader_test | 16 +- tests/hlsl/max.shader_test | 12 +- tests/hlsl/nested-arrays.shader_test | 4 +- tests/hlsl/nointerpolation.shader_test | 10 +- tests/hlsl/normalize.shader_test | 10 +- tests/hlsl/numeric-types.shader_test | 6 +- tests/hlsl/numthreads.shader_test | 10 +- tests/hlsl/object-field-offsets.shader_test | 6 +- tests/hlsl/object-parameters.shader_test | 18 +- tests/hlsl/object-references.shader_test | 18 +- tests/hlsl/pow.shader_test | 6 +- tests/hlsl/reflect.shader_test | 12 +- tests/hlsl/register-reservations.shader_test | 22 +- .../return-implicit-conversion.shader_test | 2 +- tests/hlsl/return.shader_test | 34 +-- tests/hlsl/round.shader_test | 18 +- tests/hlsl/sample-bias.shader_test | 6 +- tests/hlsl/sample-grad.shader_test | 6 +- tests/hlsl/sample-level.shader_test | 6 +- tests/hlsl/sampler-offset.shader_test | 6 +- tests/hlsl/sampler.shader_test | 8 +- tests/hlsl/saturate.shader_test | 12 +- .../shader-interstage-interface.shader_test | 2 +- tests/hlsl/side-effects.shader_test | 5 + tests/hlsl/sign.shader_test | 20 +- tests/hlsl/smoothstep.shader_test | 2 +- tests/hlsl/sqrt.shader_test | 4 +- tests/hlsl/state-block-syntax.shader_test | 20 +- tests/hlsl/static-initializer.shader_test | 6 +- tests/hlsl/step.shader_test | 2 +- tests/hlsl/storage-qualifiers.shader_test | 29 +- tests/hlsl/struct-array.shader_test | 2 +- tests/hlsl/swizzle-constant-prop.shader_test | 6 +- tests/hlsl/swizzle-matrix.shader_test | 6 +- tests/hlsl/swizzles.shader_test | 6 +- tests/hlsl/ternary.shader_test | 10 +- tests/hlsl/texture-load-offset.shader_test | 4 +- tests/hlsl/texture-load-typed.shader_test | 17 ++ tests/hlsl/texture-load.shader_test | 6 +- tests/hlsl/texture-ordering.shader_test | 3 + tests/hlsl/trigonometry.shader_test | 8 +- tests/hlsl/trunc.shader_test | 20 +- tests/hlsl/type-names.shader_test | 6 +- tests/hlsl/uav-load.shader_test | 2 +- tests/hlsl/uav-out-param.shader_test | 4 +- tests/hlsl/uav-rwbuffer.shader_test | 8 +- tests/hlsl/uav-rwstructuredbuffer.shader_test | 2 +- tests/hlsl/uav-rwtexture.shader_test | 22 +- tests/hlsl/uniform-parameters.shader_test | 36 +++ tests/hlsl/uniform-semantics.shader_test | 4 +- .../hlsl/vector-indexing-uniform.shader_test | 2 +- tests/hlsl/vector-indexing.shader_test | 4 +- tests/hlsl/writemask-assignop-0.shader_test | 2 +- tests/hlsl/writemask-assignop-1.shader_test | 2 +- tests/shader_runner.c | 257 ++++++++++++++++-- tests/shader_runner.h | 10 +- tests/shader_runner_d3d11.c | 2 +- tests/shader_runner_d3d12.c | 42 ++- tests/shader_runner_d3d9.c | 2 +- tests/shader_runner_vulkan.c | 2 +- 133 files changed, 1269 insertions(+), 556 deletions(-) create mode 100644 tests/dxcompiler.idl create mode 100644 tests/hlsl/uniform-parameters.shader_test
diff --git a/Makefile.am b/Makefile.am index 11df76ad7..8364aaa37 100644 --- a/Makefile.am +++ b/Makefile.am @@ -14,7 +14,8 @@ widl_headers = \ include/vkd3d_dxgi1_4.h \ include/vkd3d_dxgibase.h \ include/vkd3d_dxgiformat.h \ - include/vkd3d_dxgitype.h + include/vkd3d_dxgitype.h \ + tests/dxcompiler.h
vkd3d_public_headers = \ include/vkd3d.h \ @@ -181,6 +182,7 @@ vkd3d_shader_tests = \ tests/hlsl/uav-rwbuffer.shader_test \ tests/hlsl/uav-rwstructuredbuffer.shader_test \ tests/hlsl/uav-rwtexture.shader_test \ + tests/hlsl/uniform-parameters.shader_test \ tests/hlsl/uniform-semantics.shader_test \ tests/hlsl/vector-indexing-uniform.shader_test \ tests/hlsl/vector-indexing.shader_test \ @@ -198,6 +200,7 @@ vkd3d_shader_tests = \ vkd3d_test_headers = \ tests/d3d12_crosstest.h \ tests/d3d12_test_utils.h \ + tests/dxcompiler.h \ tests/shader_runner.h \ tests/utils.h \ tests/vulkan_procs.h @@ -380,6 +383,7 @@ tests_d3d12_LDADD = $(LDADD) @PTHREAD_LIBS@ @DL_LIBS@ tests_d3d12_invalid_usage_LDADD = $(LDADD) @DL_LIBS@ tests_hlsl_d3d12_LDADD = $(LDADD) @DL_LIBS@ tests_shader_runner_LDADD = $(LDADD) @DL_LIBS@ +tests_shader_runner_CFLAGS = $(AM_CFLAGS) -I$(builddir)/tests tests_shader_runner_SOURCES = \ tests/shader_runner.c \ tests/shader_runner_d3d9.c \ @@ -420,7 +424,7 @@ endif EXTRA_DIST += $(widl_headers) $(widl_headers:.h=.idl) $(widl_headers): %.h: %.idl if HAVE_WIDL - $(VKD3D_V_WIDL)$(WIDL) -h -o $@ $< + $(VKD3D_V_WIDL)$(WIDL) -I$(srcdir)/include -h -o $@ $< else @echo "widl is required to generate $@" endif @@ -464,7 +468,7 @@ dummy-vkd3d-version:
## Cross-compile tests cross_implibs = crosslibs/d3d12 -CROSS_CPPFLAGS = -I$(srcdir)/include -I$(srcdir)/include/private -I$(builddir)/include +CROSS_CPPFLAGS = -I$(srcdir)/include -I$(srcdir)/include/private -I$(builddir)/include -I$(builddir)/tests CROSS_CFLAGS = -g -O2 -Wall -municode ${CROSS_CPPFLAGS} -D__USE_MINGW_ANSI_STDIO=0 -DVKD3D_CROSSTEST=1 EXTRA_DIST += $(cross_implibs:=.cross32.def) $(cross_implibs:=.cross64.def) EXTRA_DIST += tests/shader_runner_d3d11.c tests/shader_runner_d3d9.c diff --git a/README b/README index cb9d66156..664a28670 100644 --- a/README +++ b/README @@ -83,6 +83,16 @@ commas or semicolons.
* VKD3D_TEST_BUG - set to 0 to disable bug_if() conditions in tests.
+If the configuration defines 'DXCOMPILER_LIBS=-L/path/to/dxcompiler', Shader +Runner attempts to load libdxcompiler.so or dxcompiler.dll to compile test +shaders in Shader Model 6. LD_LIBRARY_PATH (linux), WINEPATH (wine) or PATH +(native windows) should include the location of dxcompiler if SM 6 shader +tests are desired. If dxcompiler is not found, Shader Runner will compile the +test shaders only in earlier shader models. The DXC source does not contain +code for adding DXBC checksums, so the official release should be installed +from: +https://github.com/microsoft/DirectXShaderCompiler/releases + ================ Developing vkd3d ================ diff --git a/configure.ac b/configure.ac index 07eeabbfc..3f6e6b789 100644 --- a/configure.ac +++ b/configure.ac @@ -120,6 +120,12 @@ AS_IF([test "x$SONAME_LIBVULKAN" = "x"], [VKD3D_CHECK_VULKAN], [AC_DEFINE_UNQUOTED([SONAME_LIBVULKAN],["$SONAME_LIBVULKAN"],[Define to the shared object name of the Vulkan library.])])
+AC_ARG_VAR([SONAME_LIBDXCOMPILER], [shared object name for the dxcompiler library]) +AC_ARG_VAR([DXCOMPILER_LIBS], [linker flags for the dxcompiler library]) +AS_IF([test "x$SONAME_LIBDXCOMPILER" = "x"], + [VKD3D_CHECK_SONAME([dxcompiler], [DxcCreateInstance], [HAVE_DXCOMPILER=yes], [HAVE_DXCOMPILER=no], [$DXCOMPILER_LIBS])], + [AC_DEFINE_UNQUOTED([SONAME_LIBDXCOMPILER],["$SONAME_LIBDXCOMPILER"],[Define to the shared object name of the dxcompiler library.])]) + AS_IF([test "x$with_ncurses" != "xno"], [PKG_CHECK_MODULES([NCURSES], [ncurses], [AC_DEFINE([HAVE_NCURSES], [1], [Define to 1 if you have ncurses.]) with_ncurses=yes], @@ -183,6 +189,7 @@ AS_ECHO([" Have ncurses: ${with_ncurses} Have SPIRV-Tools: ${with_spirv_tools} Have xcb: ${HAVE_XCB} + Have dxcompiler: ${HAVE_DXCOMPILER}
Building demos: ${enable_demos} Building tests: ${enable_tests} diff --git a/tests/dxcompiler.idl b/tests/dxcompiler.idl new file mode 100644 index 000000000..17f8f5bd9 --- /dev/null +++ b/tests/dxcompiler.idl @@ -0,0 +1,168 @@ +/* + * Copyright 2023 Conor McCarthy for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +import "vkd3d_windows.h"; + +#include "vkd3d_unknown.idl" + +/* The linux build of dxcompiler does not apply the ms_abi calling convention to its COM interfaces, + * so they default to sysv_abi. The '__stdcall' macro is set in vkd3d_windows.h to ms_abi, and widl + * emits STDMETHODCALLTYPE for COM interfaces, so '__stdcall' must be temporarily undefined. Doing + * this in a PE build (x86 or x64) is unnecessary since the default calling convention is identical. + * A 32-bit linux release of dxcompiler is not available. + * TODO: modily widl to optionally omit STDMETHODCALLTYPE? */ +cpp_quote("#if defined(__x86_64__) && !defined(_WIN32)") +cpp_quote("# pragma push_macro("__stdcall")") +cpp_quote("# undef __stdcall") +cpp_quote("# define __stdcall") +cpp_quote("#endif") + +static const HRESULT DXC_E_LLVM_CAST_ERROR = 0x80aa001d; + +[ + uuid(73e22d93-e6ce-47f3-b5bf-f0664f39c1b0) +] +coclass DxcCompiler +{ +} + +[ + uuid(8ba5fb08-5195-40e2-ac58-0d989c3a0102), + object, + local, +] +interface IDxcBlob : IUnknown +{ + void *GetBufferPointer(); + SIZE_T GetBufferSize(); +} + +[ + uuid(7241d424-2646-4191-97c0-98e96e42fc68), + object, + local, +] +interface IDxcBlobEncoding : IDxcBlob +{ + HRESULT GetEncoding(BOOL *known, UINT32 *code_page); +} + +[ + uuid(3da636c9-ba71-4024-a301-30cbf125305b), + object, + local, +] +interface IDxcBlobUtf8 : IDxcBlobEncoding +{ + const char *GetStringPointer(); + SIZE_T GetStringLength(); +} + +[ + uuid(a3f84eab-0faa-497e-a39c-ee6ed60b2d84), + object, + local, +] +interface IDxcBlobUtf16 : IDxcBlobEncoding +{ + const WCHAR *GetStringPointer(); + SIZE_T GetStringLength(); +} + +[ + uuid(7f61fc7d-950d-467f-b3e3-3c02fb49187c), + object, + local, +] +interface IDxcIncludeHandler : IUnknown +{ + HRESULT LoadSource(const WCHAR *filename, IDxcBlob **include_source); +} + +typedef struct DxcBuffer +{ + const void *Ptr; + SIZE_T Size; + UINT Encoding; +} DxcBuffer; + +[ + uuid(cedb484a-d4e9-445a-b991-ca21ca157dc2), + object, + local, +] +interface IDxcOperationResult : IUnknown +{ + HRESULT GetStatus(HRESULT *status); + + HRESULT GetResult(IDxcBlob **result); + + HRESULT GetErrorBuffer(IDxcBlobEncoding **errors); +} + +typedef enum DXC_OUT_KIND +{ + DXC_OUT_NONE = 0, + DXC_OUT_OBJECT = 1, + DXC_OUT_ERRORS = 2, + DXC_OUT_PDB = 3, + DXC_OUT_SHADER_HASH = 4, + DXC_OUT_DISASSEMBLY = 5, + DXC_OUT_HLSL = 6, + DXC_OUT_TEXT = 7, + DXC_OUT_REFLECTION = 8, + DXC_OUT_ROOT_SIGNATURE = 9, + DXC_OUT_EXTRA_OUTPUTS = 10, + + DXC_OUT_FORCE_DWORD = 0xFFFFFFFF +} DXC_OUT_KIND; + +[ + uuid(58346cda-dde7-4497-9461-6f87af5e0659), + object, + local, +] +interface IDxcResult : IDxcOperationResult +{ + BOOL HasOutput(DXC_OUT_KIND dxc_out_kind); + HRESULT GetOutput(DXC_OUT_KIND dxc_out_kind, + REFIID iid, void **object, IDxcBlobUtf16 **output_name); + + UINT32 GetNumOutputs(); + DXC_OUT_KIND GetOutputByIndex(UINT32 index); + DXC_OUT_KIND PrimaryOutput(); +} + +[ + uuid(228b4687-5a6a-4730-900c-9702b2203f54), + object, + local, +] +interface IDxcCompiler3 : IUnknown +{ + HRESULT Compile(const DxcBuffer *source, const WCHAR **arguments, UINT32 arg_count, + IDxcIncludeHandler *include_handler, REFIID riid, void **result); + + HRESULT Disassemble(const DxcBuffer *object, REFIID riid, void **result); +} + +typedef HRESULT (__stdcall *DxcCreateInstanceProc)(const IID *rclsid, REFIID riid, void **ppv); + +cpp_quote("#if defined(__x86_64__) && !defined(_WIN32)") +cpp_quote("# pragma pop_macro("__stdcall")") +cpp_quote("#endif") diff --git a/tests/hlsl/abs.shader_test b/tests/hlsl/abs.shader_test index 6fa6d1ca7..738e69312 100644 --- a/tests/hlsl/abs.shader_test +++ b/tests/hlsl/abs.shader_test @@ -1,13 +1,15 @@ [pixel shader] -float4 main(uniform float2 u) : sv_target +uniform float2 u; + +float4 main() : sv_target { return float4(abs(u), abs(u.x - 0.5), abs(-0.4)); }
[test] uniform 0 float4 0.1 0.7 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.1, 0.7, 0.4, 0.4) uniform 0 float4 -0.7 0.1 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.7, 0.1, 1.2, 0.4) diff --git a/tests/hlsl/all.shader_test b/tests/hlsl/all.shader_test index 7bdb0dc82..564cc5b00 100644 --- a/tests/hlsl/all.shader_test +++ b/tests/hlsl/all.shader_test @@ -11,17 +11,17 @@ float4 main() : sv_target
[test] uniform 0 float4 -1.1 1.6 1.3 0.5 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0)
[test] uniform 0 float4 0.0 1.6 1.3 0.5 -draw quad +todo(sm>=6) draw quad probe all rgba (0.0, 0.0, 0.0, 0.0)
[test] uniform 0 float4 1.0 0.0 1.3 0.5 -draw quad +todo(sm>=6) draw quad probe all rgba (0.0, 0.0, 0.0, 0.0)
[pixel shader] @@ -34,12 +34,12 @@ float4 main() : sv_target
[test] uniform 0 float4 1.0 0.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0)
[test] uniform 0 float4 0.0 0.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.0, 0.0, 0.0, 0.0)
[pixel shader] @@ -53,11 +53,11 @@ float4 main() : sv_target [test] uniform 0 float4 1.0 2.0 0.0 0.0 uniform 4 float4 3.0 4.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0)
[test] uniform 0 float4 1.0 2.0 0.0 0.0 uniform 4 float4 0.0 4.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.0, 0.0, 0.0, 0.0) diff --git a/tests/hlsl/any.shader_test b/tests/hlsl/any.shader_test index f2298d3a3..9b8b922c9 100644 --- a/tests/hlsl/any.shader_test +++ b/tests/hlsl/any.shader_test @@ -8,25 +8,25 @@ float4 main() : sv_target
[test] uniform 0 float4 1.0 1.0 1.0 1.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0) uniform 0 float4 1.0 0.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0) uniform 0 float4 0.0 1.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0) uniform 0 float4 0.0 0.0 1.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0) uniform 0 float4 0.0 0.0 0.0 1.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0) uniform 0 float4 0.0 0.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.0, 0.0, 0.0, 0.0) uniform 0 float4 -1.0 -1.0 -1.0 -1.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0)
[pixel shader] @@ -39,13 +39,13 @@ float4 main() : sv_target
[test] uniform 0 float4 1.0 0.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0) uniform 0 float4 0.0 0.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.0, 0.0, 0.0, 0.0) uniform 0 float4 -1.0 0.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0)
[require] @@ -61,22 +61,22 @@ float4 main() : sv_target
[test] uniform 0 uint4 1 1 1 1 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0) uniform 0 uint4 1 0 0 0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0) uniform 0 uint4 0 1 0 0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0) uniform 0 uint4 0 0 1 0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0) uniform 0 uint4 0 0 0 1 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0) uniform 0 uint4 0 0 0 0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.0, 0.0, 0.0, 0.0)
[pixel shader] @@ -89,8 +89,8 @@ float4 main() : sv_target
[test] uniform 0 uint4 1 0 0 0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0) uniform 0 uint4 0 0 0 0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.0, 0.0, 0.0, 0.0) diff --git a/tests/hlsl/arithmetic-float-uniform.shader_test b/tests/hlsl/arithmetic-float-uniform.shader_test index f022ac79f..8aaca621a 100644 --- a/tests/hlsl/arithmetic-float-uniform.shader_test +++ b/tests/hlsl/arithmetic-float-uniform.shader_test @@ -10,7 +10,7 @@ float4 main() : SV_TARGET
[test] uniform 0 float4 5.0 15.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (20.0, -10.0, 75.0, 0.33333333) 1
[pixel shader] @@ -25,7 +25,7 @@ float4 main() : SV_TARGET
[test] uniform 0 float4 5.0 15.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (5.0, 5.0, -5.0, 3.0) 1
[pixel shader] @@ -40,7 +40,7 @@ float4 main() : SV_TARGET
[test] uniform 0 float4 42.0 5.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (2.0, -2.0, 2.0, -2.0) 16
[pixel shader] @@ -55,7 +55,7 @@ float4 main() : SV_TARGET
[test] uniform 0 float4 45.0 5.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.0, 0.0, 0.0, 0.0)
[pixel shader] @@ -69,7 +69,7 @@ float4 main() : sv_target [test] uniform 0 float4 5.0 -42.1 4.0 45.0 uniform 4 float4 15.0 -5.0 4.1 5.0 -draw quad +todo(sm>=6) draw quad probe all rgba (5.0, -2.1, 4.0, 0.0) 4
[require] @@ -88,5 +88,5 @@ float4 main() : SV_TARGET
[test] uniform 0 float4 1.0 0.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1e99, 1e99, 1e99, 1e99) diff --git a/tests/hlsl/arithmetic-float.shader_test b/tests/hlsl/arithmetic-float.shader_test index 73bd627c0..71835082c 100644 --- a/tests/hlsl/arithmetic-float.shader_test +++ b/tests/hlsl/arithmetic-float.shader_test @@ -61,7 +61,7 @@ float4 main() : sv_target
[test] draw quad -probe all rgba (5.0, -2.1, 4.0, 0.0) 4 +probe all rgba (5.0, -2.1, 4.0, 0.0) 6
[require] % Infinities are not allowed in SM1 diff --git a/tests/hlsl/arithmetic-int-uniform.shader_test b/tests/hlsl/arithmetic-int-uniform.shader_test index b2bf720fc..726a191a7 100644 --- a/tests/hlsl/arithmetic-int-uniform.shader_test +++ b/tests/hlsl/arithmetic-int-uniform.shader_test @@ -10,7 +10,7 @@ float4 main() : SV_TARGET
[test] uniform 0 float4 5.0 16.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (21.0, -11.0, 80.0, 0.0)
[pixel shader] @@ -25,7 +25,7 @@ float4 main() : SV_TARGET
[test] uniform 0 float4 5.0 16.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (5.0, 5.0, -5.0, 3.0)
[pixel shader] @@ -40,7 +40,7 @@ float4 main() : SV_TARGET
[test] uniform 0 float4 42.0 5.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (8.0, -8.0, -8.0, 8.0)
[pixel shader] @@ -55,7 +55,7 @@ float4 main() : SV_TARGET
[test] uniform 0 float4 42.0 5.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (2.0, -2.0, 2.0, -2.0)
[pixel shader] @@ -70,7 +70,7 @@ float4 main() : SV_TARGET
[test] uniform 0 float4 45.0 5.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (9.0, -9.0, -9.0, 9.0)
[pixel shader] @@ -85,7 +85,7 @@ float4 main() : SV_TARGET
[test] uniform 0 float4 45.0 5.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.0, 0.0, 0.0, 0.0)
[pixel shader] @@ -98,7 +98,7 @@ float4 main() : SV_TARGET
[test] uniform 0 float4 5.0 -7.0 0.0 -10.0 -draw quad +todo(sm>=6) draw quad probe all rgba (5.0, 7.0, 0.0, 10.0)
[pixel shader] @@ -117,5 +117,5 @@ float4 main() : sv_target [test] uniform 0 float4 45.0 5.0 50.0 10.0 uniform 4 float4 3.0 8.0 2.0 5.0 -draw quad +todo(sm>=6) draw quad probe all rgba (9.0, 5.0, 1.0, 3.0) diff --git a/tests/hlsl/arithmetic-int.shader_test b/tests/hlsl/arithmetic-int.shader_test index c97022099..f2044c42c 100644 --- a/tests/hlsl/arithmetic-int.shader_test +++ b/tests/hlsl/arithmetic-int.shader_test @@ -76,7 +76,7 @@ float4 main() : SV_TARGET draw quad probe all rgba (0.0, 0.0, 0.0, 0.0)
-[pixel shader fail] +[pixel shader fail(sm<6)] float4 main() : SV_TARGET { int x = 1; @@ -85,7 +85,11 @@ float4 main() : SV_TARGET return x / y; }
-[pixel shader fail] +[test] +draw quad +probe all rgba (0.0, 0.0, 0.0, 0.0) + +[pixel shader fail(sm<6)] float4 main() : SV_TARGET { int x = 1; @@ -94,8 +98,14 @@ float4 main() : SV_TARGET return x % y; }
+[test] +draw quad +probe all rgba (0.0, 0.0, 0.0, 0.0) + [require] shader model >= 4.0 +% dxcompiler performs this calculation on unsigned values and emits zero. +shader model < 6.0
[pixel shader] float4 main() : SV_TARGET @@ -110,6 +120,9 @@ float4 main() : SV_TARGET draw quad probe all rgba (-2147483648.0, -2147483648.0, -2147483648.0, -2147483648.0)
+[require] +shader model >= 4.0 + [pixel shader] float4 main() : sv_target { diff --git a/tests/hlsl/arithmetic-uint.shader_test b/tests/hlsl/arithmetic-uint.shader_test index f1801b9c2..c245d447d 100644 --- a/tests/hlsl/arithmetic-uint.shader_test +++ b/tests/hlsl/arithmetic-uint.shader_test @@ -27,7 +27,7 @@ float4 main() : SV_TARGET draw quad probe all rgba (5.0, 5.0, 4294967296.0, 3.0)
-[pixel shader fail] +[pixel shader fail(sm<6)] float4 main() : SV_TARGET { uint x = 1; @@ -36,7 +36,11 @@ float4 main() : SV_TARGET return x / y; }
-[pixel shader fail] +[test] +draw quad +probe all rgba (0.0, 0.0, 0.0, 0.0) + +[pixel shader fail(sm<6)] float4 main() : SV_TARGET { uint x = 1; @@ -44,3 +48,7 @@ float4 main() : SV_TARGET
return x % y; } + +[test] +draw quad +probe all rgba (0.0, 0.0, 0.0, 0.0) diff --git a/tests/hlsl/array-dimension.shader_test b/tests/hlsl/array-dimension.shader_test index 4e8bc12f7..86b0f7d56 100644 --- a/tests/hlsl/array-dimension.shader_test +++ b/tests/hlsl/array-dimension.shader_test @@ -5,7 +5,12 @@ float4 main() : sv_target { const int dim = 4; float a[2 * 2] = {0.1, 0.2, 0.3, 0.4}; +#ifdef __hlsl_dx_compiler + /* float array dimensions are not valid. */ + float b[4] = a; +#else float b[4.1] = a; +#endif float c[dim] = b; float d[true] = {c[0]}; float e[65536]; @@ -13,5 +18,5 @@ float4 main() : sv_target }
[test] -todo draw quad +todo(sm<6) draw quad probe all rgba (0.1, 0.1, 0.2, 0.4) diff --git a/tests/hlsl/array-index-expr.shader_test b/tests/hlsl/array-index-expr.shader_test index 0a83080cc..357b82f57 100644 --- a/tests/hlsl/array-index-expr.shader_test +++ b/tests/hlsl/array-index-expr.shader_test @@ -36,16 +36,16 @@ float4 main() : SV_TARGET
[test] uniform 0 float 0 -draw quad +todo(sm>=6) draw quad probe all rgba (11.0, 11.0, 11.0, 11.0) uniform 0 float 1 -draw quad +todo(sm>=6) draw quad probe all rgba (12.0, 12.0, 12.0, 12.0) uniform 0 float 2 -draw quad +todo(sm>=6) draw quad probe all rgba (13.0, 13.0, 13.0, 13.0) uniform 0 float 3 -draw quad +todo(sm>=6) draw quad probe all rgba (14.0, 14.0, 14.0, 14.0)
@@ -61,16 +61,16 @@ float4 main() : SV_TARGET
[test] uniform 0 float 0 -draw quad +todo(sm>=6) draw quad probe all rgba (21.0, 1.0, 24.0, 0.0) uniform 0 float 1 -draw quad +todo(sm>=6) draw quad probe all rgba (22.0, 0.0, 23.0, 1.0) uniform 0 float 2 -draw quad +todo(sm>=6) draw quad probe all rgba (23.0, 1.0, 22.0, 0.0) uniform 0 float 3 -draw quad +todo(sm>=6) draw quad probe all rgba (24.0, 0.0, 21.0, 1.0)
diff --git a/tests/hlsl/array-parameters.shader_test b/tests/hlsl/array-parameters.shader_test index 6e866ceb5..28a3c5996 100644 --- a/tests/hlsl/array-parameters.shader_test +++ b/tests/hlsl/array-parameters.shader_test @@ -111,7 +111,7 @@ float4 main() : sv_target
% Implicit size arrays are not allowed. -[pixel shader fail] +[pixel shader fail(sm<6)] float fun(float a[]) { return 0; diff --git a/tests/hlsl/array-size-expr.shader_test b/tests/hlsl/array-size-expr.shader_test index 1fd4e2627..55af741da 100644 --- a/tests/hlsl/array-size-expr.shader_test +++ b/tests/hlsl/array-size-expr.shader_test @@ -53,7 +53,7 @@ draw quad probe all rgba (2, 3, 6, 1)
% Additional level of indirection -[pixel shader todo] +[pixel shader todo fail(sm>=6)] static const float array[8] = {1, 2, 3, 4, 5, 6, 7, 8}; static const int idx = 2; static const float array2[array[idx]] = {1, 2, 3}; diff --git a/tests/hlsl/asfloat.shader_test b/tests/hlsl/asfloat.shader_test index 9c0d93732..00238164c 100644 --- a/tests/hlsl/asfloat.shader_test +++ b/tests/hlsl/asfloat.shader_test @@ -2,7 +2,12 @@ shader model >= 4.0
[pixel shader] -float4 main(uniform float f, uniform int i, uniform uint u, uniform half h) : sv_target +uniform float f; +uniform int i; +uniform uint u; +uniform half h; + +float4 main() : sv_target { float4 ret;
@@ -15,11 +20,14 @@ float4 main(uniform float f, uniform int i, uniform uint u, uniform half h) : sv
[test] uniform 0 float4 123.0 -2.0 456 0.01 -draw quad +todo(sm>=6) draw quad probe (320,240) rgba (123.0, -2.0, 456.0, 0.01)
[pixel shader] -float4 main(uniform float2x2 m, uniform float4 v) : sv_target +uniform float2x2 m; +uniform float4 v; + +float4 main() : sv_target { return float4(asfloat(m)[0][1], asfloat(v).y, 0, 0); } @@ -28,7 +36,7 @@ float4 main(uniform float2x2 m, uniform float4 v) : sv_target uniform 0 float4 11 12 0 0 uniform 4 float4 13 14 0 0 uniform 8 float4 20 21 22 23 -draw quad +todo(sm>=6) draw quad probe (320,240) rgba (13.0, 21.0, 0.0, 0.0)
[pixel shader fail] diff --git a/tests/hlsl/asuint.shader_test b/tests/hlsl/asuint.shader_test index 633a543a6..494229e7e 100644 --- a/tests/hlsl/asuint.shader_test +++ b/tests/hlsl/asuint.shader_test @@ -2,8 +2,12 @@ shader model >= 4.0
[pixel shader] +uniform float f; +uniform int i; +uniform uint u; +uniform half h;
-float4 main(uniform float f, uniform int i, uniform uint u, uniform half h) : sv_target +float4 main() : sv_target { uint4 ret;
@@ -16,13 +20,15 @@ float4 main(uniform float f, uniform int i, uniform uint u, uniform half h) : sv
[test] uniform 0 uint4 123 0xc0000000 456 0x7fd69345 -draw quad +todo(sm>=6) draw quad probe (320,240) rgba (123.0, 3221225472.0, 456.0, 2144768896.0)
[pixel shader] +uniform float2x2 m; +uniform float4 v;
-float4 main(uniform float2x2 m, uniform float4 v) : sv_target +float4 main() : sv_target { return float4(asuint(m)[0][1], asuint(v).y, 0, 0); } @@ -31,7 +37,7 @@ float4 main(uniform float2x2 m, uniform float4 v) : sv_target uniform 0 uint4 11 12 0 0 uniform 4 uint4 13 14 0 0 uniform 8 uint4 20 21 22 23 -draw quad +todo(sm>=6) draw quad probe (320,240) rgba (13.0, 21.0, 0.0, 0.0)
diff --git a/tests/hlsl/attributes.shader_test b/tests/hlsl/attributes.shader_test index cb6c2b5e5..fd9c087a3 100644 --- a/tests/hlsl/attributes.shader_test +++ b/tests/hlsl/attributes.shader_test @@ -2,32 +2,32 @@ % we need to get the parsing syntax right. Most of the following tests which % succeed print warnings.
-[pixel shader] +[pixel shader fail(sm>=6)]
[numthreads] float4 main() : sv_target { return 0; }
-[pixel shader] +[pixel shader fail(sm>=6)]
[ numthreads ] float4 main() : sv_target { return 0; }
-[pixel shader] +[pixel shader fail(sm>=6)]
[numthreads(1)] float4 main() : sv_target { return 0; }
-[pixel shader todo] +[pixel shader todo fail(sm>=6)]
[numthreads("")] float4 main() : sv_target { return 0; }
-[pixel shader todo] +[pixel shader todo fail(sm>=6)]
[numthreads("one")] float4 main() : sv_target { return 0; }
-[pixel shader todo] +[pixel shader todo fail(sm>=6)]
uniform float4 f;
@@ -77,12 +77,12 @@ float4 main() : sv_target { return 0; } [one][two] float4 main() : sv_target { return 0; }
-[pixel shader fail todo] +[pixel shader fail(sm<6) todo]
[one][one] float4 main() : sv_target { return 0; }
-[pixel shader fail todo] +[pixel shader fail(sm<6) todo]
[one][one(1)] float4 main() : sv_target { return 0; } @@ -92,7 +92,7 @@ float4 main() : sv_target { return 0; } [one][One] float4 main() : sv_target { return 0; }
-[pixel shader] +[pixel shader fail(sm>=6)]
[numthreads] float4 main(); @@ -112,7 +112,7 @@ static int i = 1; [three(i = 4)] float4 main() : sv_target { return 0; }
-[pixel shader fail] +[pixel shader fail(sm<6)]
[one] float4 f; diff --git a/tests/hlsl/bool-cast.shader_test b/tests/hlsl/bool-cast.shader_test index 09ca12e2b..dc75ea376 100644 --- a/tests/hlsl/bool-cast.shader_test +++ b/tests/hlsl/bool-cast.shader_test @@ -30,7 +30,7 @@ float4 main() : SV_TARGET [test] uniform 0 float4 0.0 0.0 2.0 4.0 uniform 4 int4 0 1 0 10 -draw quad +todo(sm>=6) draw quad probe all rgba (0.0, 10.0, 1.0, 11.0)
@@ -44,5 +44,5 @@ float4 main() : sv_target
[test] uniform 0 uint4 0x00000001 0x00000002 0x80000000 0x00000000 -draw quad +todo(sm>=6) draw quad probe all rgba (2.0, 2.0, 2.0, 0.0) diff --git a/tests/hlsl/bool-semantics.shader_test b/tests/hlsl/bool-semantics.shader_test index bcbd9f9bf..d8df96a2a 100644 --- a/tests/hlsl/bool-semantics.shader_test +++ b/tests/hlsl/bool-semantics.shader_test @@ -49,5 +49,5 @@ float4 main(struct input i) : sv_target }
[test] -draw triangle strip 4 +todo(sm>=6) draw triangle strip 4 probe all rgba (0.0, 2.0, 2.0, 2.0) diff --git a/tests/hlsl/cast-componentwise-compatible.shader_test b/tests/hlsl/cast-componentwise-compatible.shader_test index da55628bf..8ad21d12a 100644 --- a/tests/hlsl/cast-componentwise-compatible.shader_test +++ b/tests/hlsl/cast-componentwise-compatible.shader_test @@ -262,7 +262,7 @@ draw quad probe all rgba (41.0, 42.0, 43.0, 44.0)
-[pixel shader fail] +[pixel shader fail(sm<6)] struct apple { float2 aa; @@ -301,7 +301,7 @@ draw quad probe all rgba (55.0, 56.0, 57.0, 58.0)
-[pixel shader fail] +[pixel shader fail(sm<6)] struct apple { float2 aa; @@ -333,7 +333,7 @@ draw quad probe all rgba (61.0, 62.0, 63.0, 64.0)
-[pixel shader fail] +[pixel shader fail(sm<6)] float4 main() : sv_target { float arr[5] = {1, 2, 3, 4, 5}; @@ -359,7 +359,7 @@ draw quad probe all rgba (71.0, 72.0, 73.0, 74.0)
-[pixel shader fail] +[pixel shader fail(sm<6)] float4 main() : sv_target { float2x2 mat = {1, 2, 3, 4}; @@ -381,7 +381,7 @@ float4 main() : sv_target }
-[pixel shader fail] +[pixel shader fail(sm<6)] float4 main() : sv_target { float arr[5] = {1, 2, 3, 4, 5}; @@ -440,7 +440,7 @@ draw quad probe all rgba (11.0, 12.0, 13.0, 0.0)
-[pixel shader fail] +[pixel shader fail(sm<6)] struct apple { float3 aa; @@ -541,7 +541,7 @@ draw quad probe all rgba (51.0, 52.0, 53.0, 0.0)
-[pixel shader fail] +[pixel shader fail(sm<6)] float4 main() : sv_target { float4 vec = {1, 2, 3, 4}; diff --git a/tests/hlsl/cast-componentwise-equal.shader_test b/tests/hlsl/cast-componentwise-equal.shader_test index 4a25f6dd5..bb1c26fe0 100644 --- a/tests/hlsl/cast-componentwise-equal.shader_test +++ b/tests/hlsl/cast-componentwise-equal.shader_test @@ -32,7 +32,7 @@ float4 main() : sv_target }
-[pixel shader] +[pixel shader fail(sm>=6)] struct apple { float3 aa; @@ -71,7 +71,7 @@ float4 main() : sv_target }
-[pixel shader] +[pixel shader fail(sm>=6)] struct apple { float3 aa; @@ -93,7 +93,7 @@ draw quad probe all rgba (5.0, 6.0, 7.0, 8.0)
-[pixel shader] +[pixel shader fail(sm>=6)] Texture2D tex;
struct apple @@ -124,7 +124,7 @@ draw quad probe all rgba (4.0, 4.0, 4.0, 4.0)
-[pixel shader] +[pixel shader fail(sm>=6)] Texture2D tex;
struct apple @@ -158,7 +158,7 @@ draw quad probe all rgba (5.0, 5.0, 5.0, 5.0)
-[pixel shader] +[pixel shader fail(sm>=6)] struct apple { float3 xx[2]; diff --git a/tests/hlsl/cast-to-float.shader_test b/tests/hlsl/cast-to-float.shader_test index f09100204..69786eccc 100644 --- a/tests/hlsl/cast-to-float.shader_test +++ b/tests/hlsl/cast-to-float.shader_test @@ -2,7 +2,12 @@ shader model >= 4.0
[pixel shader] -float4 main(uniform int i, uniform uint u, uniform bool b, uniform half h) : sv_target +uniform int i; +uniform uint u; +uniform bool b; +uniform half h; + +float4 main() : sv_target { return float4(((float)i) + 1.5, ((float)u) - 2.5, ((float)b) / 2, h); } @@ -12,7 +17,7 @@ uniform 0 int -1 uniform 1 uint 3 uniform 2 int -2 uniform 3 float 0.5 -draw quad +todo(sm>=6) draw quad probe all rgba (0.5, 0.5, 0.5, 0.5)
[pixel shader] diff --git a/tests/hlsl/cast-to-half.shader_test b/tests/hlsl/cast-to-half.shader_test index 81d6bc5d5..1579c63f3 100644 --- a/tests/hlsl/cast-to-half.shader_test +++ b/tests/hlsl/cast-to-half.shader_test @@ -2,8 +2,12 @@ shader model >= 4.0
[pixel shader] +uniform int i; +uniform uint u; +uniform bool b; +uniform float f;
-float4 main(uniform int i, uniform uint u, uniform bool b, uniform float f) : sv_target +float4 main() : sv_target { return float4(((half)i) + 1.5, ((half)u) - 2.5, ((half)b) / 2, f); } @@ -13,7 +17,7 @@ uniform 0 int -1 uniform 1 uint 3 uniform 2 int -2 uniform 3 float 0.5 -draw quad +todo(sm>=6) draw quad probe all rgba (0.5, 0.5, 0.5, 0.5)
[pixel shader] diff --git a/tests/hlsl/cast-to-int.shader_test b/tests/hlsl/cast-to-int.shader_test index fe8c79a3c..efa60eed1 100644 --- a/tests/hlsl/cast-to-int.shader_test +++ b/tests/hlsl/cast-to-int.shader_test @@ -2,8 +2,12 @@ shader model >= 4.0
[pixel shader] +uniform float f; +uniform uint u; +uniform bool b; +uniform half h;
-float4 main(uniform float f, uniform uint u, uniform bool b, uniform half h) : sv_target +float4 main() : sv_target { float4 ret;
@@ -19,7 +23,7 @@ uniform 0 float 2.6 uniform 1 int -2 uniform 2 int -2 uniform 3 float -3.6 -draw quad +todo(sm>=6) draw quad probe all rgba (0.5, 0.5, 0.5, 0.5)
[pixel shader] diff --git a/tests/hlsl/cast-to-uint.shader_test b/tests/hlsl/cast-to-uint.shader_test index 93862a36f..668538554 100644 --- a/tests/hlsl/cast-to-uint.shader_test +++ b/tests/hlsl/cast-to-uint.shader_test @@ -2,8 +2,12 @@ shader model >= 4.0
[pixel shader] +uniform float f; +uniform int i; +uniform bool b; +uniform half h;
-float4 main(uniform float f, uniform int i, uniform bool b, uniform half h) : sv_target +float4 main() : sv_target { float4 ret;
@@ -19,7 +23,7 @@ uniform 0 float 2.6 uniform 1 int 2 uniform 2 int -2 uniform 3 float -3.6 -draw quad +todo(sm>=6) draw quad probe all rgba (0.5, 0.5, 0.5, 0.5)
[pixel shader] diff --git a/tests/hlsl/cbuffer.shader_test b/tests/hlsl/cbuffer.shader_test index 83397c189..59dda97a5 100644 --- a/tests/hlsl/cbuffer.shader_test +++ b/tests/hlsl/cbuffer.shader_test @@ -13,7 +13,7 @@ float4 main() : sv_target
[test] uniform 0 float4 1.0 2.0 3.0 4.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 2.0, 3.0, 4.0)
[pixel shader] @@ -31,7 +31,7 @@ float4 main() : sv_target
[test] uniform 0 float4 1.0 2.0 3.0 4.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 2.0, 3.0, 4.0)
% SM1 buffer offset allocation follows different rules than SM4. @@ -72,7 +72,7 @@ uniform 0 float4 0.0 1.0 2.0 3.0 uniform 4 float4 4.0 5.0 6.0 7.0 uniform 8 float4 8.0 9.0 10.0 11.0 uniform 12 float4 12.0 13.0 14.0 15.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.0, 2.0, 4.0, 8.0)
@@ -93,7 +93,7 @@ float4 main() : sv_target uniform 0 float4 0.0 1.0 2.0 3.0 uniform 4 float4 4.0 5.0 6.0 7.0 uniform 8 float4 8.0 9.0 10.0 11.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.0, 4.0, 8.0, 9.0)
@@ -119,11 +119,11 @@ uniform 0 float4 0.0 1.0 2.0 3.0 uniform 4 float4 4.0 5.0 6.0 7.0 uniform 8 float4 8.0 9.0 10.0 11.0 uniform 12 float4 12.0 13.0 14.0 15.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.0, 4.0, 5.0, 6.0)
-[pixel shader fail] +[pixel shader fail(sm<6)] // Elements cannot overlap if buffer is used. cbuffer buffer { @@ -134,9 +134,17 @@ cbuffer buffer
float4 main() : sv_target { - return c; + return float4(c, a[1].x, b[0].x, b[1].x); }
+[test] +uniform 0 float4 1.0 0.0 0.0 0.0 +uniform 4 float4 2.0 0.0 0.0 0.0 +uniform 8 float4 3.0 0.0 0.0 0.0 +uniform 12 float4 4.0 0.0 0.0 0.0 +todo draw quad +probe all rgba (1.0, 3.0, 3.0, 4.0) +
[pixel shader] // Elements can overlap if buffer is not used. @@ -168,7 +176,7 @@ float4 main() : sv_target uniform 0 float4 1.0 2.0 3.0 4.0 uniform 4 float4 5.0 6.0 7.0 8.0 uniform 8 float4 9.0 10.0 11.0 12.0 -draw quad +todo(sm>=6) draw quad probe all rgba (509, 610, 711, 812)
@@ -196,7 +204,7 @@ uniform 0 float4 0.0 1.0 2.0 3.0 uniform 4 float4 4.0 5.0 6.0 7.0 uniform 8 float4 8.0 9.0 10.0 11.0 uniform 12 float4 12.0 13.0 14.0 15.0 -draw quad +todo(sm>=6) draw quad probe all rgba (12468.0, 13509.0, 14010.0, 15011.0)
@@ -213,7 +221,7 @@ float4 main() : sv_target
[test] uniform 0 float4 1.0 2.0 3.0 4.0 -draw quad +todo(sm>=6) draw quad probe all rgba (2.0, 3.0, 2.0, 3.0)
@@ -230,7 +238,7 @@ float4 main() : sv_target }
-[pixel shader fail] +[pixel shader fail(sm<6)] // Matrices must be aligned. cbuffer buffer { @@ -243,7 +251,7 @@ float4 main() : sv_target }
-[pixel shader fail] +[pixel shader fail(sm<6)] // Arrays must be aligned. cbuffer buffer { @@ -256,7 +264,7 @@ float4 main() : sv_target }
-[pixel shader fail] +[pixel shader fail(sm<6)] // Structs must be aligned. struct apple { @@ -318,11 +326,11 @@ float4 main() : sv_target uniform 0 float 1.0 uniform 1 float 2.0 uniform 4 float4 5.0 6.0 7.0 8.0 -draw quad +todo(sm>=6) draw quad probe all rgba (512.0, 612.0, 712.0, 812.0)
-[pixel shader fail] +[pixel shader fail(sm<6)] // packoffset cannot be used unless all elements use it. cbuffer buffer { @@ -349,7 +357,7 @@ float4 main() : sv_target
[test] uniform 0 float4 1.0 2.0 3.0 4.0 -draw quad +todo(sm>=6) draw quad probe all rgba (3.0, 4.0, 3.0, 4.0)
@@ -491,7 +499,7 @@ float4 main() : sv_target uniform 0 float4 1.0 0.0 0.0 0.0 uniform 4 float4 0.0 2.0 0.0 0.0 uniform 8 float4 0.0 0.0 3.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 2.0, 0.0, 4.0)
@@ -541,14 +549,14 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0)
% Samplers cannot have packoffset(), unless register() is also specified, or they are not used. % Note: In SM1 the rules are different: packoffset() is allowed for samplers, but they cannot be % used together with other numeric fields, which seems like a bug. -[pixel shader fail todo] +[pixel shader fail(sm<6) todo] Texture2D tex;
cbuffer buffer @@ -599,7 +607,7 @@ float4 main() : sv_target
% When packoffset is used in one field, resources are also expected to have a reservation. -[pixel shader fail] +[pixel shader fail(sm<6)] cbuffer buffer { float4 foo : packoffset(c0); @@ -611,7 +619,7 @@ float4 main() : sv_target return 0; }
-[pixel shader fail] +[pixel shader fail(sm<6)] cbuffer buffer { float4 foo : packoffset(c0); @@ -649,7 +657,7 @@ float4 main() : sv_target }
% Using register() alone is considered manual packing for resources, so the other fields expect packoffset(). -[pixel shader fail] +[pixel shader fail(sm<6)] cbuffer buffer { float4 foo; @@ -661,7 +669,7 @@ float4 main() : sv_target return 0; }
-[pixel shader fail] +[pixel shader fail(sm<6)] cbuffer buffer { float4 foo; @@ -718,5 +726,5 @@ uniform 0 float4 0.0 1.0 2.0 3.0 uniform 4 float4 4.0 5.0 6.0 7.0 uniform 8 float4 8.0 9.0 10.0 11.0 uniform 12 float4 12.0 13.0 14.0 15.0 -draw quad +todo(sm>=6) draw quad probe all rgba (124.0, 135.0, 146.0, 150.5) diff --git a/tests/hlsl/clamp.shader_test b/tests/hlsl/clamp.shader_test index 1320c3dd3..3d797ec3f 100644 --- a/tests/hlsl/clamp.shader_test +++ b/tests/hlsl/clamp.shader_test @@ -1,12 +1,14 @@ [pixel shader] -float4 main(uniform float3 u) : sv_target +uniform float3 u; + +float4 main() : sv_target { return float4(clamp(u.x, u.y, u.z), clamp(0.9, u.y, u.z), clamp(u.x, -0.5, u.z), clamp(0.6, -0.4, 0.3)); }
[test] uniform 0 float4 -0.3 -0.1 0.7 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (-0.1, 0.7, -0.3, 0.3)
diff --git a/tests/hlsl/clip.shader_test b/tests/hlsl/clip.shader_test index f9859e1b8..d7473c999 100644 --- a/tests/hlsl/clip.shader_test +++ b/tests/hlsl/clip.shader_test @@ -9,14 +9,14 @@ float4 main() : sv_target
[test] uniform 0 float4 1 2 3 4 -draw quad +todo(sm>=6) draw quad probe all rgba (1, 2, 3, 4) uniform 0 float4 9 8 7 6 -draw quad +todo(sm>=6) draw quad probe all rgba (9, 8, 7, 6) uniform 0 float4 -1 8 7 6 -draw quad +todo(sm>=6) draw quad probe all rgba (9, 8, 7, 6) uniform 0 float4 9 0 7 6 -draw quad +todo(sm>=6) draw quad probe all rgba (9, 0, 7, 6) diff --git a/tests/hlsl/combined-samplers.shader_test b/tests/hlsl/combined-samplers.shader_test index 465c11cb5..19038c34d 100644 --- a/tests/hlsl/combined-samplers.shader_test +++ b/tests/hlsl/combined-samplers.shader_test @@ -1,5 +1,6 @@ [require] shader model >= 4.0 +shader model < 6.0
[sampler 0] @@ -35,6 +36,7 @@ size (1, 1) 4.0 4.0 4.0 1.0
[require] +shader model < 6.0 options: backcompat
[pixel shader] @@ -136,6 +138,7 @@ probe all rgba (1, 1, 1, 11)
[require] shader model >= 5.0 +shader model < 6.0
[pixel shader todo] diff --git a/tests/hlsl/compute.shader_test b/tests/hlsl/compute.shader_test index 6d2f698c7..2f2af9fc8 100644 --- a/tests/hlsl/compute.shader_test +++ b/tests/hlsl/compute.shader_test @@ -17,5 +17,5 @@ void main() }
[test] -dispatch 1 1 1 +todo(sm>=6) dispatch 1 1 1 probe uav 0 (0, 0) r (-123.0) diff --git a/tests/hlsl/conditional.shader_test b/tests/hlsl/conditional.shader_test index 810f7366a..4175813bd 100644 --- a/tests/hlsl/conditional.shader_test +++ b/tests/hlsl/conditional.shader_test @@ -1,5 +1,7 @@ [pixel shader] -float4 main(uniform float4 u) : sv_target +uniform float4 u; + +float4 main() : sv_target { if (u.x > 0.0) return float4(0.1, 0.2, 0.3, 0.4); @@ -9,14 +11,16 @@ float4 main(uniform float4 u) : sv_target
[test] uniform 0 float4 0.0 0.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.9, 0.8, 0.7, 0.6) uniform 0 float4 0.1 0.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.1, 0.2, 0.3, 0.4)
[pixel shader] -float4 main(uniform float4 u) : sv_target +uniform float4 u; + +float4 main() : sv_target { [attr1] if (u.x > 0.0) @@ -26,7 +30,9 @@ float4 main(uniform float4 u) : sv_target }
[pixel shader] -float4 main(uniform float4 u) : sv_target +uniform float4 u; + +float4 main() : sv_target { [flatten] if (u.x > 0.0) @@ -37,10 +43,10 @@ float4 main(uniform float4 u) : sv_target
[test] uniform 0 float4 0.0 0.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.9, 0.8, 0.7, 0.6)
-[pixel shader fail] +[pixel shader fail(sm<6)] float4 u;
float main() : sv_target @@ -69,7 +75,9 @@ float main() : sv_target shader model >= 3.0
[pixel shader] -float4 main(uniform float4 u) : sv_target +uniform float4 u; + +float4 main() : sv_target { [branch] if (u.x > 0.0) @@ -80,7 +88,7 @@ float4 main(uniform float4 u) : sv_target
[test] uniform 0 float4 0.0 0.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.9, 0.8, 0.7, 0.6)
[pixel shader] diff --git a/tests/hlsl/const.shader_test b/tests/hlsl/const.shader_test index ed5899f65..17427c385 100644 --- a/tests/hlsl/const.shader_test +++ b/tests/hlsl/const.shader_test @@ -10,10 +10,10 @@ float4 main() : sv_target [test] uniform 0 float4 1.0 2.0 3.0 4.0 uniform 4 float4 0.1 0.2 0.3 0.4 -draw quad +todo(sm>=6) draw quad probe all rgba (1.1, 2.2, 3.3, 4.4)
-[pixel shader fail] +[pixel shader fail(sm<6)] float4 main() : sv_target { const float f; diff --git a/tests/hlsl/cross.shader_test b/tests/hlsl/cross.shader_test index 101db6071..b84e2eaca 100644 --- a/tests/hlsl/cross.shader_test +++ b/tests/hlsl/cross.shader_test @@ -1,5 +1,8 @@ [pixel shader] -float4 main(uniform float4 u, uniform float4 v) : sv_target +uniform float4 u; +uniform float4 v; + +float4 main() : sv_target { float4 res = float4(0, 0, 0, 0); res.xyz = cross(u, v); @@ -9,13 +12,15 @@ float4 main(uniform float4 u, uniform float4 v) : sv_target [test] uniform 0 float4 1 -2 3 4 uniform 4 float4 10 100 1000 10000 -draw quad +todo(sm>=6) draw quad probe all rgba (-2300, -970, 120, 0)
[pixel shader] -float4 main(uniform float4 u) : sv_target +uniform float4 u; + +float4 main() : sv_target { float4 res = float4(0, 0, 0, 3.5); res.xyz = cross(u, 4); @@ -24,5 +29,5 @@ float4 main(uniform float4 u) : sv_target
[test] uniform 0 float4 1 -2 3 4 -draw quad +todo(sm>=6) draw quad probe all rgba (-20, 8, 12, 3.5) diff --git a/tests/hlsl/d3dcolor-to-ubyte4.shader_test b/tests/hlsl/d3dcolor-to-ubyte4.shader_test index e31ef61ca..01b7f2f64 100644 --- a/tests/hlsl/d3dcolor-to-ubyte4.shader_test +++ b/tests/hlsl/d3dcolor-to-ubyte4.shader_test @@ -2,23 +2,27 @@ shader model >= 4.0
[pixel shader] -float4 main(uniform float4 u) : sv_target +uniform float4 u; + +float4 main() : sv_target { return D3DCOLORtoUBYTE4(u); }
[test] uniform 0 float4 -0.5 6.5 7.5 3.4 -draw quad +todo(sm>=6) draw quad probe all rgba (1912.0, 1657.0, -127.0, 867.0) 1
[pixel shader] -float4 main(uniform float4 u) : sv_target +uniform float4 u; + +float4 main() : sv_target { return D3DCOLORtoUBYTE4(u.x); }
[test] uniform 0 float4 -0.5 6.5 7.5 3.4 -draw quad +todo(sm>=6) draw quad probe all rgba (-127.0, -127.0, -127.0, -127.0) 1 diff --git a/tests/hlsl/ddxddy.shader_test b/tests/hlsl/ddxddy.shader_test index 4986c233f..ba7215ca0 100644 --- a/tests/hlsl/ddxddy.shader_test +++ b/tests/hlsl/ddxddy.shader_test @@ -8,7 +8,7 @@ float4 main(float4 pos : sv_position) : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 1.0, 0.0, 0.0)
@@ -29,7 +29,7 @@ float4 main(float4 pos : sv_position) : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe (10, 10) rgba (-16.0, -5.0, 3.0, 0.0) probe (11, 10) rgba (-21.0, -5.0, 3.0, 0.0) probe (10, 11) rgba (-13.0, -5.0, 3.0, 0.0) @@ -55,7 +55,7 @@ float4 main(float4 pos : sv_position) : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe (10, 10) rgba (-16.0, -5.0, 3.0, 0.0) probe (11, 10) rgba (-21.0, -5.0, 3.0, 0.0) probe (10, 11) rgba (-13.0, -5.0, 3.0, 0.0) @@ -74,7 +74,7 @@ float4 main(float4 pos : sv_position) : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe (10, 10) rgba (-0.524999976, -0.164999843, 0.104999900, 0.0) 16 probe (11, 10) rgba (-0.689999819, -0.164999843, 0.114999890, 0.0) 32 probe (10, 11) rgba (-0.420000076, -0.154999852, 0.104999900, 0.0) 32 diff --git a/tests/hlsl/discard.shader_test b/tests/hlsl/discard.shader_test index f543f877b..cecb8c1fd 100644 --- a/tests/hlsl/discard.shader_test +++ b/tests/hlsl/discard.shader_test @@ -9,8 +9,8 @@ float4 main() : sv_target
[test] uniform 0 float4 1 2 3 4 -draw quad +todo(sm>=6) draw quad probe all rgba (1, 2, 3, 4) uniform 0 float4 9 8 7 6 -draw quad +todo(sm>=6) draw quad probe all rgba (1, 2, 3, 4) diff --git a/tests/hlsl/distance.shader_test b/tests/hlsl/distance.shader_test index 3f5446451..6527c218a 100644 --- a/tests/hlsl/distance.shader_test +++ b/tests/hlsl/distance.shader_test @@ -10,7 +10,7 @@ float4 main() : sv_target [test] uniform 0 float4 -2.0 3.0 4.0 0.1 uniform 4 float4 2.0 -1.0 4.0 5.0 -draw quad +todo(sm>=6) draw quad probe all rgba (7.483983, 7.483983, 7.483983, 7.483983) 1
[pixel shader] diff --git a/tests/hlsl/dot.shader_test b/tests/hlsl/dot.shader_test index 15f120f70..bb71919ce 100644 --- a/tests/hlsl/dot.shader_test +++ b/tests/hlsl/dot.shader_test @@ -10,7 +10,7 @@ float4 main() : SV_TARGET [test] uniform 0 float4 2.0 3.0 4.0 5.0 uniform 4 float4 10.0 11.0 12.0 13.0 -draw quad +todo(sm>=6) draw quad probe all rgba (166.0, 166.0, 166.0, 166.0)
[pixel shader] @@ -25,7 +25,7 @@ float4 main() : SV_TARGET [test] uniform 0 float4 2.0 3.0 0.0 0.0 uniform 4 float4 10.0 11.0 12.0 13.0 -draw quad +todo(sm>=6) draw quad probe all rgba (53.0, 53.0, 53.0, 53.0)
[pixel shader] @@ -40,7 +40,7 @@ float4 main() : SV_TARGET [test] uniform 0 float4 2.0 0.0 0.0 0.0 uniform 4 float4 10.0 11.0 12.0 13.0 -draw quad +todo(sm>=6) draw quad probe all rgba (92.0, 92.0, 92.0, 92.0)
[pixel shader] @@ -55,7 +55,7 @@ float4 main() : SV_TARGET [test] uniform 0 float4 10.0 11.0 12.0 13.0 uniform 4 float4 2.0 0.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (92.0, 92.0, 92.0, 92.0)
[pixel shader] @@ -71,7 +71,7 @@ float4 main() : SV_TARGET % Account for both the SM1 and SM4 uniform layout uniform 0 float4 2.0 3.0 0.0 0.0 uniform 4 float4 3.0 0.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (6.0, 6.0, 6.0, 6.0)
[pixel shader] diff --git a/tests/hlsl/duplicate-modifiers.shader_test b/tests/hlsl/duplicate-modifiers.shader_test index 6491701ae..bf1d9c1b8 100644 --- a/tests/hlsl/duplicate-modifiers.shader_test +++ b/tests/hlsl/duplicate-modifiers.shader_test @@ -1,3 +1,7 @@ +% Returns (0.1, 0.3, 0.2, 0.4) with dxcompiler +[require] +shader model < 6.0 + [pixel shader] typedef const precise row_major float2x2 mat_t; float4 main() : sv_target diff --git a/tests/hlsl/entry-point-semantics.shader_test b/tests/hlsl/entry-point-semantics.shader_test index 32cd43c2f..6d355ab5c 100644 --- a/tests/hlsl/entry-point-semantics.shader_test +++ b/tests/hlsl/entry-point-semantics.shader_test @@ -84,7 +84,7 @@ float4 main(in apple a) : sv_target
[test] draw quad -probe (0, 0) rgba (10.0, 20.0, 30.0, 40.0) +todo(sm>=6) probe (0, 0) rgba (10.0, 20.0, 30.0, 40.0)
% Arrays of matrices get successive indexes. @@ -101,7 +101,7 @@ float4 main(in apple a) : sv_target
[test] draw quad -probe (0, 0) rgba (10.0, 11.0, 30.0, 31.0) +todo(sm>=6) probe (0, 0) rgba (10.0, 11.0, 30.0, 31.0)
% Arrays (even multi-dimensional) of struct elements are allowed. The fields in the different struct @@ -120,7 +120,7 @@ float4 main(in apple aps[2][2]) : sv_target
[test] draw quad -probe (0, 0) rgba (10.0, 10.0, 20.0, 20.0) +todo(sm>=6) probe (0, 0) rgba (10.0, 10.0, 20.0, 20.0)
[pixel shader] @@ -142,7 +142,7 @@ float4 main(in banana bans[2]) : sv_target
[test] draw quad -probe (0, 0) rgba (10.0, 11.0, 20.0, 21.0) +todo(sm>=6) probe (0, 0) rgba (10.0, 11.0, 20.0, 21.0)
[pixel shader fail] @@ -201,11 +201,11 @@ float4 main(in float4 tex0 : TEXCOORD0, in float4 tex1 : TEXCOORD1) : sv_target
[test] draw quad -probe (0, 0) rgba (1.0, 2.0, 10.0, 20.0) +todo(sm>=6) probe (0, 0) rgba (1.0, 2.0, 10.0, 20.0)
% Output semantics cannot be mapped to more than one value. -[vertex shader fail] +[vertex shader fail(sm<6)] struct apple { float2 tex : TEXCOORD0; @@ -251,7 +251,7 @@ void main(out float4 tex[4] : texcoord, inout float4 pos : sv_position)
% Arguments with the same semantic aren't aliased. -[pixel shader] +[pixel shader fail(sm>=6)] float4 main(in float4 t1 : TEXCOORD0, in float4 t2 : TEXCOORD0) : sv_target { t1 = 99; @@ -259,7 +259,7 @@ float4 main(in float4 t1 : TEXCOORD0, in float4 t2 : TEXCOORD0) : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe (0, 0) rgba (99.0, 99.0, 10.0, 11.0)
@@ -272,19 +272,19 @@ float4 main(in float4 a : TEXCOORD0, in float3 b : TEXCOORD1) : sv_target
[test] draw quad -probe (0, 0) rgba (10.0, 11.0, 20.0, 21.0) +todo(sm>=6) probe (0, 0) rgba (10.0, 11.0, 20.0, 21.0)
% In SM4, duplicated input semantics can only have different types if they have the same layout and % register types. SM1 is permissive in this regard. -[pixel shader] +[pixel shader fail(sm>=6)] float4 main(in float2 a : TEXCOORD0, in half2 b : TEXCOORD0, in float2x1 c: TEXCOORD0) : sv_target { return 0.0; }
-[pixel shader] +[pixel shader fail(sm>=6)] float4 main(in uint2 a : TEXCOORD0, in int2 b : TEXCOORD0, in int2x1 c : TEXCOORD0, in bool2 d : TEXCOORD0) : sv_target { return 0.0; diff --git a/tests/hlsl/exp.shader_test b/tests/hlsl/exp.shader_test index 1d1889977..38f8750fd 100644 --- a/tests/hlsl/exp.shader_test +++ b/tests/hlsl/exp.shader_test @@ -8,7 +8,7 @@ float4 main() : sv_target
[test] uniform 0 float4 -1.0 0.0 1.0 2.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.5, 1.0, 2.0, 4.0) 2
[pixel shader] @@ -21,5 +21,5 @@ float4 main() : sv_target
[test] uniform 0 float4 -1.0 0.0 1.0 2.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.36787948, 1.0, 2.7182815, 7.38905573) 2 diff --git a/tests/hlsl/expr-indexing.shader_test b/tests/hlsl/expr-indexing.shader_test index 3dcc5727e..1816c6eb7 100644 --- a/tests/hlsl/expr-indexing.shader_test +++ b/tests/hlsl/expr-indexing.shader_test @@ -9,7 +9,7 @@ float4 main() : sv_target [test] uniform 0 float4 1.0 2.0 3.0 4.0 uniform 4 float4 5.0 6.0 7.0 8.0 -draw quad +todo(sm>=6) draw quad probe all rgba (8.0, 8.0, 8.0, 8.0)
@@ -26,7 +26,7 @@ float4 main() : sv_target uniform 0 float4 1.0 2.0 3.0 4.0 uniform 4 float4 5.0 6.0 7.0 8.0 uniform 8 float 2 -draw quad +todo(sm>=6) draw quad probe all rgba (10.0, 10.0, 10.0, 10.0)
@@ -40,7 +40,7 @@ float4 main() : sv_target
[test] uniform 0 float4 1.0 2.0 3.0 4.0 -draw quad +todo(sm>=6) draw quad probe all rgba (3.0, 3.0, 3.0, 3.0)
@@ -56,10 +56,10 @@ float4 main() : sv_target [test] uniform 0 float4 1.0 2.0 3.0 4.0 uniform 4 float 0 -draw quad +todo(sm>=6) draw quad probe all rgba (4.0, 4.0, 4.0, 4.0) uniform 4 float 2 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0)
@@ -78,7 +78,7 @@ float4 main() : sv_target
[test] uniform 0 float4 1.0 2.0 3.0 4.0 -draw quad +todo(sm>=6) draw quad probe all rgba (4.0, 4.0, 4.0, 4.0)
@@ -99,5 +99,5 @@ float4 main() : sv_target [test] uniform 0 float4 1.0 2.0 3.0 4.0 uniform 4 float 1 -draw quad +todo(sm>=6) draw quad probe all rgba (2.0, 2.0, 2.0, 2.0) diff --git a/tests/hlsl/floor.shader_test b/tests/hlsl/floor.shader_test index c111f98b9..deb9acf91 100644 --- a/tests/hlsl/floor.shader_test +++ b/tests/hlsl/floor.shader_test @@ -1,16 +1,20 @@ [pixel shader] -float4 main(uniform float4 u) : sv_target +uniform float4 u; + +float4 main() : sv_target { return floor(u); }
[test] uniform 0 float4 -0.5 6.5 7.5 3.4 -draw quad +todo(sm>=6) draw quad probe all rgba (-1.0, 6.0, 7.0, 3.0) 4
[pixel shader] -float4 main(uniform float4 u) : sv_target +uniform float4 u; + +float4 main() : sv_target { float a = floor(u.r); int2 b = floor(u.gb); @@ -20,14 +24,16 @@ float4 main(uniform float4 u) : sv_target
[test] uniform 0 float4 -0.5 6.5 7.5 3.4 -draw quad +todo(sm>=6) draw quad probe all rgba (6.0, 7.0, -1.0, 3.0) 4
[require] shader model >= 4.0
[pixel shader] -float4 main(uniform int4 u) : sv_target +uniform int4 u; + +float4 main() : sv_target { float a = floor(u.r); int2 b = floor(u.gb); @@ -37,5 +43,5 @@ float4 main(uniform int4 u) : sv_target
[test] uniform 0 int4 -1 6 7 3 -draw quad +todo(sm>=6) draw quad probe all rgba (6.0, 7.0, -1.0, 3.0) 4 diff --git a/tests/hlsl/fmod.shader_test b/tests/hlsl/fmod.shader_test index 9eb69c3bb..05518c7cd 100644 --- a/tests/hlsl/fmod.shader_test +++ b/tests/hlsl/fmod.shader_test @@ -1,27 +1,31 @@ [pixel shader] -float4 main(uniform float4 u) : sv_target +uniform float4 u; + +float4 main() : sv_target { return float4(fmod(u.x, u.y), 0, 0, 0); }
[test] uniform 0 float4 -0.5 6.5 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (-0.5, 0.0, 0.0, 0.0) 4 uniform 0 float4 1.1 0.3 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.2, 0.0, 0.0, 0.0) 4
[pixel shader] -float4 main(uniform float4 u) : sv_target +uniform float4 u; + +float4 main() : sv_target { return float4(fmod(u.xy, u.z), 0, 0); }
[test] uniform 0 float4 -0.5 6.5 2.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (-0.5, 0.5, 0.0, 0.0) 4 uniform 0 float4 1.1 0.3 3.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.1, 0.3, 0.0, 0.0) 4 diff --git a/tests/hlsl/for.shader_test b/tests/hlsl/for.shader_test index e0b0edc11..e5faa28fd 100644 --- a/tests/hlsl/for.shader_test +++ b/tests/hlsl/for.shader_test @@ -22,7 +22,7 @@ float4 main(float tex : texcoord) : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe ( 0, 0, 159, 480) rgba (10.0, 35.0, 0.0, 0.0) probe (161, 0, 479, 480) rgba (10.0, 38.0, 0.0, 0.0) probe (481, 0, 640, 480) rgba ( 5.0, 10.0, 0.0, 0.0) @@ -43,7 +43,7 @@ float4 main(float tex : texcoord) : sv_target draw quad probe all rgba (10.0, 45.0, 0.0, 0.0)
-[pixel shader fail] +[pixel shader fail(sm<6)] float4 main(float tex : texcoord) : sv_target { int i; diff --git a/tests/hlsl/frac.shader_test b/tests/hlsl/frac.shader_test index f54f3fe88..2ac9b530d 100644 --- a/tests/hlsl/frac.shader_test +++ b/tests/hlsl/frac.shader_test @@ -8,5 +8,5 @@ float4 main() : sv_target
[test] uniform 0 float4 -1.1 1.6 1.3 0.5 -draw quad +todo(sm>=6) draw quad probe all rgba (0.9, 0.6, 0.3, 0.5) 2 diff --git a/tests/hlsl/function-cast.shader_test b/tests/hlsl/function-cast.shader_test index e6a5a96b4..a2b9cf4f4 100644 --- a/tests/hlsl/function-cast.shader_test +++ b/tests/hlsl/function-cast.shader_test @@ -22,8 +22,10 @@ todo draw quad probe all rgba (-1.0, -1.0, 2.0, 4.0)
% As above, but cast "x" to float4 first. +% In SM 6 a cast seems to implicitly promote the type to const, +% so it fails to match the parameter of func().
-[pixel shader todo] +[pixel shader todo fail(sm>=6)]
uniform float4 f;
@@ -46,7 +48,7 @@ probe all rgba (-1.0, -1.0, 2.0, 4.0)
% As above, but declare "x" as float4 and cast it to int4.
-[pixel shader todo] +[pixel shader todo fail(sm>=6)]
uniform float4 f;
@@ -71,13 +73,14 @@ probe all rgba (-1.0, -1.0, 2.0, 4.0) shader model >= 4.0
[pixel shader todo] +uniform int4 i;
void func(inout float4 a) { a += 0.1; }
-float4 main(uniform int4 i) : sv_target +float4 main() : sv_target { int4 x = i; func(x); diff --git a/tests/hlsl/function-overload.shader_test b/tests/hlsl/function-overload.shader_test index 099f63f34..c5a30b165 100644 --- a/tests/hlsl/function-overload.shader_test +++ b/tests/hlsl/function-overload.shader_test @@ -36,5 +36,5 @@ float4 main() : sv_target }
[test] -todo draw quad +todo(sm<6) draw quad probe all rgba (0.1, 0.2, 0.1, 0.2) diff --git a/tests/hlsl/function-return.shader_test b/tests/hlsl/function-return.shader_test index cbd29749f..98aac4fa7 100644 --- a/tests/hlsl/function-return.shader_test +++ b/tests/hlsl/function-return.shader_test @@ -80,16 +80,16 @@ float4 main() : sv_target
[test] uniform 0 float 0.1 -draw quad +todo(sm>=6) draw quad probe all rgba (0.3, 0.2, 0.6, 0.3) 1 uniform 0 float 0.4 -draw quad +todo(sm>=6) draw quad probe all rgba (0.6, 0.5, 0.6, 0.3) 1 uniform 0 float 0.6 -draw quad +todo(sm>=6) draw quad probe all rgba (0.6, 0.5, 0.4, 0.5) 1 uniform 0 float 0.8 -draw quad +todo(sm>=6) draw quad probe all rgba (0.8, 0.7, 0.4, 0.5) 1
[pixel shader] @@ -136,13 +136,13 @@ float4 main() : sv_target
[test] uniform 0 float 0.1 -draw quad +todo(sm>=6) draw quad probe all rgba (0.2, 0.1, 0.2, 0.1) 1 uniform 0 float 0.5 -draw quad +todo(sm>=6) draw quad probe all rgba (0.5, 0.4, 1.0, 0.9) 1 uniform 0 float 0.9 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 0.9, 1.0, 0.6) 1
[pixel shader] @@ -239,23 +239,23 @@ float4 main() : sv_target
[test] uniform 0 float 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.3, 0.2, 0.3, 0.3) 1
uniform 0 float 0.1 -draw quad +todo(sm>=6) draw quad probe all rgba (0.3, 0.3, 0.3, 0.3) 1
uniform 0 float 0.3 -draw quad +todo(sm>=6) draw quad probe all rgba (0.3, 0.5, 0.3, 0.3) 1
uniform 0 float 0.7 -draw quad +todo(sm>=6) draw quad probe all rgba (0.3, 0.9, 0.7, 0.6) 1
uniform 0 float 0.9 -draw quad +todo(sm>=6) draw quad probe all rgba (0.4, 0.1, 0.7, 0.6) 1
[pixel shader todo] diff --git a/tests/hlsl/function.shader_test b/tests/hlsl/function.shader_test index 0db0477ed..d712f8522 100644 --- a/tests/hlsl/function.shader_test +++ b/tests/hlsl/function.shader_test @@ -89,7 +89,7 @@ float4 main() : sv_target return func(); }
-[pixel shader fail] +[pixel shader fail(sm<6)]
void foo() { @@ -226,7 +226,7 @@ probe all rgba (0.6, 0.1, 0.5, 0)
% Recursion is forbidden.
-[pixel shader notimpl] +[pixel shader notimpl(sm<6) fail(sm>=6)]
void bar();
@@ -246,7 +246,7 @@ float4 main() : sv_target return 0; }
-[pixel shader notimpl] +[pixel shader notimpl(sm<6) fail(sm>=6)]
% Even trivially finite recursion is forbidden.
@@ -317,7 +317,7 @@ probe all rgba (2.0, 3.0, 6.0, 7.0)
% Inline modifier used on entry point
-[pixel shader] +[pixel shader fail(sm>=6)] float func(float a) { return a + 1; diff --git a/tests/hlsl/fwidth.shader_test b/tests/hlsl/fwidth.shader_test index e302505f2..d4c20f4e0 100644 --- a/tests/hlsl/fwidth.shader_test +++ b/tests/hlsl/fwidth.shader_test @@ -18,7 +18,7 @@ float4 main(float4 pos : sv_position) : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe (10, 10) rgba (8.0, 8.0, 8.0, 8.0) probe (11, 10) rgba (8.0, 8.0, 8.0, 8.0) probe (12, 10) rgba (10.0, 10.0, 10.0, 10.0) diff --git a/tests/hlsl/gather-offset.shader_test b/tests/hlsl/gather-offset.shader_test index 51e6a6b64..6360d1fc8 100644 --- a/tests/hlsl/gather-offset.shader_test +++ b/tests/hlsl/gather-offset.shader_test @@ -23,7 +23,7 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (0.1, 0.2, 0.2, 0.1)
@@ -37,7 +37,7 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (0.0, 0.1, 0.1, 0.0)
@@ -55,7 +55,7 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (0.2, 0.2, 0.1, 0.1)
@@ -69,7 +69,7 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (0.1, 0.1, 0.0, 0.0)
@@ -83,7 +83,7 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (0.5, 0.0, 0.5, 0.0)
@@ -97,5 +97,5 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (0.0, 0.4, 0.0, 0.4) diff --git a/tests/hlsl/gather.shader_test b/tests/hlsl/gather.shader_test index 28fd6f9a5..9cfc2d599 100644 --- a/tests/hlsl/gather.shader_test +++ b/tests/hlsl/gather.shader_test @@ -23,7 +23,7 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (0.0, 0.1, 0.1, 0.0)
@@ -37,7 +37,7 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (0.1, 0.2, 0.2, 0.1)
@@ -55,7 +55,7 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (0.1, 0.1, 0.0, 0.0)
@@ -69,7 +69,7 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (0.2, 0.2, 0.1, 0.1)
@@ -97,7 +97,7 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (0.0, 0.5, 0.0, 0.5)
@@ -111,5 +111,5 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (0.4, 0.0, 0.4, 0.0) diff --git a/tests/hlsl/getdimensions.shader_test b/tests/hlsl/getdimensions.shader_test index 4d781b320..01d12f87a 100644 --- a/tests/hlsl/getdimensions.shader_test +++ b/tests/hlsl/getdimensions.shader_test @@ -28,7 +28,7 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (2.0, 3.0, 2.0, 3.0)
[texture 1] @@ -53,5 +53,5 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (2.0, 2.0, 1.0, 2.0) diff --git a/tests/hlsl/initializer-implicit-array.shader_test b/tests/hlsl/initializer-implicit-array.shader_test index 38c8234cb..fff2b8fdf 100644 --- a/tests/hlsl/initializer-implicit-array.shader_test +++ b/tests/hlsl/initializer-implicit-array.shader_test @@ -11,6 +11,10 @@ draw quad probe all rgba (50, 60, 70, 80)
+% dxcompiler emits a nop shader which returns immediately. +[require] +shader model < 6.0 + [pixel shader] float4 main() : sv_target { @@ -22,8 +26,10 @@ float4 main() : sv_target
[test] draw quad -probe all rgba (5.0, 6.0, 7.0, 8.0) +todo(sm>=6) probe all rgba (5.0, 6.0, 7.0, 8.0)
+[require] +% reset requirements
[pixel shader] float4 main() : sv_target @@ -121,7 +127,7 @@ float4 main() : sv_target }
-[pixel shader fail] +[pixel shader fail(sm<6)] // Implicit size array as function argument float4 fun(float4 arr[]) { @@ -150,18 +156,7 @@ float4 main() : sv_target }
-[pixel shader fail] -// Implicit size array as a cast -float4 main() : sv_target -{ - float2 arr1[4] = {1, 2, 3, 4, 5, 6, 7, 8}; - float4 arr2[2] = (float4 []) arr1; - - return 0.0; -} - - -[pixel shader fail] +[pixel shader fail(sm<6)] // Implicit size array as a typedef typedef float4 arrtype[];
@@ -174,52 +169,68 @@ float4 main() : sv_target
[pixel shader fail] -// Implicit size array of elements of size 0 +// Implicit size array of elements of size 0, without initializer struct emp { };
float4 main() : sv_target { - struct emp arr[] = {1, 2, 3, 4}; + struct emp arr[];
return 0.0; }
[pixel shader fail] -// Implicit size array of elements of size 0, without initializer +// Implicit size array with an initializer of size 0 struct emp { };
float4 main() : sv_target { - struct emp arr[]; + float4 arr[] = (struct emp) 42;
return 0.0; }
+% dxcompiler crashes. +[require] +shader model < 6.0 + + [pixel shader fail] -// Broadcast to an implicit size array +// Implicit size array as a cast float4 main() : sv_target { - int a[4] = (int[]) 0; + float2 arr1[4] = {1, 2, 3, 4, 5, 6, 7, 8}; + float4 arr2[2] = (float4 []) arr1;
return 0.0; }
[pixel shader fail] -// Implicit size array with an initializer of size 0 +// Implicit size array of elements of size 0 struct emp { };
float4 main() : sv_target { - float4 arr[] = (struct emp) 42; + struct emp arr[] = {1, 2, 3, 4}; + + return 0.0; +} + + +[pixel shader fail] +// Broadcast to an implicit size array +float4 main() : sv_target +{ + int a[4] = (int[]) 0;
return 0.0; } diff --git a/tests/hlsl/initializer-objects.shader_test b/tests/hlsl/initializer-objects.shader_test index d9c0bc91c..514a7cebb 100644 --- a/tests/hlsl/initializer-objects.shader_test +++ b/tests/hlsl/initializer-objects.shader_test @@ -25,7 +25,7 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (0.2, 0.2, 0.2, 0.1)
@@ -48,7 +48,7 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (31.1, 41.1, 51.1, 61.1) 1
diff --git a/tests/hlsl/intrinsic-override.shader_test b/tests/hlsl/intrinsic-override.shader_test index 55a23f21d..b95f80e7f 100644 --- a/tests/hlsl/intrinsic-override.shader_test +++ b/tests/hlsl/intrinsic-override.shader_test @@ -1,4 +1,4 @@ -[pixel shader] +[pixel shader fail(sm>=6)]
float2 max(float2 a, float2 b) { @@ -14,7 +14,7 @@ float4 main() : sv_target draw quad probe all rgba (0.3, 0.3, 0.4, 0.6)
-[pixel shader] +[pixel shader fail(sm>=6)]
float2 max(float2 a, float3 b) { @@ -29,3 +29,23 @@ float4 main() : sv_target [test] draw quad probe all rgba (0.3, 0.3, 0.3, 0.4) + + +[require] +shader model >= 6.0 + +[pixel shader] + +float2 max(float2 a, float2 b) +{ + return a + b; +} + +float4 main() : sv_target +{ + return float4(max(0.1, 0.2), 0.0, max(float2(0.1, 0.2), float2(0.3, 0.4))); +} + +[test] +draw quad +probe all rgba (0.2, 0.0, 0.3, 0.4) diff --git a/tests/hlsl/invalid.shader_test b/tests/hlsl/invalid.shader_test index ad0626520..815c86740 100644 --- a/tests/hlsl/invalid.shader_test +++ b/tests/hlsl/invalid.shader_test @@ -58,14 +58,14 @@ float4 main(float2 pos : TEXCOORD0) : sv_target return pos; }
-[pixel shader fail] +[pixel shader fail(sm<6)] float4 main() : sv_target { float a[0]; return 0; }
-[pixel shader fail] +[pixel shader fail(sm<6)] float4 main() : sv_target { float a[65537]; @@ -126,7 +126,7 @@ float4 main() : sv_target return 0; }
-[pixel shader fail] +[pixel shader fail(sm<6)] float4 main() : sv_target { const float4 x; @@ -186,7 +186,7 @@ void main(out float4 o : sv_target) sub(o); }
-[pixel shader fail] +[pixel shader fail(sm<6)] void sub(in out uniform float4 o) { } @@ -211,7 +211,7 @@ float4 main(void) : sv_target return 0; }
-[pixel shader fail] +[pixel shader fail(sm<6)] const const float4 c;
float4 main() : sv_target @@ -233,7 +233,7 @@ float4 main() : sv_target return a.a; }
-[pixel shader fail] +[pixel shader fail(sm<6)] struct apple { sampler sam; diff --git a/tests/hlsl/is-front-face.shader_test b/tests/hlsl/is-front-face.shader_test index 11447d262..162d4e634 100644 --- a/tests/hlsl/is-front-face.shader_test +++ b/tests/hlsl/is-front-face.shader_test @@ -22,7 +22,7 @@ float4 main(bool face : sv_isfrontface) : sv_target }
[test] -draw triangle strip 4 +todo(sm>=6) draw triangle strip 4 probe all rgba (0.0, 1.0, 0.0, 1.0)
[vertex buffer 0] @@ -32,5 +32,5 @@ probe all rgba (0.0, 1.0, 0.0, 1.0) 2.0 2.0
[test] -draw triangle strip 4 +todo(sm>=6) draw triangle strip 4 probe all rgba (1.0, 2.0, 1.0, 2.0) diff --git a/tests/hlsl/ldexp.shader_test b/tests/hlsl/ldexp.shader_test index f8ad40d8e..2db624067 100644 --- a/tests/hlsl/ldexp.shader_test +++ b/tests/hlsl/ldexp.shader_test @@ -10,7 +10,7 @@ float4 main() : SV_TARGET [test] uniform 0 float4 2.0 3.0 4.0 5.0 uniform 4 float4 0.0 -10.0 10.0 100.0 -draw quad +todo(sm>=6) draw quad probe all rgba (2.0, 0.00292968750, 4096.0, 6.33825300e+030) 2
[require] @@ -28,7 +28,7 @@ float4 main() : SV_TARGET [test] uniform 0 int4 2 3 4 5 uniform 4 int4 0 -10 10 100 -draw quad +todo(sm>=6) draw quad probe all rgba (2.0, 0.00292968750, 4096.0, 6.33825300e+030) 2
diff --git a/tests/hlsl/length.shader_test b/tests/hlsl/length.shader_test index d5a708e27..8653942e0 100644 --- a/tests/hlsl/length.shader_test +++ b/tests/hlsl/length.shader_test @@ -8,7 +8,7 @@ float4 main() : SV_TARGET
[test] uniform 0 float4 2.0 3.0 4.0 5.0 -draw quad +todo(sm>=6) draw quad probe all rgba (7.34846926, 7.34846926, 7.34846926, 7.34846926) 1
[pixel shader] @@ -21,7 +21,7 @@ float4 main() : SV_TARGET
[test] uniform 0 float4 2.0 3.0 4.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (5.38516474, 5.38516474, 5.38516474, 5.38516474) 1
[pixel shader] @@ -34,7 +34,7 @@ float4 main() : SV_TARGET
[test] uniform 0 float4 2.0 3.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (3.60555124, 3.60555124, 3.60555124, 3.60555124) 1
[pixel shader] @@ -47,7 +47,7 @@ float4 main() : SV_TARGET
[test] uniform 0 float4 2.0 0.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (2.0, 2.0, 2.0, 2.0)
[pixel shader] @@ -60,7 +60,7 @@ float4 main() : SV_TARGET
[test] uniform 0 float4 2.0 0.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (2.0, 2.0, 2.0, 2.0)
[pixel shader fail] diff --git a/tests/hlsl/lerp.shader_test b/tests/hlsl/lerp.shader_test index 15e90cef9..27c45fe7d 100644 --- a/tests/hlsl/lerp.shader_test +++ b/tests/hlsl/lerp.shader_test @@ -12,7 +12,7 @@ float4 main() : SV_TARGET uniform 0 float4 2.0 3.0 4.0 5.0 uniform 4 float4 0.0 -10.0 10.0 100.0 uniform 8 float4 0.0 1.0 -1.0 0.75 -draw quad +todo(sm>=6) draw quad probe all rgba (2.0, -10.0, -2.0, 76.25)
[require] @@ -32,7 +32,7 @@ float4 main() : SV_TARGET uniform 0 int4 2 3 4 0 uniform 4 int4 0 -10 10 1000000 uniform 8 int4 0 1 -1 1000000 -draw quad +todo(sm>=6) draw quad probe all rgba (2.0, -10.0, -2.0, 1e12)
diff --git a/tests/hlsl/lit.shader_test b/tests/hlsl/lit.shader_test index cbfffb4ee..5014c1ed0 100644 --- a/tests/hlsl/lit.shader_test +++ b/tests/hlsl/lit.shader_test @@ -1,73 +1,86 @@ [pixel shader] -float4 main(uniform float4 u) : sv_target +uniform float4 u; + +float4 main() : sv_target { return lit(u.x, u.y, u.z); }
[test] uniform 0 float4 -0.1 10.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 0.0, 0.0, 1.0)
[test] uniform 0 float4 1.2 -0.1 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 1.2, 0.0, 1.0)
[test] uniform 0 float4 1.2 2.0 3.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 1.2, 8.0, 1.0)
[pixel shader] -float4 main(uniform float4 u) : sv_target +uniform float4 u; + +float4 main() : sv_target { return lit(u.x, u.y, u.z) + lit(u.x, u.y, u.z); }
[test] uniform 0 float4 1.2 2.0 3.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (2.0, 2.4, 16.0, 2.0)
[pixel shader fail] -float4 main(uniform float4 u) : sv_target +uniform float4 u; + +float4 main() : sv_target { return lit(u.xy, u.y, u.z); }
[pixel shader fail] -float4 main(uniform float4 u) : sv_target +uniform float4 u; + +float4 main() : sv_target { return lit(u.x, u.xy, u.z); }
[pixel shader fail] -float4 main(uniform float4 u) : sv_target +uniform float4 u; + +float4 main() : sv_target { return lit(u.x, u.y, u.yz); }
[pixel shader fail] uniform float4x4 m; +uniform float4 u;
-float4 main(uniform float4 u) : sv_target +float4 main() : sv_target { return lit(m, u.y, u.z); }
[pixel shader fail] uniform float4x4 m; +uniform float4 u;
-float4 main(uniform float4 u) : sv_target +float4 main() : sv_target { return lit(u.x, m, u.z); }
[pixel shader fail] uniform float4x4 m; +uniform float4 u;
-float4 main(uniform float4 u) : sv_target +float4 main() : sv_target { return lit(u.x, u.y, m); } diff --git a/tests/hlsl/load-level.shader_test b/tests/hlsl/load-level.shader_test index 0f64bd5d5..9df2f01fb 100644 --- a/tests/hlsl/load-level.shader_test +++ b/tests/hlsl/load-level.shader_test @@ -22,10 +22,10 @@ float4 main() : sv_target
[test] uniform 0 uint 0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 0.0, 1.0, 0.0) uniform 0 uint 1 -draw quad +todo(sm>=6) draw quad probe all rgba (0.0, 0.0, 1.0, 0.0)
[pixel shader fail] @@ -47,5 +47,5 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 0.0, 1.0, 0.0) diff --git a/tests/hlsl/log.shader_test b/tests/hlsl/log.shader_test index b0f405d11..2f7d5c7c0 100644 --- a/tests/hlsl/log.shader_test +++ b/tests/hlsl/log.shader_test @@ -8,7 +8,7 @@ float4 main() : sv_target
[test] uniform 0 float4 2.0 4.0 5.0 0.4 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 2.0, 2.32192802, -1.32192802) 1
[pixel shader] @@ -21,7 +21,7 @@ float4 main() : sv_target
[test] uniform 0 float4 10.0 100.0 1.0 0.1 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 2.0, 0.0, -1.0) 1
[pixel shader] @@ -34,5 +34,5 @@ float4 main() : sv_target
[test] uniform 0 float4 3.0 10.0 1.0 0.1 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0986123, 2.302585, 0.0, -2.302585) 2 diff --git a/tests/hlsl/loop.shader_test b/tests/hlsl/loop.shader_test index bf26b69cf..4fbf14d8f 100644 --- a/tests/hlsl/loop.shader_test +++ b/tests/hlsl/loop.shader_test @@ -16,7 +16,7 @@ float4 main() : sv_target
[test] uniform 0 float 5.0 -draw quad +todo(sm>=6) draw quad probe all rgba (50.0, 50.0, 50.0, 50.0)
@@ -39,7 +39,7 @@ float4 main() : sv_target
[test] uniform 0 float 4.0 -draw quad +todo(sm>=6) draw quad probe all rgba (20.0, 20.0, 20.0, 20.0)
[pixel shader] @@ -68,7 +68,7 @@ float4 main() : sv_target
[test] uniform 0 float 4.0 -draw quad +todo(sm>=6) draw quad probe all rgba (409.1, 409.1, 409.1, 409.1)
[pixel shader] @@ -98,5 +98,5 @@ float4 main() : sv_target
[test] uniform 0 float 4.0 -draw quad +todo(sm>=6) draw quad probe all rgba (410.1, 410.1, 410.1, 410.1) diff --git a/tests/hlsl/majority-pragma.shader_test b/tests/hlsl/majority-pragma.shader_test index 808313e70..f7baa90b9 100644 --- a/tests/hlsl/majority-pragma.shader_test +++ b/tests/hlsl/majority-pragma.shader_test @@ -17,7 +17,7 @@ uniform 0 float4 0.1 0.2 0.0 0.0 uniform 4 float4 0.3 0.4 0.0 0.0 uniform 8 float4 0.1 0.3 0.0 0.0 uniform 12 float4 0.2 0.4 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.17, 0.39, 0.17, 0.39) 1
@@ -40,7 +40,7 @@ float4 main() : sv_target [test] uniform 0 float4 0.1 0.2 0.0 0.0 uniform 4 float4 0.3 0.4 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.1, 0.2, 0.3, 0.4)
@@ -61,7 +61,7 @@ uniform 0 float4 0.0 0.0 0.0 0.0 uniform 4 float4 0.0 0.0 0.0 0.0 uniform 8 float4 0.5 0.6 0.0 0.0 uniform 12 float4 0.7 0.8 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.5, 0.6, 0.7, 0.8)
@@ -90,7 +90,7 @@ float4 main() : sv_target [test] uniform 0 float4 0.1 0.2 0.0 0.0 uniform 4 float4 0.3 0.4 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.23, 0.34, 0.5, 0.5) 1
@@ -111,7 +111,7 @@ float4 main() : sv_target [test] uniform 0 float4 0.1 0.2 0.0 0.0 uniform 4 float4 0.3 0.4 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.1, 0.2, 0.3, 0.4)
@@ -149,7 +149,7 @@ uniform 0 float4 0.3 0.4 0.0 0.0 uniform 4 float4 0.0 0.0 0.0 0.0 uniform 8 float4 0.0 0.0 0.0 0.0 uniform 12 float4 0.5 0.6 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.3, 0.4, 0.5, 0.6)
@@ -173,7 +173,7 @@ float4 main() : sv_target [test] uniform 0 float4 0.1 0.2 0.0 0.0 uniform 4 float4 0.3 0.4 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.1, 0.2, 0.3, 0.4)
@@ -201,7 +201,7 @@ float4 main() : sv_target [test] uniform 0 float4 0.2 0.4 0.0 0.0 uniform 4 float4 0.3 0.5 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.2, 0.3, 0.4, 0.5)
@@ -221,7 +221,7 @@ uniform 0 float4 0.3 0.0 0.0 0.0 uniform 4 float4 0.4 0.0 0.0 0.0 uniform 8 float4 0.0 0.5 0.0 0.0 uniform 12 float4 0.0 0.6 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.3, 0.4, 0.5, 0.6)
% Compiler options @@ -245,7 +245,7 @@ uniform 0 float4 0.1 0.5 0.9 1.3 uniform 4 float4 0.2 0.6 1.0 1.4 uniform 8 float4 0.3 0.7 1.1 1.5 uniform 12 float4 0.4 0.8 1.2 1.6 -draw quad +todo(sm>=6) draw quad probe all rgba (0.2, 0.3, 0.6, 0.7) 1
[require] @@ -267,7 +267,7 @@ uniform 0 float4 0.1 0.5 0.9 1.3 uniform 4 float4 0.2 0.6 1.0 1.4 uniform 8 float4 0.3 0.7 1.1 1.5 uniform 12 float4 0.4 0.8 1.2 1.6 -draw quad +todo(sm>=6) draw quad probe all rgba (0.2, 0.3, 0.6, 0.7) 1
[require] @@ -289,7 +289,7 @@ uniform 0 float4 0.1 0.5 0.9 1.3 uniform 4 float4 0.2 0.6 1.0 1.4 uniform 8 float4 0.3 0.7 1.1 1.5 uniform 12 float4 0.4 0.8 1.2 1.6 -draw quad +todo(sm>=6) draw quad probe all rgba (0.5, 0.9, 0.6, 1.0) 1
[require] @@ -317,7 +317,7 @@ uniform 16 float4 1.7 2.1 2.5 2.9 uniform 20 float4 1.8 2.2 2.6 3.0 uniform 24 float4 1.9 2.3 2.7 3.1 uniform 28 float4 2.0 2.4 2.8 3.2 -draw quad +todo(sm>=6) draw quad probe all rgba (0.3, 0.4, 2.5, 2.9) 1
[require] @@ -345,7 +345,7 @@ uniform 16 float4 1.7 2.1 2.5 2.9 uniform 20 float4 1.8 2.2 2.6 3.0 uniform 24 float4 1.9 2.3 2.7 3.1 uniform 28 float4 2.0 2.4 2.8 3.2 -draw quad +todo(sm>=6) draw quad probe all rgba (1.2, 1.6, 3.1, 3.2) 1
[require] @@ -365,5 +365,5 @@ float4 main() : sv_target [test] uniform 0 float4 0.1 0.2 0.0 0.0 uniform 4 float4 0.3 0.4 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.1, 0.3, 0.2, 0.4) 1 diff --git a/tests/hlsl/majority-syntax.shader_test b/tests/hlsl/majority-syntax.shader_test index 4ab385a5d..63e5d2986 100644 --- a/tests/hlsl/majority-syntax.shader_test +++ b/tests/hlsl/majority-syntax.shader_test @@ -11,10 +11,10 @@ float4 main() : sv_target [test] uniform 0 float4 0.1 0.3 0.0 0.0 uniform 4 float4 0.2 0.4 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.1, 0.3, 0.2, 0.4)
-[pixel shader fail] +[pixel shader fail(sm<6)] row_major row_major float4x4 m;
float4 main() : sv_target diff --git a/tests/hlsl/majority-typedef.shader_test b/tests/hlsl/majority-typedef.shader_test index 1460e9a08..fa62dd5f7 100644 --- a/tests/hlsl/majority-typedef.shader_test +++ b/tests/hlsl/majority-typedef.shader_test @@ -18,5 +18,5 @@ uniform 0 float4 0.1 0.2 0.0 0.0 uniform 4 float4 0.3 0.4 0.0 0.0 uniform 8 float4 0.1 0.3 0.0 0.0 uniform 12 float4 0.2 0.4 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.17, 0.39, 0.17, 0.39) 1 diff --git a/tests/hlsl/math.shader_test b/tests/hlsl/math.shader_test index 6bd9656d8..8f0592275 100644 --- a/tests/hlsl/math.shader_test +++ b/tests/hlsl/math.shader_test @@ -1,5 +1,8 @@ [pixel shader] -float4 main(uniform float4 a, uniform float2 b) : SV_TARGET +uniform float4 a; +uniform float2 b; + +float4 main() : SV_TARGET { float u = a.x, v = a.y, w = a.z, x = a.w, y = b.x, z = b.y; return float4(x * y - z / w + --u / -v, @@ -11,5 +14,5 @@ float4 main(uniform float4 a, uniform float2 b) : SV_TARGET [test] uniform 0 float4 2.5 0.3 0.2 0.7 uniform 4 float4 0.1 1.5 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (-12.43, 9.833333, 1.6, 35.0) 1 diff --git a/tests/hlsl/matrix-indexing.shader_test b/tests/hlsl/matrix-indexing.shader_test index a57d8fb8b..a61983eef 100644 --- a/tests/hlsl/matrix-indexing.shader_test +++ b/tests/hlsl/matrix-indexing.shader_test @@ -11,7 +11,7 @@ uniform 0 float4 1.0 2.0 3.0 4.0 uniform 4 float4 5.0 6.0 7.0 8.0 uniform 8 float4 9.0 10.0 11.0 12.0 uniform 12 float4 13.0 14.0 15.0 16.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 2.0, 10.0, 15.0)
[pixel shader] @@ -27,7 +27,7 @@ uniform 0 float4 1.0 2.0 3.0 4.0 uniform 4 float4 5.0 6.0 7.0 8.0 uniform 8 float4 9.0 10.0 11.0 12.0 uniform 12 float4 13.0 14.0 15.0 16.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 2.0, 10.0, 15.0)
[pixel shader] @@ -43,7 +43,7 @@ uniform 0 float4 1.0 2.0 3.0 4.0 uniform 4 float4 5.0 6.0 7.0 8.0 uniform 8 float4 9.0 10.0 11.0 12.0 uniform 12 float4 13.0 14.0 15.0 16.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 5.0, 7.0, 12.0)
[pixel shader] @@ -58,7 +58,7 @@ float4 main() : SV_TARGET [test] uniform 0 float4 1.0 2.0 3.0 0.0 uniform 4 float4 5.0 6.0 7.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 3.0, 6.0, 7.0)
[pixel shader] @@ -120,7 +120,7 @@ float4 main() : sv_target
[test] uniform 0 float 2 -draw quad +todo(sm>=6) draw quad probe all rgba (8, 9, 10, 11)
diff --git a/tests/hlsl/matrix-semantics.shader_test b/tests/hlsl/matrix-semantics.shader_test index b704dc1a6..082c69c0c 100644 --- a/tests/hlsl/matrix-semantics.shader_test +++ b/tests/hlsl/matrix-semantics.shader_test @@ -37,27 +37,27 @@ size (640, 480) format r32 float size (640, 480)
-[pixel shader] +[pixel shader fail(sm>=6)] row_major float4x1 main() : sv_target { return float4(1.0, 2.0, 3.0, 4.0); }
[test] -draw quad +todo(sm>=6) draw quad probe render target 0 all r (1.0) probe render target 1 all r (2.0) probe render target 2 all r (3.0) probe render target 3 all r (4.0)
-[pixel shader] +[pixel shader fail(sm>=6)] float1x4 main() : sv_target { return float4(1.0, 2.0, 3.0, 4.0); }
[test] -draw quad +todo(sm>=6) draw quad probe render target 0 all r (1.0) probe render target 1 all r (2.0) probe render target 2 all r (3.0) @@ -70,7 +70,7 @@ void main(out float1x2 x : sv_target0, out float1x2 y : sv_target1) y = float2(5.0, 6.0); }
-[pixel shader] +[pixel shader fail(sm>=6)] void main(out float1x2 x : sv_target0, out float1x2 y : sv_target2) { x = float2(1.0, 2.0); @@ -78,7 +78,7 @@ void main(out float1x2 x : sv_target0, out float1x2 y : sv_target2) }
[test] -draw quad +todo(sm>=6) draw quad probe render target 0 all r (1.0) probe render target 1 all r (2.0) probe render target 2 all r (5.0) @@ -88,7 +88,7 @@ probe render target 3 all r (6.0) format r32g32b32a32 float size (640, 480)
-[pixel shader] +[pixel shader fail(sm>=6)] void main(out row_major float1x4 x : sv_target0, out float1x2 y : sv_target1) { x = float4(1.0, 2.0, 3.0, 4.0); @@ -96,7 +96,7 @@ void main(out row_major float1x4 x : sv_target0, out float1x2 y : sv_target1) }
[test] -draw quad +todo(sm>=6) draw quad probe render target 0 all rgba (1.0, 2.0, 3.0, 4.0) probe render target 1 all r (5.0) probe render target 2 all r (6.0) diff --git a/tests/hlsl/max.shader_test b/tests/hlsl/max.shader_test index 3a5c3125a..e2763df46 100644 --- a/tests/hlsl/max.shader_test +++ b/tests/hlsl/max.shader_test @@ -1,17 +1,21 @@ [pixel shader] -float4 main(uniform float2 u) : sv_target +uniform float2 u; + +float4 main() : sv_target { return float4(max(u.x, u.y), max(2, 2.1), max(true, 2), max(-1, -1)); }
[test] uniform 0 float4 0.7 -0.1 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.7, 2.1, 2.0, -1.0)
[pixel shader] -float4 main(uniform float4 u) : sv_target +uniform float4 u; + +float4 main() : sv_target { float3 a = float3(-0.1, 0.2, 0.3);
@@ -20,7 +24,7 @@ float4 main(uniform float4 u) : sv_target
[test] uniform 0 float4 0.7 -0.1 0.4 0.8 -draw quad +todo(sm>=6) draw quad probe all rgba (0.7, 0.8, 0.7, 0.2)
diff --git a/tests/hlsl/nested-arrays.shader_test b/tests/hlsl/nested-arrays.shader_test index 66ae93e10..b7aeec442 100644 --- a/tests/hlsl/nested-arrays.shader_test +++ b/tests/hlsl/nested-arrays.shader_test @@ -1,4 +1,4 @@ -[pixel shader fail] +[pixel shader fail(sm<6)] uniform float4 color[2][3];
float4 main() : sv_target @@ -21,5 +21,5 @@ uniform 8 float4 0.3 0.0 0.0 0.0 uniform 12 float4 0.4 0.0 0.0 0.0 uniform 16 float4 0.5 0.0 0.0 0.0 uniform 20 float4 0.6 0.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.4, 0.1, 0.6, 0.3) diff --git a/tests/hlsl/nointerpolation.shader_test b/tests/hlsl/nointerpolation.shader_test index 6c218be86..a3c9edfd1 100644 --- a/tests/hlsl/nointerpolation.shader_test +++ b/tests/hlsl/nointerpolation.shader_test @@ -23,7 +23,7 @@ float4 main(nointerpolation float4 t : texcoord) : sv_target }
[test] -draw triangle list 3 +todo(sm>=6) draw triangle list 3 probe all rgba (0.0, 1.0, 0.0, 1.0)
[vertex shader] @@ -50,7 +50,7 @@ float4 main(ps_input input) : sv_target }
[test] -draw triangle list 3 +todo(sm>=6) draw triangle list 3 probe all rgba (0.0, 1.0, 0.0, 1.0)
[vertex shader] @@ -77,7 +77,7 @@ float4 main(nointerpolation ps_input input) : sv_target }
[test] -draw triangle list 3 +todo(sm>=6) draw triangle list 3 probe all rgba (0.0, 1.0, 0.0, 1.0)
[vertex shader] @@ -104,7 +104,7 @@ float4 main(centroid ps_input input) : sv_target }
[test] -draw triangle list 3 +todo(sm>=6) draw triangle list 3 probe all rgba (0.0, 1.0, 0.0, 1.0)
[vertex shader] @@ -131,7 +131,7 @@ float4 main(nointerpolation ps_input input) : sv_target }
[test] -draw triangle list 3 +todo(sm>=6) draw triangle list 3 probe all rgba (0.0, 1.0, 0.0, 1.0)
[vertex shader fail todo] diff --git a/tests/hlsl/normalize.shader_test b/tests/hlsl/normalize.shader_test index 359a7590d..0fe0dea3c 100644 --- a/tests/hlsl/normalize.shader_test +++ b/tests/hlsl/normalize.shader_test @@ -8,7 +8,7 @@ float4 main() : SV_TARGET
[test] uniform 0 float4 2.0 3.0 4.0 5.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.272165537, 0.408248305, 0.544331074, 0.680413842) 2
[pixel shader] @@ -21,7 +21,7 @@ float4 main() : SV_TARGET
[test] uniform 0 float4 2.0 3.0 4.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.371390700, 0.557086051, 0.742781401, 0.0) 1
[pixel shader] @@ -34,7 +34,7 @@ float4 main() : SV_TARGET
[test] uniform 0 float4 2.0 3.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.554700196, 0.832050323, 0.0, 0.0) 1
[pixel shader] @@ -47,7 +47,7 @@ float4 main() : SV_TARGET
[test] uniform 0 float4 2.0 0.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0)
[pixel shader] @@ -60,7 +60,7 @@ float4 main() : SV_TARGET
[test] uniform 0 float4 2.0 0.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0)
[pixel shader fail] diff --git a/tests/hlsl/numeric-types.shader_test b/tests/hlsl/numeric-types.shader_test index 7504f95aa..dfdd7a538 100644 --- a/tests/hlsl/numeric-types.shader_test +++ b/tests/hlsl/numeric-types.shader_test @@ -38,7 +38,7 @@ vector main() : sv_target return ret; }
-[pixel shader fail] +[pixel shader fail(sm<6)] vector main() : sv_target { vector<float> ret = vector(1.0, 2.0, 3.0, 4.0); @@ -71,7 +71,7 @@ float4 main() : sv_target draw quad probe all rgba (5.0, 6.0, 7.0, 0.0)
-[pixel shader fail] +[pixel shader fail(sm<6)] float4 main() : sv_target { matrix m = matrix<float>(1.0, 2.0, 3.0, 4.0, @@ -81,7 +81,7 @@ float4 main() : sv_target return m[1]; }
-[pixel shader fail] +[pixel shader fail(sm<6)] float4 main() : sv_target { matrix m = matrix<float, 4>(1.0, 2.0, 3.0, 4.0, diff --git a/tests/hlsl/numthreads.shader_test b/tests/hlsl/numthreads.shader_test index 404d7d763..fb11dc480 100644 --- a/tests/hlsl/numthreads.shader_test +++ b/tests/hlsl/numthreads.shader_test @@ -93,7 +93,7 @@ void main() {} [numthreads("1", 1, 1)] void main() {}
-[compute shader todo] +[compute shader todo fail(sm>=6)] static int x = 1;
[numthreads(x, 1, 1)] @@ -103,7 +103,7 @@ void main() {}
void main() {}
-[compute shader fail] +[compute shader fail(sm<6)]
[NumThreads(1, 1, 1)] void main() {} @@ -122,7 +122,7 @@ void main() {} [numthreads(1, 1, 1)] void main();
-[compute shader fail] +[compute shader fail(sm<6)]
void main();
@@ -153,7 +153,7 @@ static int x = 1; [numthreads((x = 2), 1, 1)] void main() {}
-[compute shader] +[compute shader fail(sm>=6)]
static int x = 1;
@@ -185,7 +185,7 @@ void main(uint2 id : sv_dispatchthreadid) }
[test] -dispatch 1 1 1 +todo(sm>=6) dispatch 1 1 1 probe uav 0 (0, 0) r (2.0) probe uav 0 (0, 1) r (1.0) probe uav 0 (1, 0) r (2.0) diff --git a/tests/hlsl/object-field-offsets.shader_test b/tests/hlsl/object-field-offsets.shader_test index 8afd9af7d..d1741c3e4 100644 --- a/tests/hlsl/object-field-offsets.shader_test +++ b/tests/hlsl/object-field-offsets.shader_test @@ -19,7 +19,7 @@ float4 main() : sv_target [test] uniform 0 float4 1.0 2.0 3.0 4.0 uniform 4 float4 5.0 6.0 7.0 8.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 2.0, 3.0, 0.0)
@@ -45,7 +45,7 @@ float4 main() : sv_target [test] uniform 0 float4 1.0 2.0 3.0 4.0 uniform 4 float4 5.0 6.0 7.0 8.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 2.0, 5.0, 0.0)
@@ -66,5 +66,5 @@ float4 main() : sv_target [test] uniform 0 float4 1.0 2.0 3.0 4.0 uniform 4 float4 5.0 6.0 7.0 8.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 2.0, 5.0, 0.0) diff --git a/tests/hlsl/object-parameters.shader_test b/tests/hlsl/object-parameters.shader_test index c6109aef7..0d279fb27 100644 --- a/tests/hlsl/object-parameters.shader_test +++ b/tests/hlsl/object-parameters.shader_test @@ -7,6 +7,11 @@ float4 main(out Texture2D tex : TEXTURE) : sv_target }
+% dxcompiler crashes. +[require] +shader model < 6.0 + + [pixel shader fail todo] struct params { @@ -23,7 +28,7 @@ float4 main(inout params x) : sv_target shader model >= 5.0
-[pixel shader todo] +[pixel shader todo fail(sm>=6)] uniform float global;
struct apple @@ -32,7 +37,12 @@ struct apple float4 pos : sv_position; };
+#ifdef __hlsl_dx_compiler +uniform float param; +float4 main(struct apple input) : sv_target +#else float4 main(struct apple input, uniform float param) : sv_target +#endif { return input.tex.Load(int3(0, 0, 0)) + global + param + input.pos; } @@ -89,7 +99,7 @@ filter linear linear linear address clamp clamp clamp
-[pixel shader todo] +[pixel shader todo fail(sm>=6)] struct apple { Texture2D unused; // must reserve t1 @@ -113,7 +123,7 @@ todo draw quad todo probe all rgba (416.0, 416.0, 416.0, 111.0)
-[pixel shader todo] +[pixel shader todo fail(sm>=6)] Texture2D tex;
struct apple @@ -157,7 +167,7 @@ filter point point point address clamp clamp clamp
-[pixel shader todo] +[pixel shader todo fail(sm>=6)] Texture2D tex; sampler sam0; // must reserve s3
diff --git a/tests/hlsl/object-references.shader_test b/tests/hlsl/object-references.shader_test index 5ed4dcd63..e7b2bef06 100644 --- a/tests/hlsl/object-references.shader_test +++ b/tests/hlsl/object-references.shader_test @@ -46,7 +46,7 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (77.77, 77.77, 77.77, 77.77)
@@ -73,7 +73,7 @@ float4 main(float4 pos : sv_position) : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe (0, 0) rgba (0.1, 0.2, 0.3, 0.4) probe (1, 0) rgba (0.5, 0.7, 0.6, 0.8) probe (0, 1) rgba (0.6, 0.5, 0.2, 0.1) @@ -111,7 +111,7 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (312, 312, 312, 111)
@@ -134,11 +134,11 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (2132, 2132, 2132, 1111)
-[pixel shader fail] +[pixel shader fail(sm<6)] Texture2D tex[3]; uniform int n;
@@ -158,7 +158,7 @@ float4 main() : sv_target }
-[pixel shader fail] +[pixel shader fail(sm<6)] // Note: Only valid in shader model 5.1 Texture2D tex[3]; uniform int n; @@ -169,7 +169,7 @@ float4 main() : sv_target }
-[pixel shader fail] +[pixel shader fail(sm<6)] // Note: Only valid in shader model 5.1 RWTexture2D<float4> tex[3]; uniform int n; @@ -202,7 +202,7 @@ float4 main() : sv_target
[test] uniform 0 float 10.0 -draw quad +todo(sm>=6) draw quad probe (0, 0) rgba (11.0, 12.0, 13.0, 11.0)
@@ -223,7 +223,7 @@ shader model >= 5.0 size (1, 1) 1.0 2.0 3.0 4.0
-[pixel shader todo] +[pixel shader todo fail(sm>=6)] struct apple { Texture2D tex; float4 fo : COLOR; diff --git a/tests/hlsl/pow.shader_test b/tests/hlsl/pow.shader_test index 1bb3bd944..d8f5eec9f 100644 --- a/tests/hlsl/pow.shader_test +++ b/tests/hlsl/pow.shader_test @@ -1,12 +1,14 @@ [pixel shader] -float4 main(uniform float4 u) : sv_target +uniform float4 u; + +float4 main() : sv_target { return float4(pow(u.y, 3), pow(u.xy, u.zw), pow(0.5, u.w)); }
[test] uniform 0 float4 0.4 0.8 2.5 2.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.512, 0.101192884, 0.64, 0.25) 4
diff --git a/tests/hlsl/reflect.shader_test b/tests/hlsl/reflect.shader_test index 02488589b..808b4b772 100644 --- a/tests/hlsl/reflect.shader_test +++ b/tests/hlsl/reflect.shader_test @@ -10,7 +10,7 @@ float4 main() : sv_target [test] uniform 0 float4 0.5 -0.1 0.2 0.3 uniform 4 float4 0.6 0.4 -0.3 1.0 -draw quad +todo(sm>=6) draw quad probe all rgba (-0.1, -0.5, 0.5, -0.7) 4
[pixel shader] @@ -27,7 +27,7 @@ float4 main() : sv_target [test] uniform 0 float4 0.5 0.0 0.0 0.0 uniform 4 float4 0.6 0.4 -0.3 1.0 -draw quad +todo(sm>=6) draw quad probe all rgba (-0.52, -0.18, 1.01, -1.2) 4
[pixel shader] @@ -44,7 +44,7 @@ float4 main() : sv_target [test] uniform 0 float4 0.5 -0.1 0.2 0.3 uniform 4 float4 0.6 0.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (-0.148, -0.748, -0.448, -0.348) 4
[pixel shader] @@ -62,7 +62,7 @@ float4 main() : sv_target [test] uniform 0 float4 0.5 0.0 0.0 0.0 uniform 4 float4 0.6 0.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.14, 0.14, 0.14, 0.14) 4
[pixel shader] @@ -79,7 +79,7 @@ float4 main() : sv_target [test] uniform 0 float4 0.5 -0.1 0.0 0.0 uniform 4 float4 0.6 0.4 -0.3 1.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.188, -0.308, 0.0, 0.0) 4
[pixel shader] @@ -97,5 +97,5 @@ float4 main() : sv_target [test] uniform 0 float4 0.5 -0.1 0.2 0.0 uniform 4 float4 0.6 0.4 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.188, -0.308, 0.0, 0.0) 4 diff --git a/tests/hlsl/register-reservations.shader_test b/tests/hlsl/register-reservations.shader_test index 13e2fac2c..9539b05ff 100644 --- a/tests/hlsl/register-reservations.shader_test +++ b/tests/hlsl/register-reservations.shader_test @@ -34,7 +34,7 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (41.0, 41.0, 41.0, 1089.0)
@@ -50,7 +50,7 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (0.0, 0.0, 0.0, 99.0)
@@ -65,7 +65,7 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 1.0, 1.0, 99.0)
@@ -80,12 +80,12 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (0.0, 0.0, 0.0, 99.0)
% Register reservation with incorrect register type. -[pixel shader] +[pixel shader fail(sm>=6)] sampler2D unused : register(t0); Texture2D tex;
@@ -109,7 +109,7 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (4.0, 4.0, 4.0, 99.0)
@@ -125,7 +125,7 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 1.0, 1.0, 99.0)
@@ -140,7 +140,7 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (2.0, 2.0, 2.0, 99.0)
@@ -154,7 +154,7 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (2.0, 2.0, 2.0, 99.0)
@@ -184,7 +184,7 @@ filter linear linear linear address clamp clamp clamp
% If a struct spans many object register sets and one is reserved, all other used object register sets must be. -[pixel shader fail todo] +[pixel shader fail(sm<6) todo] struct { Texture2D tex; @@ -227,5 +227,5 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad todo probe all rgba (1.0, 1.0, 1.0, 99.0) diff --git a/tests/hlsl/return-implicit-conversion.shader_test b/tests/hlsl/return-implicit-conversion.shader_test index 1767748be..7070b28ae 100644 --- a/tests/hlsl/return-implicit-conversion.shader_test +++ b/tests/hlsl/return-implicit-conversion.shader_test @@ -165,7 +165,7 @@ float4 main() : sv_target draw quad probe all rgba (0.4, 0.3, 0.2, 0.0)
-[pixel shader fail todo] +[pixel shader fail(sm<6) todo] float3x1 func() { return float4(0.4, 0.3, 0.2, 0.1); diff --git a/tests/hlsl/return.shader_test b/tests/hlsl/return.shader_test index 9f800d1a7..b8ebac0a1 100644 --- a/tests/hlsl/return.shader_test +++ b/tests/hlsl/return.shader_test @@ -38,10 +38,10 @@ float4 main() : sv_target
[test] uniform 0 float 0.2 -draw quad +todo(sm>=6) draw quad probe all rgba (0.1, 0.2, 0.3, 0.4) uniform 0 float 0.8 -draw quad +todo(sm>=6) draw quad probe all rgba (0.5, 0.6, 0.7, 0.8)
[pixel shader] @@ -65,10 +65,10 @@ void main(out float4 ret : sv_target)
[test] uniform 0 float 0.2 -draw quad +todo(sm>=6) draw quad probe all rgba (0.3, 0.4, 0.5, 0.6) uniform 0 float 0.8 -draw quad +todo(sm>=6) draw quad probe all rgba (0.1, 0.2, 0.3, 0.4)
[pixel shader] @@ -92,13 +92,13 @@ void main(out float4 ret : sv_target)
[test] uniform 0 float 0.1 -draw quad +todo(sm>=6) draw quad probe all rgba (0.1, 0.2, 0.3, 0.4) 1 uniform 0 float 0.5 -draw quad +todo(sm>=6) draw quad probe all rgba (0.2, 0.3, 0.4, 0.5) 1 uniform 0 float 0.9 -draw quad +todo(sm>=6) draw quad probe all rgba (0.5, 0.6, 0.7, 0.8) 1
[pixel shader] @@ -119,13 +119,13 @@ void main(out float4 ret : sv_target)
[test] uniform 0 float 0.1 -draw quad +todo(sm>=6) draw quad probe all rgba (0.1, 0.2, 0.3, 0.4) 1 uniform 0 float 0.5 -draw quad +todo(sm>=6) draw quad probe all rgba (0.5, 0.6, 0.7, 0.8) 1 uniform 0 float 0.9 -draw quad +todo(sm>=6) draw quad probe all rgba (0.4, 0.5, 0.6, 0.7) 1
[pixel shader] @@ -166,23 +166,23 @@ void main(out float4 ret : sv_target)
[test] uniform 0 float 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.1, 0.1, 0.1, 0.1) 1
uniform 0 float 0.1 -draw quad +todo(sm>=6) draw quad probe all rgba (0.2, 0.2, 0.2, 0.2) 1
uniform 0 float 0.3 -draw quad +todo(sm>=6) draw quad probe all rgba (0.4, 0.4, 0.4, 0.4) 1
uniform 0 float 0.7 -draw quad +todo(sm>=6) draw quad probe all rgba (0.8, 0.8, 0.8, 0.8) 1
uniform 0 float 0.9 -draw quad +todo(sm>=6) draw quad probe all rgba (0.9, 0.9, 0.9, 0.9) 1
[pixel shader] @@ -211,10 +211,10 @@ void main(out float4 ret : sv_target)
[test] uniform 0 float 0.2 -draw quad +todo(sm>=6) draw quad probe all rgba (0.2, 0.2, 0.2, 0.2) uniform 0 float 0.8 -draw quad +todo(sm>=6) draw quad probe all rgba (0.5, 0.5, 0.5, 0.5)
[pixel shader todo] diff --git a/tests/hlsl/round.shader_test b/tests/hlsl/round.shader_test index 5e40dc6dd..2a32b3ec2 100644 --- a/tests/hlsl/round.shader_test +++ b/tests/hlsl/round.shader_test @@ -1,18 +1,22 @@ [pixel shader] -float4 main(uniform float4 u) : sv_target +uniform float4 u; + +float4 main() : sv_target { return round(u); }
[test] uniform 0 float4 -0.4 -6.6 7.6 3.4 -draw quad +todo(sm>=6) draw quad probe all rgba (0.0, -7.0, 8.0, 3.0) 4
[pixel shader] -float4 main(uniform float4 u) : sv_target +uniform float4 u; + +float4 main() : sv_target { float a = round(u.r); int2 b = round(u.gb); @@ -22,13 +26,15 @@ float4 main(uniform float4 u) : sv_target
[test] uniform 0 float4 -0.4 -6.6 7.6 3.4 -draw quad +todo(sm>=6) draw quad probe all rgba (-7.0, 8.0, 0.0, 3.0) 4
[pixel shader] -float4 main(uniform float4 u) : sv_target +uniform float4 u; + +float4 main() : sv_target { int4 i = u; return round(i); @@ -36,5 +42,5 @@ float4 main(uniform float4 u) : sv_target
[test] uniform 0 float4 -1 0 2 10 -draw quad +todo(sm>=6) draw quad probe all rgba (-1.0, 0.0, 2.0, 10.0) 4 diff --git a/tests/hlsl/sample-bias.shader_test b/tests/hlsl/sample-bias.shader_test index 08e506965..e56945d06 100644 --- a/tests/hlsl/sample-bias.shader_test +++ b/tests/hlsl/sample-bias.shader_test @@ -31,13 +31,13 @@ float4 main(float2 coord : texcoord) : sv_target
[test] uniform 0 float4 6.5 0.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (10.0, 0.0, 10.0, 0.0)
uniform 0 float4 7.5 0.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (4.0, 0.0, 10.0, 0.0)
uniform 0 float4 8.5 0.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.0, 0.0, 10.0, 0.0) diff --git a/tests/hlsl/sample-grad.shader_test b/tests/hlsl/sample-grad.shader_test index c37da299c..298037a77 100644 --- a/tests/hlsl/sample-grad.shader_test +++ b/tests/hlsl/sample-grad.shader_test @@ -26,11 +26,11 @@ float4 main() : sv_target
[test] uniform 0 float4 0.0 0.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 0.0, 1.0, 0.0) uniform 0 float4 1.0 1.0 1.0 1.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.0, 0.0, 1.0, 0.0) uniform 0 float4 2.0 2.0 2.0 2.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.0, 0.0, 1.0, 0.0) diff --git a/tests/hlsl/sample-level.shader_test b/tests/hlsl/sample-level.shader_test index ec7c7e2a2..c91c65493 100644 --- a/tests/hlsl/sample-level.shader_test +++ b/tests/hlsl/sample-level.shader_test @@ -26,11 +26,11 @@ float4 main() : sv_target
[test] uniform 0 float4 0.0 0.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 0.0, 1.0, 0.0) uniform 0 float4 0.5 0.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.5, 0.0, 1.0, 0.0) uniform 0 float4 1.0 0.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.0, 0.0, 1.0, 0.0) diff --git a/tests/hlsl/sampler-offset.shader_test b/tests/hlsl/sampler-offset.shader_test index 6f8357dfa..498a8ed3a 100644 --- a/tests/hlsl/sampler-offset.shader_test +++ b/tests/hlsl/sampler-offset.shader_test @@ -22,7 +22,7 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (0.1, 0.2, 0.5, 0.0)
@@ -36,7 +36,7 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (0.2, 0.2, 0.0, 0.4)
@@ -50,5 +50,5 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (0.0, 0.2, 0.0, 0.4) diff --git a/tests/hlsl/sampler.shader_test b/tests/hlsl/sampler.shader_test index c4b38b327..caff7b2fa 100644 --- a/tests/hlsl/sampler.shader_test +++ b/tests/hlsl/sampler.shader_test @@ -17,7 +17,7 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (0.25, 0, 0.25, 0)
[pixel shader] @@ -30,7 +30,7 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (0.25, 0, 0.25, 0)
[pixel shader fail] @@ -53,7 +53,7 @@ float4 main() : sv_target [require] options: backcompat
-[pixel shader] +[pixel shader fail(sm>=6)] samplerCUBE s;
float4 main() : sv_target @@ -61,7 +61,7 @@ float4 main() : sv_target return texCUBE(s, float3(0.0, 0.0, 0.0)); }
-[pixel shader] +[pixel shader fail(sm>=6)] sampler1D s;
float4 main() : sv_target diff --git a/tests/hlsl/saturate.shader_test b/tests/hlsl/saturate.shader_test index 41ccc62ae..2ed83cf66 100644 --- a/tests/hlsl/saturate.shader_test +++ b/tests/hlsl/saturate.shader_test @@ -1,16 +1,20 @@ [pixel shader] -float4 main(uniform float2 u) : sv_target +uniform float2 u; + +float4 main() : sv_target { return float4(saturate(u), saturate(u.x + 0.5), saturate(-1.2)); }
[test] uniform 0 float4 0.7 -0.1 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.7, 0.0, 1.0, 0.0)
[pixel shader] -float4 main(uniform float4 u) : sv_target +uniform float4 u; + +float4 main() : sv_target { int4 i = u; return saturate(i); @@ -18,5 +22,5 @@ float4 main(uniform float4 u) : sv_target
[test] uniform 0 float4 -2 0 2 -1 -draw quad +todo(sm>=6) draw quad probe all rgba (0.0, 0.0, 1.0, 0.0) diff --git a/tests/hlsl/shader-interstage-interface.shader_test b/tests/hlsl/shader-interstage-interface.shader_test index 584b88cf9..271eb3bbe 100644 --- a/tests/hlsl/shader-interstage-interface.shader_test +++ b/tests/hlsl/shader-interstage-interface.shader_test @@ -52,5 +52,5 @@ void main(float4 position : SV_Position, float2 t0 : TEXCOORD0, }
[test] -draw triangle strip 4 +todo(sm>=6) draw triangle strip 4 probe all rgba (10.0, 8.0, 7.0, 3.0) diff --git a/tests/hlsl/side-effects.shader_test b/tests/hlsl/side-effects.shader_test index 8e4557f02..f41e98510 100644 --- a/tests/hlsl/side-effects.shader_test +++ b/tests/hlsl/side-effects.shader_test @@ -27,6 +27,11 @@ draw quad probe all rgba (11.0, 11.0, 11.0, 11.0)
+% dxcompiler performs the first call to func() before the array index call. +[require] +shader model < 6.0 + + [pixel shader] float4 func(void) { diff --git a/tests/hlsl/sign.shader_test b/tests/hlsl/sign.shader_test index 7ed632dbe..c56d90823 100644 --- a/tests/hlsl/sign.shader_test +++ b/tests/hlsl/sign.shader_test @@ -8,13 +8,13 @@ float4 main() : sv_target
[test] uniform 0 float4 1.0 0.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0) uniform 0 float4 -1.0 0.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (-1.0, -1.0, -1.0, -1.0) uniform 0 float4 0.0 0.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.0, 0.0, 0.0, 0.0)
[pixel shader] @@ -27,7 +27,7 @@ float4 main() : sv_target
[test] uniform 0 float4 1.0 2.0 3.0 4.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0)
[pixel shader] @@ -41,7 +41,7 @@ float4 main() : sv_target [test] uniform 0 float4 1.0 2.0 0.0 0.0 uniform 4 float4 3.0 4.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0)
[pixel shader] @@ -54,13 +54,13 @@ float4 main() : sv_target
[test] uniform 0 int4 1 0 0 0 -draw quad +todo(sm>=6) draw quad probe all rgba (1, 1, 1, 1) uniform 0 int4 -1 0 0 0 -draw quad +todo(sm>=6) draw quad probe all rgba (-1, -1, -1, -1) uniform 0 int4 0 0 0 0 -draw quad +todo(sm>=6) draw quad probe all rgba (0, 0, 0, 0)
[pixel shader] @@ -73,7 +73,7 @@ float4 main() : sv_target
[test] uniform 0 int4 1 2 3 4 -draw quad +todo(sm>=6) draw quad probe all rgba (1, 1, 1, 1)
[pixel shader] @@ -87,5 +87,5 @@ float4 main() : sv_target [test] uniform 0 int4 1 2 0 0 uniform 4 int4 3 4 0 0 -draw quad +todo(sm>=6) draw quad probe all rgba (1, 1, 1, 1) diff --git a/tests/hlsl/smoothstep.shader_test b/tests/hlsl/smoothstep.shader_test index 63755b081..971f6d5d8 100644 --- a/tests/hlsl/smoothstep.shader_test +++ b/tests/hlsl/smoothstep.shader_test @@ -27,7 +27,7 @@ float4 main() : sv_target
[test] draw quad -probe all rgba (0, 0.104, 0.896, 1.000000) 5 +probe all rgba (0, 0.104, 0.896, 1.000000) 6
[pixel shader] diff --git a/tests/hlsl/sqrt.shader_test b/tests/hlsl/sqrt.shader_test index 78d89d38f..73ecba899 100644 --- a/tests/hlsl/sqrt.shader_test +++ b/tests/hlsl/sqrt.shader_test @@ -8,7 +8,7 @@ float4 main() : sv_target
[test] uniform 0 float4 1.0 9.0 32.3 46.5 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 3.0, 5.683309, 6.819091) 1
[pixel shader] @@ -21,5 +21,5 @@ float4 main() : sv_target
[test] uniform 0 float4 1.0 9.0 4.0 16.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 0.33333333, 0.5, 0.25) 1 diff --git a/tests/hlsl/state-block-syntax.shader_test b/tests/hlsl/state-block-syntax.shader_test index 26853bf40..7df3ae7c9 100644 --- a/tests/hlsl/state-block-syntax.shader_test +++ b/tests/hlsl/state-block-syntax.shader_test @@ -1,4 +1,4 @@ -[pixel shader fail] +[pixel shader fail(sm<6)] sampler s { foo = float; @@ -9,7 +9,7 @@ float4 main() : sv_target return float4(0, 0, 0, 0); }
-[pixel shader fail] +[pixel shader fail(sm<6)] sampler s = sampler_state { foo = float; @@ -20,7 +20,7 @@ float4 main() : sv_target return float4(0, 0, 0, 0); }
-[pixel shader fail] +[pixel shader fail(sm<6)] sampler s { 2 = 3; @@ -31,7 +31,7 @@ float4 main() : sv_target return float4(0, 0, 0, 0); }
-[pixel shader fail] +[pixel shader fail(sm<6)] sampler s { 2; @@ -42,7 +42,7 @@ float4 main() : sv_target return float4(0, 0, 0, 0); }
-[pixel shader fail] +[pixel shader fail(sm<6)] sampler s { foo; @@ -53,7 +53,7 @@ float4 main() : sv_target return float4(0, 0, 0, 0); }
-[pixel shader fail] +[pixel shader fail(sm<6)] sampler s { foo = bar @@ -104,7 +104,7 @@ float4 main() : sv_target return float4(0, 0, 0, 0); }
-[pixel shader fail] +[pixel shader fail(sm<6)] float f { foo = (sampler)2; @@ -115,7 +115,7 @@ float4 main() : sv_target return float4(0, 0, 0, 0); }
-[pixel shader fail] +[pixel shader fail(sm<6)] float f { foo = (faketype)2; @@ -126,7 +126,7 @@ float4 main() : sv_target return float4(0, 0, 0, 0); }
-[pixel shader fail] +[pixel shader fail(sm<6)] float f { foo = (sampler)bar; @@ -137,7 +137,7 @@ float4 main() : sv_target return float4(0, 0, 0, 0); }
-[pixel shader fail] +[pixel shader fail(sm<6)] float f { foo = bar(); diff --git a/tests/hlsl/static-initializer.shader_test b/tests/hlsl/static-initializer.shader_test index 394b4a9af..217444308 100644 --- a/tests/hlsl/static-initializer.shader_test +++ b/tests/hlsl/static-initializer.shader_test @@ -16,7 +16,7 @@ draw quad probe all rgba (0.8, 0.0, 0.0, 0.0)
-[pixel shader fail] +[pixel shader fail(sm<6)] static uint i;
float4 main() : sv_target @@ -146,7 +146,7 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (1, 2, 3, 4)
@@ -162,7 +162,7 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe all rgba (1, 2, 3, 4)
diff --git a/tests/hlsl/step.shader_test b/tests/hlsl/step.shader_test index e201e15f9..b857f00b2 100644 --- a/tests/hlsl/step.shader_test +++ b/tests/hlsl/step.shader_test @@ -9,7 +9,7 @@ float4 main() : sv_target [test] uniform 0 float4 5.0 -2.6 3.0 2.0 uniform 4 float4 1.0 -4.3 3.0 4.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.0, 0.0, 1.0, 1.0)
diff --git a/tests/hlsl/storage-qualifiers.shader_test b/tests/hlsl/storage-qualifiers.shader_test index 00e7b8367..09385e3e4 100644 --- a/tests/hlsl/storage-qualifiers.shader_test +++ b/tests/hlsl/storage-qualifiers.shader_test @@ -1,4 +1,4 @@ -[pixel shader] +[pixel shader fail(sm>=6)] void sub2(in uniform float4 i, out float4 o) { o = i; @@ -17,5 +17,30 @@ void main(in uniform float4 a, uniform float4 b, out float4 o : sv_target) [test] uniform 0 float4 0.1 0.0 0.0 0.0 uniform 4 float4 0.2 0.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad +probe all rgba (0.1, 0.2, 0.3, 0.4) + +[pixel shader] +uniform float4 a; +uniform float4 b; + +void sub2(in float4 i, out float4 o) +{ + o = i; +} + +void sub(float a, float b, in float c, in float d, out float4 o) +{ + sub2(float4(a, b, c, d), o); +} + +void main(out float4 o : sv_target) +{ + sub(a.x, b.x, 0.3, 0.4, o); +} + +[test] +uniform 0 float4 0.1 0.0 0.0 0.0 +uniform 4 float4 0.2 0.0 0.0 0.0 +todo(sm>=6) draw quad probe all rgba (0.1, 0.2, 0.3, 0.4) diff --git a/tests/hlsl/struct-array.shader_test b/tests/hlsl/struct-array.shader_test index aff0a677a..4097f3835 100644 --- a/tests/hlsl/struct-array.shader_test +++ b/tests/hlsl/struct-array.shader_test @@ -18,5 +18,5 @@ float4 main() : sv_target uniform 0 float4 0.1 0.2 0.0 0.0 uniform 4 float4 0.3 0.4 0.0 0.0 uniform 8 float4 0.5 0.6 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.2, 0.3, 0.6, 0.5) diff --git a/tests/hlsl/swizzle-constant-prop.shader_test b/tests/hlsl/swizzle-constant-prop.shader_test index 357a3496e..a0ec18e45 100644 --- a/tests/hlsl/swizzle-constant-prop.shader_test +++ b/tests/hlsl/swizzle-constant-prop.shader_test @@ -25,7 +25,7 @@ float4 main() : sv_target
[test] uniform 0 int 4 -draw quad +todo(sm>=6) draw quad probe all rgba (110, 210, 410, 410)
@@ -43,7 +43,7 @@ float4 main() : sv_target
[test] uniform 0 int 3 -draw quad +todo(sm>=6) draw quad probe all rgba (105, 5, 305, 305)
@@ -59,5 +59,5 @@ float4 main() : sv_target
[test] uniform 0 int 1 -draw quad +todo(sm>=6) draw quad probe all rgba (14.0, 14.0, 14.0, 14.0) diff --git a/tests/hlsl/swizzle-matrix.shader_test b/tests/hlsl/swizzle-matrix.shader_test index bc2814ebb..005522759 100644 --- a/tests/hlsl/swizzle-matrix.shader_test +++ b/tests/hlsl/swizzle-matrix.shader_test @@ -9,7 +9,7 @@ float4 main() : sv_target [test] uniform 0 float4 11 21 31 -1 uniform 4 float4 12 22 32 -1 -draw quad +todo(sm>=6) draw quad probe all rgba (21.0, 31.0, 11.0, 12.0)
@@ -24,7 +24,7 @@ float4 main() : sv_target [test] uniform 0 float4 11 21 31 -1 uniform 4 float4 12 22 32 -1 -draw quad +todo(sm>=6) draw quad probe all rgba (11.0, 31.0, 12.0, 32.0)
@@ -40,7 +40,7 @@ float4 main() : sv_target uniform 0 float4 11 12 -1 -1 uniform 4 float4 21 22 -1 -1 uniform 8 float4 31 32 -1 -1 -draw quad +todo(sm>=6) draw quad probe all rgba (11.0, 31.0, 12.0, 32.0)
diff --git a/tests/hlsl/swizzles.shader_test b/tests/hlsl/swizzles.shader_test index c3d3343f3..ddfc09fc9 100644 --- a/tests/hlsl/swizzles.shader_test +++ b/tests/hlsl/swizzles.shader_test @@ -11,7 +11,7 @@ float4 main() : sv_target
[test] uniform 0 float4 0.0303 0.08 0.07 0.0202 -draw quad +todo(sm>=6) draw quad probe all rgba (0.0101, 0.0303, 0.0202, 0.0404)
@@ -149,7 +149,7 @@ float4 main() : sv_target
[test] uniform 0 float4 1.0 2.0 3.0 4.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 2.0, 3.0, 4.0)
@@ -166,5 +166,5 @@ float4 main() : sv_target
[test] uniform 0 float4 1.0 2.0 3.0 4.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 4.0, 2.0, 3.0) diff --git a/tests/hlsl/ternary.shader_test b/tests/hlsl/ternary.shader_test index 91f49e0e9..587b3d556 100644 --- a/tests/hlsl/ternary.shader_test +++ b/tests/hlsl/ternary.shader_test @@ -8,10 +8,10 @@ float4 main() : sv_target
[test] uniform 0 float4 2.0 3.0 4.0 5.0 -draw quad +todo(sm>=6) draw quad probe all rgba (2.0, 3.0, 4.0, 5.0) uniform 0 float4 0.0 10.0 11.0 12.0 -draw quad +todo(sm>=6) draw quad probe all rgba (-1.0, 9.0, 10.0, 11.0)
[pixel shader] @@ -29,7 +29,7 @@ float4 main() : sv_target
[test] uniform 0 float4 1.1 3.0 4.0 5.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.1, 2.0, 0.0, 0.0)
[pixel shader] @@ -44,10 +44,10 @@ float4 main() : sv_target
[test] uniform 0 float4 1.0 0.0 0.0 0.0 -draw quad +todo(sm>=6) draw quad probe all rgba (0.5, 0.6, 0.7, 0.0)
-[pixel shader] +[pixel shader fail(sm>=6)] float4 x, y, z;
float4 main() : sv_target diff --git a/tests/hlsl/texture-load-offset.shader_test b/tests/hlsl/texture-load-offset.shader_test index 52b6a5f93..f32b2191f 100644 --- a/tests/hlsl/texture-load-offset.shader_test +++ b/tests/hlsl/texture-load-offset.shader_test @@ -18,7 +18,7 @@ float4 main(float4 pos : sv_position) : sv_target
[test] -draw quad +todo(sm>=6) draw quad probe (0, 0) rgba (0, 1, 0, 1) probe (1, 0) rgba (1, 1, 0, 1) probe (0, 1) rgba (0, 2, 0, 1) @@ -35,7 +35,7 @@ float4 main(float4 pos : sv_position) : sv_target
[test] -draw quad +todo(sm>=6) draw quad probe (3, 0) rgba (1, 0, 0, 1) probe (4, 0) rgba (2, 0, 0, 1) probe (3, 1) rgba (1, 1, 0, 1) diff --git a/tests/hlsl/texture-load-typed.shader_test b/tests/hlsl/texture-load-typed.shader_test index c92273373..67a13f10d 100644 --- a/tests/hlsl/texture-load-typed.shader_test +++ b/tests/hlsl/texture-load-typed.shader_test @@ -38,6 +38,23 @@ size (1, 1)
[pixel shader] typedef int myint_t; +Texture2D<float> f1; +Texture2D<myint_t> i1; +Texture2D<uint2> u2; +float4 main() : sv_target +{ + const float3 pos = float3(0.5, 0.5, 0); + return float4(f1.Load(pos), i1.Load(pos), u2.Load(pos)); +} + +[test] +todo(sm>=6) draw quad +probe all rgba (0.8, -3.0, 4294967295.0, 123.0) + +% lowercase 'texture2D' + +[pixel shader fail(sm>=6)] +typedef int myint_t; texture2D<float> f1; Texture2D<myint_t> i1; Texture2D<uint2> u2; diff --git a/tests/hlsl/texture-load.shader_test b/tests/hlsl/texture-load.shader_test index 362e1d2e3..8609828b8 100644 --- a/tests/hlsl/texture-load.shader_test +++ b/tests/hlsl/texture-load.shader_test @@ -15,7 +15,7 @@ float4 main(float4 pos : sv_position) : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe (0, 0) rgba (0.1, 0.2, 0.3, 0.4) probe (1, 0) rgba (0.5, 0.7, 0.6, 0.8) probe (0, 1) rgba (0.6, 0.5, 0.2, 0.1) @@ -30,7 +30,7 @@ float4 main(float4 pos : sv_position) : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe (0, 0) rgba (0.1, 0.2, 0.3, 0.4) probe (1, 0) rgba (0.6, 0.5, 0.2, 0.1) probe (0, 1) rgba (0.5, 0.7, 0.6, 0.8) @@ -46,7 +46,7 @@ float4 main(float4 pos : sv_position) : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe (0, 0) rgba (0.1, 0.2, 0.3, 0.4) probe (1, 0) rgba (0.6, 0.5, 0.2, 0.1) probe (0, 1) rgba (0.5, 0.7, 0.6, 0.8) diff --git a/tests/hlsl/texture-ordering.shader_test b/tests/hlsl/texture-ordering.shader_test index 2291ddf88..24cd986ca 100644 --- a/tests/hlsl/texture-ordering.shader_test +++ b/tests/hlsl/texture-ordering.shader_test @@ -1,5 +1,6 @@ [require] shader model >= 4.0 +shader model < 6.0
[sampler 0] filter linear linear linear @@ -84,6 +85,8 @@ size (1, 1) % table, and may be larger than the "bind count".
[require] +shader model >= 4.0 +shader model < 6.0 options: backcompat
[pixel shader] diff --git a/tests/hlsl/trigonometry.shader_test b/tests/hlsl/trigonometry.shader_test index f283c538c..f52d01dea 100644 --- a/tests/hlsl/trigonometry.shader_test +++ b/tests/hlsl/trigonometry.shader_test @@ -12,7 +12,7 @@ float4 main(float tex : texcoord) : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe ( 0, 0) rgba ( 0.00000000, 1.00000000, 0.00000000, 0.0) probe ( 1, 0) rgba ( 0.84147098, 0.54030231, 1.55740772, 0.0) 1024 probe ( 2, 0) rgba ( 0.90929743, -0.41614684, -2.18503986, 0.0) 1024 @@ -41,7 +41,7 @@ float4 main() : sv_target
[test] uniform 0 float4 0.0 0.52359877 2.61799387 3.14159265 -draw quad +todo(sm>=6) draw quad probe all rgba (0.0, 500.0, 500.0, 0.0)
@@ -55,7 +55,7 @@ float4 main() : sv_target
[test] uniform 0 float4 0.0 0.78539816 1.57079632 2.35619449 -draw quad +todo(sm>=6) draw quad probe all rgba (1000.0, 707.0, -0.0, -707.0)
@@ -71,5 +71,5 @@ float4 main() : sv_target % tan(pi/2) is an asymtote and therefore undefined % so check 0, pi/4, 3pi/4, pi uniform 0 float4 0.0 0.78539816 2.35619449 3.14159265 -draw quad +todo(sm>=6) draw quad probe all rgba (0, 1000, -1000.0, 0) diff --git a/tests/hlsl/trunc.shader_test b/tests/hlsl/trunc.shader_test index 419608fb0..a359cd03a 100644 --- a/tests/hlsl/trunc.shader_test +++ b/tests/hlsl/trunc.shader_test @@ -1,19 +1,23 @@ [pixel shader] -float4 main(uniform float4 u) : sv_target +uniform float4 u; + +float4 main() : sv_target { return trunc(u); }
[test] uniform 0 float4 -0.5 6.5 7.5 3.4 -draw quad +todo(sm>=6) draw quad probe all rgba (0.0, 6.0, 7.0, 3.0) uniform 0 float4 -1.5 6.5 7.5 3.4 -draw quad +todo(sm>=6) draw quad probe all rgba (-1.0, 6.0, 7.0, 3.0)
[pixel shader] -float4 main(uniform float4 u) : sv_target +uniform float4 u; + +float4 main() : sv_target { float a = trunc(u.r); int2 b = trunc(u.gb); @@ -23,14 +27,16 @@ float4 main(uniform float4 u) : sv_target
[test] uniform 0 float4 -0.5 6.5 7.5 3.4 -draw quad +todo(sm>=6) draw quad probe all rgba (6.0, 7.0, 0.0, 3.0)
[require] shader model >= 4.0
[pixel shader] -float4 main(uniform int4 u) : sv_target +uniform int4 u; + +float4 main() : sv_target { float a = trunc(u.r); int2 b = trunc(u.gb); @@ -40,5 +46,5 @@ float4 main(uniform int4 u) : sv_target
[test] uniform 0 int4 -1 6 7 3 -draw quad +todo(sm>=6) draw quad probe all rgba (6.0, 7.0, -1.0, 3.0) diff --git a/tests/hlsl/type-names.shader_test b/tests/hlsl/type-names.shader_test index f382ffae6..6e88fd285 100644 --- a/tests/hlsl/type-names.shader_test +++ b/tests/hlsl/type-names.shader_test @@ -1,4 +1,4 @@ -[pixel shader] +[pixel shader fail(sm>=6)] typedef float2 Dword; typedef float3 dWord; typedef float2 fLoat; @@ -73,7 +73,7 @@ float4 main() : sv_target return float4(0, 0, 0, 0); }
-[pixel shader fail] +[pixel shader fail(sm<6)] float4 f() { typedef float2 matrix; @@ -85,7 +85,7 @@ float4 main() : SV_TARGET return f(); }
-[pixel shader fail] +[pixel shader fail(sm<6)] float4 f() { typedef float2 vector; diff --git a/tests/hlsl/uav-load.shader_test b/tests/hlsl/uav-load.shader_test index fe6350e0c..9088ffa0d 100644 --- a/tests/hlsl/uav-load.shader_test +++ b/tests/hlsl/uav-load.shader_test @@ -23,7 +23,7 @@ void main() }
[test] -dispatch 1 1 1 +todo(sm>=6) dispatch 1 1 1 probe uav 0 (0, 0) r (0.6) probe uav 0 (1, 0) r (0.6) probe uav 0 (2, 0) r (0.6) diff --git a/tests/hlsl/uav-out-param.shader_test b/tests/hlsl/uav-out-param.shader_test index f31344748..796c4bf1f 100644 --- a/tests/hlsl/uav-out-param.shader_test +++ b/tests/hlsl/uav-out-param.shader_test @@ -26,7 +26,7 @@ void main() }
[test] -dispatch 1 1 1 +todo(sm>=6) dispatch 1 1 1 probe uav 0 (0, 0) rgba (0.4, 0.1, 0.2, 0.3)
[uav 0] @@ -51,5 +51,5 @@ void main() }
[test] -dispatch 1 1 1 +todo(sm>=6) dispatch 1 1 1 probe uav 0 (0, 0) r (0.2) diff --git a/tests/hlsl/uav-rwbuffer.shader_test b/tests/hlsl/uav-rwbuffer.shader_test index 1a7fcf1e8..b476c7854 100644 --- a/tests/hlsl/uav-rwbuffer.shader_test +++ b/tests/hlsl/uav-rwbuffer.shader_test @@ -41,7 +41,7 @@ float4 main() : sv_target1 return 0; }
-[pixel shader fail todo] +[pixel shader fail(sm<6) todo] RWBuffer<double3> u;
float4 main() : sv_target1 @@ -58,7 +58,7 @@ float4 main() : sv_target1 }
% Array type -[pixel shader fail] +[pixel shader fail(sm<6)] typedef float arr[2]; RWBuffer<arr> u;
@@ -68,7 +68,7 @@ float4 main() : sv_target1 }
% Object types -[pixel shader fail] +[pixel shader fail(sm<6)] RWBuffer<Texture2D> u;
float4 main() : sv_target1 @@ -103,5 +103,5 @@ float4 main() : sv_target1 }
[test] -draw quad +todo(sm>=6) draw quad probe buffer uav 2 (0, 0) rgba (11.1, 12.2, 13.3, 14.4) diff --git a/tests/hlsl/uav-rwstructuredbuffer.shader_test b/tests/hlsl/uav-rwstructuredbuffer.shader_test index 5ea673299..904d15514 100644 --- a/tests/hlsl/uav-rwstructuredbuffer.shader_test +++ b/tests/hlsl/uav-rwstructuredbuffer.shader_test @@ -36,7 +36,7 @@ float4 main() : sv_target1 }
% Object types -[pixel shader fail] +[pixel shader fail(sm<6)] RWStructuredBuffer<Texture2D> u;
float4 main() : sv_target1 diff --git a/tests/hlsl/uav-rwtexture.shader_test b/tests/hlsl/uav-rwtexture.shader_test index 07c28cb84..bfa2b4413 100644 --- a/tests/hlsl/uav-rwtexture.shader_test +++ b/tests/hlsl/uav-rwtexture.shader_test @@ -1,7 +1,7 @@ [require] shader model >= 5.0
-[pixel shader fail] +[pixel shader fail(sm<6)] RWTexture2D<float4> u;
float4 main() : sv_target @@ -49,7 +49,7 @@ float4 main() : sv_target }
[test] -draw quad +todo(sm>=6) draw quad probe uav 1 (0, 0) r (0.5) probe uav 1 (0, 1) r (0.6) probe uav 1 (1, 0) r (0.2) @@ -71,7 +71,7 @@ size (1, 1)
0.1 0.2 0.3 0.4
-[pixel shader fail] +[pixel shader fail(sm<6)] RWTexture2D<float4> u : register(u0);
float4 main() : sv_target1 @@ -80,7 +80,7 @@ float4 main() : sv_target1 return 0; }
-[pixel shader fail] +[pixel shader fail(sm<6)] RWTexture2D<float4> u : register(u1);
float4 main() : sv_target1 @@ -99,7 +99,7 @@ float4 main() : sv_target1 }
[test] -draw quad +todo(sm>=6) draw quad probe uav 2 (0, 0) rgba (0.9, 0.8, 0.7, 0.6)
@@ -118,7 +118,7 @@ float4 main() : sv_target1 }
[test] -draw quad +todo(sm>=6) draw quad probe uav 3 (0, 0) rgba (0.9, 0.8, 0.7, 0.6)
% Uppercase register set name @@ -132,7 +132,7 @@ float4 main() : sv_target1 }
[test] -draw quad +todo(sm>=6) draw quad probe uav 3 (0, 0) rgba (0.9, 0.8, 0.7, 0.6)
% Test that we can declare and use an array of UAVs. @@ -158,12 +158,12 @@ float4 main() : sv_target1 }
[test] -draw quad +todo(sm>=6) draw quad probe uav 2 (0, 0) rgba (1.1, 1.2, 1.3, 1.4) probe uav 3 (0, 0) rgba (2.1, 2.2, 2.3, 2.4)
% RWTexture1D types -[pixel shader] +[pixel shader fail(sm>=6)] struct s { float3 a; @@ -181,7 +181,7 @@ float4 main() : sv_target1 }
% RWTexture2D types -[pixel shader] +[pixel shader fail(sm>=6)] struct s { float3 a; @@ -199,7 +199,7 @@ float4 main() : sv_target1 }
% RWTexture3D types -[pixel shader] +[pixel shader fail(sm>=6)] struct s { float3 a; diff --git a/tests/hlsl/uniform-parameters.shader_test b/tests/hlsl/uniform-parameters.shader_test new file mode 100644 index 000000000..a17511f81 --- /dev/null +++ b/tests/hlsl/uniform-parameters.shader_test @@ -0,0 +1,36 @@ +% 'uniform' in the parameter list is not supported in SM >= 6.0. + +[require] +shader model >= 4.0 +shader model < 6.0 + +[pixel shader] +float4 main(uniform float f, uniform int i, uniform uint u, uniform half h) : sv_target +{ + float4 ret; + + ret.x = asfloat(f); + ret.y = asfloat(i); + ret.z = asfloat(u); + ret.w = asfloat(h); + return ret; +} + +[test] +uniform 0 float4 123.0 -2.0 456 0.01 +draw quad +probe (320,240) rgba (123.0, -2.0, 456.0, 0.01) + +[pixel shader] +float4 main(uniform float2x2 m, uniform float4 v) : sv_target +{ + return float4(asfloat(m)[0][1], asfloat(v).y, 0, 0); +} + +[test] +uniform 0 float4 11 12 0 0 +uniform 4 float4 13 14 0 0 +uniform 8 float4 20 21 22 23 +draw quad +probe (320,240) rgba (13.0, 21.0, 0.0, 0.0) + diff --git a/tests/hlsl/uniform-semantics.shader_test b/tests/hlsl/uniform-semantics.shader_test index 1125117fe..86e3b83f9 100644 --- a/tests/hlsl/uniform-semantics.shader_test +++ b/tests/hlsl/uniform-semantics.shader_test @@ -10,7 +10,7 @@ float4 main() : sv_target
[test] uniform 0 float 3.5 -draw quad +todo(sm>=6) draw quad probe all rgba (3.5, 3.5, 3.5, 3.5)
@@ -24,5 +24,5 @@ float4 main() : sv_target
[test] uniform 0 float4 4.0 5.0 6.0 7.0 -draw quad +todo(sm>=6) draw quad probe all rgba (4.0, 5.0, 4.0, 5.0) diff --git a/tests/hlsl/vector-indexing-uniform.shader_test b/tests/hlsl/vector-indexing-uniform.shader_test index e5ffbdd02..3501f3af7 100644 --- a/tests/hlsl/vector-indexing-uniform.shader_test +++ b/tests/hlsl/vector-indexing-uniform.shader_test @@ -12,5 +12,5 @@ float4 main() : SV_TARGET
[test] uniform 0 float 2 -draw quad +todo(sm>=6) draw quad probe all rgba (0.5, 0.3, 0.8, 0.2) diff --git a/tests/hlsl/vector-indexing.shader_test b/tests/hlsl/vector-indexing.shader_test index 1542d358a..71a4ca26d 100644 --- a/tests/hlsl/vector-indexing.shader_test +++ b/tests/hlsl/vector-indexing.shader_test @@ -23,11 +23,11 @@ float4 main() : SV_TARGET
[test] uniform 0 float4 1.0 2.0 3.0 4.0 -draw quad +todo(sm>=6) draw quad probe all rgba (1.0, 2.0, 2.0, 3.0)
-[pixel shader fail] +[pixel shader fail(sm<6)] float4 main() : SV_TARGET { float4 vec = {0, 1, 2, 3}; diff --git a/tests/hlsl/writemask-assignop-0.shader_test b/tests/hlsl/writemask-assignop-0.shader_test index 374a38bb4..fa8ecc2e4 100644 --- a/tests/hlsl/writemask-assignop-0.shader_test +++ b/tests/hlsl/writemask-assignop-0.shader_test @@ -11,5 +11,5 @@ float4 main() : SV_target
[test] uniform 0 float4 0.0303 0.08 0.07 0.0202 -draw quad +todo(sm>=6) draw quad probe all rgba (-0.4697, -0.02, 0.57, 0.3202) 2 diff --git a/tests/hlsl/writemask-assignop-1.shader_test b/tests/hlsl/writemask-assignop-1.shader_test index 61993257c..3bebcce61 100644 --- a/tests/hlsl/writemask-assignop-1.shader_test +++ b/tests/hlsl/writemask-assignop-1.shader_test @@ -12,5 +12,5 @@ float4 main() : SV_target
[test] uniform 0 float4 0.0303 0.08 0.07 0.0202 -draw quad +todo(sm>=6) draw quad probe all rgba (0.5697, -0.08, -0.27, -0.4202) diff --git a/tests/shader_runner.c b/tests/shader_runner.c index bec08d7e7..cae0bf026 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -60,6 +60,7 @@ typedef int HRESULT; #include "vkd3d_d3dcompiler.h" #include "vkd3d_test.h" #include "shader_runner.h" +#include "dxcompiler.h"
struct test_options test_options = {0};
@@ -129,9 +130,11 @@ static bool match_directive_substring(const char *line, const char *token, const
static void parse_require_directive(struct shader_runner *runner, const char *line) { + bool less_than = false; unsigned int i;
- if (match_string(line, "shader model >=", &line)) + if (match_string(line, "shader model >=", &line) + || (less_than = match_string(line, "shader model <", &line))) { static const char *const model_strings[] = { @@ -141,13 +144,23 @@ static void parse_require_directive(struct shader_runner *runner, const char *li [SHADER_MODEL_4_1] = "4.1", [SHADER_MODEL_5_0] = "5.0", [SHADER_MODEL_5_1] = "5.1", + [SHADER_MODEL_6_0] = "6.0", };
for (i = 0; i < ARRAY_SIZE(model_strings); ++i) { if (match_string(line, model_strings[i], &line)) { - runner->minimum_shader_model = i; + if (less_than) + { + if (!i) + fatal_error("Shader model < '%s' is invalid.\n", line); + runner->maximum_shader_model = min(runner->maximum_shader_model, i - 1); + } + else + { + runner->minimum_shader_model = max(runner->minimum_shader_model, i); + } return; } } @@ -485,6 +498,10 @@ static void parse_test_directive(struct shader_runner *runner, const char *line)
if (match_string(line, "todo", &line)) runner->is_todo = true; + else if (match_string(line, "todo(sm<6)", &line)) + runner->is_todo = runner->minimum_shader_model < SHADER_MODEL_6_0; + else if (match_string(line, "todo(sm>=6)", &line)) + runner->is_todo = runner->minimum_shader_model >= SHADER_MODEL_6_0;
if (match_string(line, "dispatch", &line)) { @@ -802,9 +819,125 @@ const char *shader_type_string(enum shader_type type) return shader_types[type]; }
-static void compile_shader(struct shader_runner *runner, const char *source, size_t len, enum shader_type type, - HRESULT expect) +/* Avoid issues with calling convention mismatch and different methods for string + * retrieval by copying all IDxcBlob objects to a new ID3D10Blob. */ + +static void d3d10_blob_from_dxc_blob_utf8(IDxcBlobUtf8 *blob, ID3D10Blob **blob_out) +{ + ID3D10Blob *d3d_blob; + size_t size; + HRESULT hr; + + size = IDxcBlobUtf8_GetStringLength(blob) + 1; + if (FAILED(hr = D3DCreateBlob(size, (ID3DBlob **)&d3d_blob))) + { + trace("Failed to create blob, hr %#x.\n", hr); + return; + } + + memcpy(ID3D10Blob_GetBufferPointer(d3d_blob), IDxcBlobUtf8_GetStringPointer(blob), size); + *blob_out = d3d_blob; +} + +static HRESULT d3d10_blob_from_dxc_blob(IDxcBlob *blob, ID3D10Blob **blob_out) +{ + ID3D10Blob *d3d_blob; + size_t size; + HRESULT hr; + + size = IDxcBlob_GetBufferSize(blob); + if (FAILED(hr = D3DCreateBlob(size, (ID3DBlob **)&d3d_blob))) + { + trace("Failed to create blob, hr %#x.\n", hr); + return hr; + } + + memcpy(ID3D10Blob_GetBufferPointer(d3d_blob), IDxcBlob_GetBufferPointer(blob), size); + *blob_out = d3d_blob; + + return S_OK; +} + +HRESULT dxc_compiler_compile_shader(void *dxc_compiler, enum shader_type type, unsigned int compile_options, + const char *hlsl, ID3D10Blob **blob_out, ID3D10Blob **errors_out) +{ + DxcBuffer src_buf = {hlsl, strlen(hlsl), 65001}; + IDxcCompiler3 *compiler = dxc_compiler; + HRESULT hr, compile_hr; + IDxcBlobUtf8 *errors; + IDxcResult *result; + size_t arg_count; + IDxcBlob *blob; + + static const WCHAR *const shader_profiles[] = + { + [SHADER_TYPE_CS] = L"cs_6_0", + [SHADER_TYPE_PS] = L"ps_6_0", + [SHADER_TYPE_VS] = L"vs_6_0", + }; + const WCHAR *args[] = + { + L"/T", + shader_profiles[type], + L"/Qstrip_reflect", + L"/Qstrip_debug", + L"/flegacy-macro-expansion", + L"/flegacy-resource-reservation", + NULL, + NULL, + NULL, + }; + + *blob_out = NULL; + *errors_out = NULL; + + arg_count = ARRAY_SIZE(args) - 3; + if (compile_options & D3DCOMPILE_PACK_MATRIX_ROW_MAJOR) + args[arg_count++] = L"/Zpr"; + if (compile_options & D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR) + args[arg_count++] = L"/Zpc"; + if (compile_options & D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY) + args[arg_count++] = L"/Gec"; + + if (FAILED(hr = IDxcCompiler3_Compile(compiler, &src_buf, args, arg_count, NULL, &IID_IDxcResult, (void **)&result))) + { + trace("Failed to compile shader, hr %#x.\n", hr); + return hr; + } + + if (IDxcResult_HasOutput(result, DXC_OUT_ERRORS) + && SUCCEEDED(hr = IDxcResult_GetOutput(result, DXC_OUT_ERRORS, &IID_IDxcBlobUtf8, (void **)&errors, NULL))) + { + if (IDxcBlobUtf8_GetStringLength(errors)) + d3d10_blob_from_dxc_blob_utf8(errors, errors_out); + IDxcBlobUtf8_Release(errors); + } + + if (FAILED(hr = IDxcResult_GetStatus(result, &compile_hr)) || FAILED((hr = compile_hr))) + { + if (hr == DXC_E_LLVM_CAST_ERROR) + hr = E_FAIL; + goto result_release; + } + + if (FAILED(hr = IDxcResult_GetOutput(result, DXC_OUT_OBJECT, &IID_IDxcBlob, (void **)&blob, NULL))) + goto result_release; + + IDxcResult_Release(result); + + hr = d3d10_blob_from_dxc_blob(blob, blob_out); + IDxcBlob_Release(blob); + return hr; + +result_release: + IDxcResult_Release(result); + return hr; +} + +static void compile_shader(struct shader_runner *runner, IDxcCompiler3 *dxc_compiler, const char *source, size_t len, + enum shader_type type, HRESULT expect) { + bool use_dxcompiler = runner->minimum_shader_model >= SHADER_MODEL_6_0; ID3D10Blob *blob = NULL, *errors = NULL; char profile[7]; HRESULT hr; @@ -817,10 +950,19 @@ static void compile_shader(struct shader_runner *runner, const char *source, siz [SHADER_MODEL_4_1] = "4_1", [SHADER_MODEL_5_0] = "5_0", [SHADER_MODEL_5_1] = "5_1", + [SHADER_MODEL_6_0] = "6_0", };
- sprintf(profile, "%s_%s", shader_type_string(type), shader_models[runner->minimum_shader_model]); - hr = D3DCompile(source, len, NULL, NULL, NULL, "main", profile, runner->compile_options, 0, &blob, &errors); + if (use_dxcompiler) + { + assert(dxc_compiler); + hr = dxc_compiler_compile_shader(dxc_compiler, type, runner->compile_options, source, &blob, &errors); + } + else + { + sprintf(profile, "%s_%s", shader_type_string(type), shader_models[runner->minimum_shader_model]); + hr = D3DCompile(source, len, NULL, NULL, NULL, "main", profile, runner->compile_options, 0, &blob, &errors); + } hr = map_unidentified_hrs(hr); ok(hr == expect, "Got unexpected hr %#x.\n", hr); if (hr == S_OK) @@ -845,8 +987,11 @@ static enum parse_state read_shader_directive(struct shader_runner *runner, enum { while (*src && *src != ']') { + /* 'todo' is not meaningful when dxcompiler is in use, so it has no '(sm<6) qualifier. */ if (match_directive_substring(src, "todo", &src)) { + if (runner->minimum_shader_model >= SHADER_MODEL_6_0) + continue; if (state == STATE_SHADER_COMPUTE) state = STATE_SHADER_COMPUTE_TODO; else if (state == STATE_SHADER_PIXEL) @@ -858,9 +1003,20 @@ static enum parse_state read_shader_directive(struct shader_runner *runner, enum { *expect_hr = E_FAIL; } - else if (match_directive_substring(src, "notimpl", &src)) + else if (match_directive_substring(src, "fail(sm<6)", &src)) { - *expect_hr = E_NOTIMPL; + if (runner->minimum_shader_model < SHADER_MODEL_6_0) + *expect_hr = E_FAIL; + } + else if (match_directive_substring(src, "fail(sm>=6)", &src)) + { + if (runner->minimum_shader_model >= SHADER_MODEL_6_0) + *expect_hr = E_FAIL; + } + else if (match_directive_substring(src, "notimpl(sm<6)", &src)) + { + if (runner->minimum_shader_model < SHADER_MODEL_6_0) + *expect_hr = E_NOTIMPL; } else { @@ -874,7 +1030,8 @@ static enum parse_state read_shader_directive(struct shader_runner *runner, enum return state; }
-void run_shader_tests(struct shader_runner *runner, const struct shader_runner_ops *ops) +void run_shader_tests(struct shader_runner *runner, const struct shader_runner_ops *ops, void *dxc_compiler, + enum shader_model minimum_shader_model, enum shader_model maximum_shader_model) { size_t shader_source_size = 0, shader_source_len = 0; struct resource_params current_resource; @@ -895,7 +1052,8 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_o
memset(runner, 0, sizeof(*runner)); runner->ops = ops; - runner->minimum_shader_model = SHADER_MODEL_2_0; + runner->minimum_shader_model = minimum_shader_model; + runner->maximum_shader_model = maximum_shader_model;
for (;;) { @@ -915,7 +1073,8 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_o break;
case STATE_REQUIRE: - if (runner->ops->check_requirements && !runner->ops->check_requirements(runner)) + if (runner->maximum_shader_model < runner->minimum_shader_model + || (runner->ops->check_requirements && !runner->ops->check_requirements(runner))) { skip_tests = true; } @@ -931,7 +1090,8 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_o if (!skip_tests) { todo_if (state == STATE_SHADER_COMPUTE_TODO) - compile_shader(runner, shader_source, shader_source_len, SHADER_TYPE_CS, expect_hr); + compile_shader(runner, dxc_compiler, shader_source, shader_source_len, SHADER_TYPE_CS, + expect_hr); } free(runner->cs_source); runner->cs_source = shader_source; @@ -945,7 +1105,8 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_o if (!skip_tests) { todo_if (state == STATE_SHADER_PIXEL_TODO) - compile_shader(runner, shader_source, shader_source_len, SHADER_TYPE_PS, expect_hr); + compile_shader(runner, dxc_compiler, shader_source, shader_source_len, SHADER_TYPE_PS, + expect_hr); } free(runner->ps_source); runner->ps_source = shader_source; @@ -959,7 +1120,8 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_o if (!skip_tests) { todo_if (state == STATE_SHADER_VERTEX_TODO) - compile_shader(runner, shader_source, shader_source_len, SHADER_TYPE_VS, expect_hr); + compile_shader(runner, dxc_compiler, shader_source, shader_source_len, SHADER_TYPE_VS, + expect_hr); } free(runner->vs_source); runner->vs_source = shader_source; @@ -1047,7 +1209,8 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_o else if (!strcmp(line, "[require]\n")) { state = STATE_REQUIRE; - runner->minimum_shader_model = SHADER_MODEL_2_0; + runner->minimum_shader_model = minimum_shader_model; + runner->maximum_shader_model = maximum_shader_model; runner->compile_options = 0; skip_tests = false; } @@ -1208,7 +1371,9 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_o break;
case STATE_TEST: - if (!skip_tests) + /* Compilation which fails with dxcompiler is not 'todo', therefore the tests are + * not 'todo' either. They cannot run, so skip them entirely. */ + if (!skip_tests && SUCCEEDED(expect_hr)) parse_test_directive(runner, line); break; } @@ -1284,8 +1449,47 @@ out: } #endif
+#if defined(SONAME_LIBDXCOMPILER) && !defined(VKD3D_CROSSTEST) +static IDxcCompiler3 *dxcompiler_create() +{ + DxcCreateInstanceProc create_instance; + IDxcCompiler3 *compiler; + HRESULT hr; + void *dll; + + if (!(dll = vkd3d_dlopen(SONAME_LIBDXCOMPILER))) + { + trace("Failed to load dxcompiler library, %s.\n", vkd3d_dlerror()); + return NULL; + } + + if (!(create_instance = (DxcCreateInstanceProc)vkd3d_dlsym(dll, "DxcCreateInstance"))) + { + trace("Failed to get DxcCreateInstance() pointer.\n"); + return NULL; + } + + if (FAILED(hr = create_instance(&CLSID_DxcCompiler, &IID_IDxcCompiler3, (void **)&compiler))) + { + trace("Failed to create instance, hr %#x.\n", hr); + return NULL; + } + + return compiler; +} +#elif !defined(VKD3D_CROSSTEST) +static IDxcCompiler3 *dxcompiler_create() +{ + return NULL; +} +#endif + START_TEST(shader_runner) { +#ifndef VKD3D_CROSSTEST + IDxcCompiler3 *dxc_compiler; +#endif + parse_args(argc, argv);
#if defined(VKD3D_CROSSTEST) @@ -1298,7 +1502,7 @@ START_TEST(shader_runner) run_shader_tests_d3d11();
trace("Compiling shaders with d3dcompiler_47.dll and executing with d3d12.dll\n"); - run_shader_tests_d3d12(); + run_shader_tests_d3d12(NULL, SHADER_MODEL_4_0, SHADER_MODEL_5_1);
print_dll_version("d3dcompiler_47.dll"); print_dll_version("dxgi.dll"); @@ -1315,7 +1519,15 @@ START_TEST(shader_runner) run_shader_tests_d3d11();
trace("Compiling shaders with vkd3d-shader and executing with vkd3d\n"); - run_shader_tests_d3d12(); + run_shader_tests_d3d12(NULL, SHADER_MODEL_4_0, SHADER_MODEL_5_1); + + if ((dxc_compiler = dxcompiler_create())) + { + trace("Compiling shaders with dxcompiler and executing with vkd3d\n"); + run_shader_tests_d3d12(dxc_compiler, SHADER_MODEL_6_0, SHADER_MODEL_6_0); + IDxcCompiler3_Release(dxc_compiler); + print_dll_version(SONAME_LIBDXCOMPILER); + }
print_dll_version("d3d9.dll"); print_dll_version("d3d11.dll"); @@ -1326,6 +1538,13 @@ START_TEST(shader_runner) run_shader_tests_vulkan();
trace("Compiling shaders with vkd3d-shader and executing with vkd3d\n"); - run_shader_tests_d3d12(); + run_shader_tests_d3d12(NULL, SHADER_MODEL_4_0, SHADER_MODEL_5_1); + + if ((dxc_compiler = dxcompiler_create())) + { + trace("Compiling shaders with dxcompiler and executing with vkd3d\n"); + run_shader_tests_d3d12(dxc_compiler, SHADER_MODEL_6_0, SHADER_MODEL_6_0); + IDxcCompiler3_Release(dxc_compiler); + } #endif } diff --git a/tests/shader_runner.h b/tests/shader_runner.h index 6591143e6..3efbcf362 100644 --- a/tests/shader_runner.h +++ b/tests/shader_runner.h @@ -36,6 +36,7 @@ enum shader_model SHADER_MODEL_4_1, SHADER_MODEL_5_0, SHADER_MODEL_5_1, + SHADER_MODEL_6_0, };
enum shader_type @@ -118,6 +119,7 @@ struct shader_runner char *ps_source; char *cs_source; enum shader_model minimum_shader_model; + enum shader_model maximum_shader_model;
bool last_render_failed;
@@ -158,8 +160,11 @@ void fatal_error(const char *format, ...) VKD3D_NORETURN VKD3D_PRINTF_FUNC(1, 2)
unsigned int get_vb_stride(const struct shader_runner *runner, unsigned int slot); void init_resource(struct resource *resource, const struct resource_params *params); +HRESULT dxc_compiler_compile_shader(void *dxc_compiler, enum shader_type type, unsigned int compile_options, + const char *hlsl, ID3D10Blob **blob_out, ID3D10Blob **errors_out);
-void run_shader_tests(struct shader_runner *runner, const struct shader_runner_ops *ops); +void run_shader_tests(struct shader_runner *runner, const struct shader_runner_ops *ops, void *dxc_compiler, + enum shader_model minimum_shader_model, enum shader_model maximum_shader_model);
#ifdef _WIN32 void run_shader_tests_d3d9(void); @@ -167,4 +172,5 @@ void run_shader_tests_d3d11(void); #else void run_shader_tests_vulkan(void); #endif -void run_shader_tests_d3d12(void); +void run_shader_tests_d3d12(void *dxc_compiler, enum shader_model minimum_shader_model, + enum shader_model maximum_shader_model); diff --git a/tests/shader_runner_d3d11.c b/tests/shader_runner_d3d11.c index 25b585b14..bd9d363ce 100644 --- a/tests/shader_runner_d3d11.c +++ b/tests/shader_runner_d3d11.c @@ -747,7 +747,7 @@ void run_shader_tests_d3d11(void) init_adapter_info(); if (init_test_context(&runner)) { - run_shader_tests(&runner.r, &d3d11_runner_ops); + run_shader_tests(&runner.r, &d3d11_runner_ops, NULL, SHADER_MODEL_2_0, SHADER_MODEL_5_1); destroy_test_context(&runner); } } diff --git a/tests/shader_runner_d3d12.c b/tests/shader_runner_d3d12.c index 925bdca99..8453617ef 100644 --- a/tests/shader_runner_d3d12.c +++ b/tests/shader_runner_d3d12.c @@ -23,6 +23,7 @@ #define VKD3D_TEST_NO_DEFS #include "d3d12_crosstest.h" #include "shader_runner.h" +#include "dxcompiler.h"
struct d3d12_resource { @@ -49,6 +50,8 @@ struct d3d12_shader_runner ID3D12CommandQueue *compute_queue; ID3D12CommandAllocator *compute_allocator; ID3D12GraphicsCommandList *compute_list; + + IDxcCompiler3 *dxc_compiler; };
static struct d3d12_shader_runner *d3d12_shader_runner(struct shader_runner *r) @@ -70,10 +73,19 @@ static ID3D10Blob *compile_shader(const struct d3d12_shader_runner *runner, cons [SHADER_MODEL_4_1] = "4_1", [SHADER_MODEL_5_0] = "5_0", [SHADER_MODEL_5_1] = "5_1", + [SHADER_MODEL_6_0] = "6_0", };
- sprintf(profile, "%s_%s", shader_type_string(type), shader_models[runner->r.minimum_shader_model]); - hr = D3DCompile(source, strlen(source), NULL, NULL, NULL, "main", profile, runner->r.compile_options, 0, &blob, &errors); + if (runner->r.minimum_shader_model >= SHADER_MODEL_6_0) + { + assert(runner->dxc_compiler); + hr = dxc_compiler_compile_shader(runner->dxc_compiler, type, runner->r.compile_options, source, &blob, &errors); + } + else + { + sprintf(profile, "%s_%s", shader_type_string(type), shader_models[runner->r.minimum_shader_model]); + hr = D3DCompile(source, strlen(source), NULL, NULL, NULL, "main", profile, runner->r.compile_options, 0, &blob, &errors); + } ok(FAILED(hr) == !blob, "Got unexpected hr %#x, blob %p.\n", hr, blob); if (errors) { @@ -311,7 +323,7 @@ static bool d3d12_runner_dispatch(struct shader_runner *r, unsigned int x, unsig size_t i;
cs_code = compile_shader(runner, runner->r.cs_source, SHADER_TYPE_CS); - todo_if (runner->r.is_todo) ok(cs_code, "Failed to compile shader.\n"); + todo_if(runner->r.is_todo && runner->r.minimum_shader_model < SHADER_MODEL_6_0) ok(cs_code, "Failed to compile shader.\n"); if (!cs_code) return false;
@@ -319,8 +331,16 @@ static bool d3d12_runner_dispatch(struct shader_runner *r, unsigned int x, unsig
cs.pShaderBytecode = ID3D10Blob_GetBufferPointer(cs_code); cs.BytecodeLength = ID3D10Blob_GetBufferSize(cs_code); + todo_if(runner->r.is_todo) pso = create_compute_pipeline_state(device, root_signature, cs); ID3D10Blob_Release(cs_code); + + if (!pso) + { + ID3D12RootSignature_Release(root_signature); + return false; + } + add_pso(test_context, pso);
ID3D12GraphicsCommandList_SetComputeRootSignature(command_list, root_signature); @@ -387,7 +407,8 @@ static bool d3d12_runner_draw(struct shader_runner *r,
ps_code = compile_shader(runner, runner->r.ps_source, SHADER_TYPE_PS); vs_code = compile_shader(runner, runner->r.vs_source, SHADER_TYPE_VS); - todo_if (runner->r.is_todo) ok(ps_code && vs_code, "Failed to compile shaders.\n"); + todo_if(runner->r.is_todo && runner->r.minimum_shader_model < SHADER_MODEL_6_0) + ok(ps_code && vs_code, "Failed to compile shaders.\n");
if (!ps_code || !vs_code) { @@ -445,10 +466,14 @@ static bool d3d12_runner_draw(struct shader_runner *r,
hr = ID3D12Device_CreateGraphicsPipelineState(device, &pso_desc, &IID_ID3D12PipelineState, (void **)&pso); - ok(hr == S_OK, "Failed to create state, hr %#x.\n", hr); + todo_if(runner->r.is_todo) ok(hr == S_OK, "Failed to create state, hr %#x.\n", hr); ID3D10Blob_Release(vs_code); ID3D10Blob_Release(ps_code); free(input_element_descs); + + if (FAILED(hr)) + return false; + add_pso(test_context, pso);
ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, test_context->root_signature); @@ -550,7 +575,8 @@ static const struct shader_runner_ops d3d12_runner_ops = .release_readback = d3d12_runner_release_readback, };
-void run_shader_tests_d3d12(void) +void run_shader_tests_d3d12(void *dxc_compiler, enum shader_model minimum_shader_model, + enum shader_model maximum_shader_model) { static const struct test_context_desc desc = { @@ -569,6 +595,8 @@ void run_shader_tests_d3d12(void) return; device = runner.test_context.device;
+ runner.dxc_compiler = dxc_compiler; + runner.compute_queue = create_command_queue(device, D3D12_COMMAND_LIST_TYPE_COMPUTE, D3D12_COMMAND_QUEUE_PRIORITY_NORMAL);
@@ -580,7 +608,7 @@ void run_shader_tests_d3d12(void) runner.compute_allocator, NULL, &IID_ID3D12GraphicsCommandList, (void **)&runner.compute_list); ok(hr == S_OK, "Failed to create command list, hr %#x.\n", hr);
- run_shader_tests(&runner.r, &d3d12_runner_ops); + run_shader_tests(&runner.r, &d3d12_runner_ops, dxc_compiler, minimum_shader_model, maximum_shader_model);
ID3D12GraphicsCommandList_Release(runner.compute_list); ID3D12CommandAllocator_Release(runner.compute_allocator); diff --git a/tests/shader_runner_d3d9.c b/tests/shader_runner_d3d9.c index 0c6d37884..0b33c1c53 100644 --- a/tests/shader_runner_d3d9.c +++ b/tests/shader_runner_d3d9.c @@ -541,7 +541,7 @@ void run_shader_tests_d3d9(void)
init_adapter_info(); init_test_context(&runner); - run_shader_tests(&runner.r, &d3d9_runner_ops); + run_shader_tests(&runner.r, &d3d9_runner_ops, NULL, SHADER_MODEL_2_0, SHADER_MODEL_3_0); destroy_test_context(&runner); } FreeLibrary(d3d9_module); diff --git a/tests/shader_runner_vulkan.c b/tests/shader_runner_vulkan.c index 60c473a45..ebb15eba9 100644 --- a/tests/shader_runner_vulkan.c +++ b/tests/shader_runner_vulkan.c @@ -1381,7 +1381,7 @@ void run_shader_tests_vulkan(void) if (!init_vulkan_runner(&runner)) return;
- run_shader_tests(&runner.r, &vulkan_runner_ops); + run_shader_tests(&runner.r, &vulkan_runner_ops, NULL, SHADER_MODEL_2_0, SHADER_MODEL_5_1);
cleanup_vulkan_runner(&runner); }
From: Conor McCarthy cmccarthy@codeweavers.com
--- libs/vkd3d-shader/d3d_asm.c | 3 +- libs/vkd3d-shader/dxil.c | 96 +++++++++++++++++++++++- libs/vkd3d-shader/spirv.c | 11 ++- libs/vkd3d-shader/tpf.c | 4 +- libs/vkd3d-shader/vkd3d_shader_main.c | 8 +- libs/vkd3d-shader/vkd3d_shader_private.h | 7 +- 6 files changed, 115 insertions(+), 14 deletions(-)
diff --git a/libs/vkd3d-shader/d3d_asm.c b/libs/vkd3d-shader/d3d_asm.c index 38a607351..566680be7 100644 --- a/libs/vkd3d-shader/d3d_asm.c +++ b/libs/vkd3d-shader/d3d_asm.c @@ -1646,7 +1646,8 @@ static void shader_dump_instruction(struct vkd3d_d3d_asm_compiler *compiler,
case VKD3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER: vkd3d_string_buffer_printf(buffer, " {\n"); - for (i = 0; i < ins->declaration.icb->vec4_count; ++i) + assert(ins->declaration.icb->component_count == VKD3D_VEC4_SIZE); + for (i = 0; i < ins->declaration.icb->element_count; ++i) { shader_print_hex_literal(compiler, " {", ins->declaration.icb->data[4 * i + 0], ""); shader_print_hex_literal(compiler, ", ", ins->declaration.icb->data[4 * i + 1], ""); diff --git a/libs/vkd3d-shader/dxil.c b/libs/vkd3d-shader/dxil.c index bb50ad62b..4963ceac8 100644 --- a/libs/vkd3d-shader/dxil.c +++ b/libs/vkd3d-shader/dxil.c @@ -1324,6 +1324,11 @@ static bool sm6_type_is_numeric_aggregate(const struct sm6_type *type) } }
+static bool sm6_type_is_array(const struct sm6_type *type) +{ + return type->class == TYPE_CLASS_ARRAY; +} + static inline bool sm6_type_is_struct(const struct sm6_type *type) { return type->class == TYPE_CLASS_STRUCT; @@ -1916,12 +1921,80 @@ static inline double bitcast_uint64_to_double(uint64_t value) return u.double_value; }
+static enum vkd3d_result register_allocate_constant_array(struct vkd3d_shader_register *reg, const struct sm6_type *type, + const uint64_t *operands, struct sm6_parser *sm6) +{ + struct vkd3d_shader_immediate_constant_buffer *icb; + const struct sm6_type *elem_type; + unsigned int i, size, count; + + elem_type = type->u.array.elem_type; + /* Multidimensional arrays are emitted in flattened form. */ + if (elem_type->class != TYPE_CLASS_INTEGER && elem_type->class != TYPE_CLASS_FLOAT) + { + FIXME("Unhandled element type %u for data array.\n", elem_type->class); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_OPERAND, + "The element data type for an immediate constant buffer is not scalar integer or floating point."); + return VKD3D_ERROR_INVALID_SHADER; + } + + /* Arrays of bool are not used in DXIL. dxc will emit an array of int32 instead if necessary. */ + if (!(size = elem_type->u.width / CHAR_BIT)) + { + WARN("Invalid data type width %u.\n", elem_type->u.width); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_OPERAND, + "An immediate constant buffer is declared with boolean elements."); + return VKD3D_ERROR_INVALID_SHADER; + } + size = max(size, sizeof(icb->data[0])); + count = type->u.array.count * size / sizeof(icb->data[0]); + + if (!(icb = vkd3d_malloc(offsetof(struct vkd3d_shader_immediate_constant_buffer, data[count])))) + { + ERR("Failed to allocate buffer, count %u.\n", count); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_OUT_OF_MEMORY, + "Out of memory allocating an immediate constant buffer of count %u.", count); + return VKD3D_ERROR_OUT_OF_MEMORY; + } + if ((reg->idx[0].offset = shader_instruction_array_add_icb(&sm6->p.instructions, icb)) == UINT_MAX) + { + ERR("Failed to store icb object.\n"); + vkd3d_free(icb); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_OUT_OF_MEMORY, + "Out of memory storing an immediate constant buffer object."); + return VKD3D_ERROR_OUT_OF_MEMORY; + } + + reg->type = VKD3DSPR_IMMCONSTBUFFER; + reg->idx_count = 1; + + icb->data_type = vkd3d_data_type_from_sm6_type(elem_type); + icb->element_count = type->u.array.count; + icb->component_count = 1; + + count = type->u.array.count; + if (size > sizeof(icb->data[0])) + { + uint64_t *data = (uint64_t *)icb->data; + for (i = 0; i < count; ++i) + data[i] = operands[i]; + } + else + { + for (i = 0; i < count; ++i) + icb->data[i] = operands[i]; + } + + return VKD3D_OK; +} + static enum vkd3d_result sm6_parser_constants_init(struct sm6_parser *sm6, const struct dxil_block *block) { enum vkd3d_shader_register_type reg_type = VKD3DSPR_INVALID; const struct sm6_type *type, *elem_type; enum vkd3d_data_type reg_data_type; const struct dxil_record *record; + enum vkd3d_result ret; struct sm6_value *dst; size_t i, value_idx; uint64_t value; @@ -1974,7 +2047,14 @@ static enum vkd3d_result sm6_parser_constants_init(struct sm6_parser *sm6, const switch (record->code) { case CST_CODE_NULL: - /* Register constant data is already zero-filled. */ + if (sm6_type_is_array(type)) + { + FIXME("Constant null arrays are not supported.\n"); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_OPERAND, + "Constant null arrays are not supported."); + return VKD3D_ERROR_INVALID_SHADER; + } + /* For non-aggregates, register constant data is already zero-filled. */ break;
case CST_CODE_INTEGER: @@ -2017,7 +2097,19 @@ static enum vkd3d_result sm6_parser_constants_init(struct sm6_parser *sm6, const break;
case CST_CODE_DATA: - WARN("Unhandled constant array.\n"); + if (!sm6_type_is_array(type)) + { + WARN("Invalid type %u for data constant idx %zu.\n", type->class, value_idx); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_OPERAND, + "The type of a constant array is not an array type."); + return VKD3D_ERROR_INVALID_SHADER; + } + if (!dxil_record_validate_operand_count(record, type->u.array.count, type->u.array.count, sm6)) + return VKD3D_ERROR_INVALID_SHADER; + + if ((ret = register_allocate_constant_array(&dst->u.reg, type, record->operands, sm6)) < 0) + return ret; + break;
case CST_CODE_UNDEF: diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 1c8b52e6d..55bc4ad42 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -5686,15 +5686,18 @@ static void spirv_compiler_emit_dcl_immediate_constant_buffer(struct spirv_compi struct vkd3d_symbol reg_symbol; unsigned int i;
- if (!(elements = vkd3d_calloc(icb->vec4_count, sizeof(*elements)))) + assert(icb->data_type == VKD3D_DATA_FLOAT); + assert(icb->component_count == VKD3D_VEC4_SIZE); + + if (!(elements = vkd3d_calloc(icb->element_count, sizeof(*elements)))) return; - for (i = 0; i < icb->vec4_count; ++i) + for (i = 0; i < icb->element_count; ++i) elements[i] = spirv_compiler_get_constant(compiler, VKD3D_SHADER_COMPONENT_FLOAT, VKD3D_VEC4_SIZE, &icb->data[4 * i]); type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_FLOAT, VKD3D_VEC4_SIZE); - length_id = spirv_compiler_get_constant_uint(compiler, icb->vec4_count); + length_id = spirv_compiler_get_constant_uint(compiler, icb->element_count); type_id = vkd3d_spirv_get_op_type_array(builder, type_id, length_id); - const_id = vkd3d_spirv_build_op_constant_composite(builder, type_id, elements, icb->vec4_count); + const_id = vkd3d_spirv_build_op_constant_composite(builder, type_id, elements, icb->element_count); ptr_type_id = vkd3d_spirv_get_op_type_pointer(builder, SpvStorageClassPrivate, type_id); icb_id = vkd3d_spirv_build_op_variable(builder, &builder->global_stream, ptr_type_id, SpvStorageClassPrivate, const_id); diff --git a/libs/vkd3d-shader/tpf.c b/libs/vkd3d-shader/tpf.c index c471d1c58..596a0c499 100644 --- a/libs/vkd3d-shader/tpf.c +++ b/libs/vkd3d-shader/tpf.c @@ -784,7 +784,9 @@ static void shader_sm4_read_shader_data(struct vkd3d_shader_instruction *ins, ui ins->handler_idx = VKD3DSIH_INVALID; return; } - icb->vec4_count = icb_size / 4; + icb->data_type = VKD3D_DATA_FLOAT; + icb->component_count = VKD3D_VEC4_SIZE; + icb->element_count = icb_size / VKD3D_VEC4_SIZE; memcpy(icb->data, tokens, sizeof(*tokens) * icb_size); shader_instruction_array_add_icb(&priv->p.instructions, icb); ins->declaration.icb = icb; diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c index 9702cf185..052edeb50 100644 --- a/libs/vkd3d-shader/vkd3d_shader_main.c +++ b/libs/vkd3d-shader/vkd3d_shader_main.c @@ -1852,14 +1852,14 @@ bool shader_instruction_array_reserve(struct vkd3d_shader_instruction_array *ins return true; }
-bool shader_instruction_array_add_icb(struct vkd3d_shader_instruction_array *instructions, +unsigned int shader_instruction_array_add_icb(struct vkd3d_shader_instruction_array *instructions, struct vkd3d_shader_immediate_constant_buffer *icb) { if (!vkd3d_array_reserve((void **)&instructions->icbs, &instructions->icb_capacity, instructions->icb_count + 1, sizeof(*instructions->icbs))) - return false; - instructions->icbs[instructions->icb_count++] = icb; - return true; + return UINT_MAX; + instructions->icbs[instructions->icb_count] = icb; + return instructions->icb_count++; }
static struct vkd3d_shader_src_param *shader_instruction_array_clone_src_params( diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 37c962587..495bda146 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -716,7 +716,10 @@ struct vkd3d_shader_version
struct vkd3d_shader_immediate_constant_buffer { - unsigned int vec4_count; + enum vkd3d_data_type data_type; + /* total count is element_count * component_count */ + unsigned int element_count; + unsigned int component_count; uint32_t data[]; };
@@ -1102,7 +1105,7 @@ struct vkd3d_shader_instruction_array
bool shader_instruction_array_init(struct vkd3d_shader_instruction_array *instructions, unsigned int reserve); bool shader_instruction_array_reserve(struct vkd3d_shader_instruction_array *instructions, unsigned int reserve); -bool shader_instruction_array_add_icb(struct vkd3d_shader_instruction_array *instructions, +unsigned int shader_instruction_array_add_icb(struct vkd3d_shader_instruction_array *instructions, struct vkd3d_shader_immediate_constant_buffer *icb); bool shader_instruction_array_clone_instruction(struct vkd3d_shader_instruction_array *instructions, unsigned int dst, unsigned int src);
From: Conor McCarthy cmccarthy@codeweavers.com
--- libs/vkd3d-shader/dxil.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d-shader/dxil.c b/libs/vkd3d-shader/dxil.c index fd7aeb331..bfb34d248 100644 --- a/libs/vkd3d-shader/dxil.c +++ b/libs/vkd3d-shader/dxil.c @@ -973,14 +973,18 @@ static const struct dxil_block *sm6_parser_get_level_one_block(const struct sm6_ return found; }
-static char *dxil_record_to_string(const struct dxil_record *record, unsigned int offset) +static char *dxil_record_to_string(const struct dxil_record *record, unsigned int offset, struct sm6_parser *sm6) { unsigned int i; char *str;
assert(offset <= record->operand_count); if (!(str = vkd3d_calloc(record->operand_count - offset + 1, 1))) + { + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_OUT_OF_MEMORY, + "Out of memory allocating a string of length %u.", record->operand_count - offset); return NULL; + }
for (i = offset; i < record->operand_count; ++i) str[i - offset] = record->operands[i]; @@ -1235,7 +1239,7 @@ static enum vkd3d_result sm6_parser_type_table_init(struct sm6_parser *sm6) break;
case TYPE_CODE_STRUCT_NAME: - if (!(struct_name = dxil_record_to_string(record, 0))) + if (!(struct_name = dxil_record_to_string(record, 0, sm6))) { ERR("Failed to allocate struct name.\n"); return VKD3D_ERROR_OUT_OF_MEMORY; @@ -1459,7 +1463,7 @@ static enum vkd3d_result sm6_parser_symtab_init(struct sm6_parser *sm6)
symbol = &sm6->global_symbols[sm6->global_symbol_count]; symbol->id = record->operands[0]; - if (!(symbol->name = dxil_record_to_string(record, 1))) + if (!(symbol->name = dxil_record_to_string(record, 1, sm6))) { ERR("Failed to allocate symbol name.\n"); return VKD3D_ERROR_OUT_OF_MEMORY;
From: Conor McCarthy cmccarthy@codeweavers.com
These are needed for reading metadata. --- libs/vkd3d-shader/dxil.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/libs/vkd3d-shader/dxil.c b/libs/vkd3d-shader/dxil.c index 4963ceac8..fd7aeb331 100644 --- a/libs/vkd3d-shader/dxil.c +++ b/libs/vkd3d-shader/dxil.c @@ -2156,6 +2156,7 @@ static enum vkd3d_result sm6_parser_globals_init(struct sm6_parser *sm6) { const struct dxil_block *block = &sm6->root_block; const struct dxil_record *record; + enum vkd3d_result ret; uint64_t version; size_t i;
@@ -2198,6 +2199,13 @@ static enum vkd3d_result sm6_parser_globals_init(struct sm6_parser *sm6) } }
+ for (i = 0; i < block->child_block_count; ++i) + { + if (block->child_blocks[i]->id == CONSTANTS_BLOCK + && (ret = sm6_parser_constants_init(sm6, block->child_blocks[i])) < 0) + return ret; + } + return VKD3D_OK; }
@@ -2770,6 +2778,9 @@ static enum vkd3d_result sm6_parser_module_init(struct sm6_parser *sm6, const st switch (block->id) { case CONSTANTS_BLOCK: + /* Level 1 (global) constants are already done in sm6_parser_globals_init(). */ + if (level < 2) + break; function = &sm6->functions[sm6->function_count]; sm6->cur_max_value = function->value_count; return sm6_parser_constants_init(sm6, block);
From: Conor McCarthy cmccarthy@codeweavers.com
--- libs/vkd3d-shader/dxil.c | 134 ++++++++++++++++++++++- libs/vkd3d-shader/vkd3d_shader_private.h | 1 + 2 files changed, 134 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/dxil.c b/libs/vkd3d-shader/dxil.c index bfb34d248..19a9758ab 100644 --- a/libs/vkd3d-shader/dxil.c +++ b/libs/vkd3d-shader/dxil.c @@ -20,6 +20,8 @@
#define VKD3D_SM6_VERSION_MAJOR(version) (((version) >> 4) & 0xf) #define VKD3D_SM6_VERSION_MINOR(version) (((version) >> 0) & 0xf) +/* Two seems to be the maximum but leave some extra room. */ +#define VKD3D_SM6_MAX_METADATA_TABLES 4
#define BITCODE_MAGIC VKD3D_MAKE_TAG('B', 'C', 0xc0, 0xde) #define DXIL_OP_MAX_OPERANDS 17 @@ -114,6 +116,19 @@ enum bitcode_function_code FUNC_CODE_INST_CMPXCHG = 46, };
+enum bitcode_metadata_code +{ + METADATA_STRING = 1, + METADATA_VALUE = 2, + METADATA_NODE = 3, + METADATA_NAME = 4, + METADATA_DISTINCT_NODE = 5, + METADATA_KIND = 6, + METADATA_LOCATION = 7, + METADATA_NAMED_NODE = 10, + METADATA_ATTACHMENT = 11, +}; + enum bitcode_type_code { TYPE_CODE_NUMENTRY = 1, @@ -278,6 +293,26 @@ struct dxil_block size_t record_count; };
+enum sm6_metadata_type +{ + VKD3D_METADATA_STRING, +}; + +struct sm6_metadata_value +{ + enum sm6_metadata_type type; + union + { + char *string_value; + } u; +}; + +struct sm6_metadata_table +{ + struct sm6_metadata_value *values; + unsigned int count; +}; + struct sm6_parser { const uint32_t *ptr, *start, *end; @@ -292,6 +327,7 @@ struct sm6_parser
struct sm6_type *types; size_t type_count; + struct sm6_type *metadata_type;
struct sm6_symbol *global_symbols; size_t global_symbol_count; @@ -302,6 +338,8 @@ struct sm6_parser struct sm6_function *functions; size_t function_count;
+ struct sm6_metadata_table metadata_tables[VKD3D_SM6_MAX_METADATA_TABLES]; + struct sm6_value *values; size_t value_count; size_t value_capacity; @@ -1173,6 +1211,7 @@ static enum vkd3d_result sm6_parser_type_table_init(struct sm6_parser *sm6)
case TYPE_CODE_METADATA: type->class = TYPE_CLASS_METADATA; + sm6->metadata_type = type; break;
case TYPE_CODE_NUMENTRY: @@ -2818,6 +2857,80 @@ static enum vkd3d_result sm6_parser_module_init(struct sm6_parser *sm6, const st return VKD3D_OK; }
+static enum vkd3d_result sm6_parser_metadata_init(struct sm6_parser *sm6, const struct dxil_block *block, + struct sm6_metadata_table *table) +{ + struct sm6_metadata_value *values, *m; + unsigned int i, count, table_idx; + const struct dxil_record *record; + + for (i = 0, count = 0; i < block->record_count; ++i) + count += block->records[i]->code != METADATA_NAME; + + if (!(values = vkd3d_calloc(count, sizeof(*values)))) + { + ERR("Failed to allocate metadata tables.\n"); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_OUT_OF_MEMORY, + "Out of memory allocating metadata tables."); + return VKD3D_ERROR_OUT_OF_MEMORY; + } + table->values = values; + + for (i = 0; i < block->record_count; ++i) + { + record = block->records[i]; + + table_idx = table->count; + m = &values[table_idx]; + + switch (record->code) + { + case METADATA_STRING: + /* LLVM allows an empty string here. */ + m->type = VKD3D_METADATA_STRING; + if (!(m->u.string_value = dxil_record_to_string(record, 0, sm6))) + { + ERR("Failed to allocate string.\n"); + return VKD3D_ERROR_OUT_OF_MEMORY; + } + break; + + default: + FIXME("Unhandled metadata type %u.\n", record->code); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_METADATA, + "Metadata type %u is unhandled.", record->code); + return VKD3D_ERROR_INVALID_SHADER; + } + ++table->count; + } + + return VKD3D_OK; +} + +static void sm6_metadata_value_destroy(struct sm6_metadata_value *m) +{ + switch (m->type) + { + case VKD3D_METADATA_STRING: + vkd3d_free(m->u.string_value); + break; + default: + break; + } +} + +static void sm6_parser_metadata_cleanup(struct sm6_parser *sm6) +{ + unsigned int i, j; + + for (i = 0; i < ARRAY_SIZE(sm6->metadata_tables); ++i) + { + for (j = 0; j < sm6->metadata_tables[i].count; ++j) + sm6_metadata_value_destroy(&sm6->metadata_tables[i].values[j]); + vkd3d_free(sm6->metadata_tables[i].values); + } +} + static void sm6_type_table_cleanup(struct sm6_type *types, size_t count) { size_t i; @@ -2881,6 +2994,7 @@ static void sm6_parser_destroy(struct vkd3d_shader_parser *parser) sm6_type_table_cleanup(sm6->types, sm6->type_count); sm6_symtab_cleanup(sm6->global_symbols, sm6->global_symbol_count); sm6_functions_cleanup(sm6->functions, sm6->function_count); + sm6_parser_metadata_cleanup(sm6); vkd3d_free(sm6->values); free_shader_desc(&parser->shader_desc); vkd3d_free(sm6); @@ -2904,7 +3018,7 @@ static enum vkd3d_result sm6_parser_init(struct sm6_parser *sm6, const uint32_t struct vkd3d_shader_version version; struct dxil_block *block; enum vkd3d_result ret; - unsigned int i; + unsigned int i, j;
count = byte_code_size / sizeof(*byte_code); if (count < 6) @@ -3091,6 +3205,24 @@ static enum vkd3d_result sm6_parser_init(struct sm6_parser *sm6, const uint32_t return ret; }
+ for (i = 0, j = 0; i < sm6->root_block.child_block_count; ++i) + { + block = sm6->root_block.child_blocks[i]; + if (block->id != METADATA_BLOCK) + continue; + + if (j == ARRAY_SIZE(sm6->metadata_tables)) + { + FIXME("Too many metadata tables.\n"); + vkd3d_shader_error(message_context, &location, VKD3D_SHADER_ERROR_DXIL_INVALID_METADATA, + "A metadata table count greater than %zu is unsupported.", ARRAY_SIZE(sm6->metadata_tables)); + return VKD3D_ERROR_INVALID_SHADER; + } + + if ((ret = sm6_parser_metadata_init(sm6, block, &sm6->metadata_tables[j++])) < 0) + return ret; + } + sm6_parser_init_output_signature(sm6, output_signature); sm6_parser_init_input_signature(sm6, input_signature);
diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 495bda146..f94a12df7 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -176,6 +176,7 @@ enum vkd3d_shader_error VKD3D_SHADER_ERROR_DXIL_INVALID_MODULE = 8011, VKD3D_SHADER_ERROR_DXIL_INVALID_OPERAND = 8012, VKD3D_SHADER_ERROR_DXIL_UNHANDLED_INTRINSIC = 8013, + VKD3D_SHADER_ERROR_DXIL_INVALID_METADATA = 8014,
VKD3D_SHADER_WARNING_DXIL_UNKNOWN_MAGIC_NUMBER = 8300, VKD3D_SHADER_WARNING_DXIL_UNKNOWN_SHADER_TYPE = 8301,
From: Conor McCarthy cmccarthy@codeweavers.com
--- libs/vkd3d-shader/dxil.c | 76 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+)
diff --git a/libs/vkd3d-shader/dxil.c b/libs/vkd3d-shader/dxil.c index 19a9758ab..d36224999 100644 --- a/libs/vkd3d-shader/dxil.c +++ b/libs/vkd3d-shader/dxil.c @@ -295,15 +295,25 @@ struct dxil_block
enum sm6_metadata_type { + VKD3D_METADATA_NODE, VKD3D_METADATA_STRING, };
+struct sm6_metadata_node +{ + bool is_distinct; + unsigned int operand_count; + struct sm6_metadata_value *operands[]; +}; + struct sm6_metadata_value { enum sm6_metadata_type type; + const struct sm6_type *value_type; union { char *string_value; + struct sm6_metadata_node *node; } u; };
@@ -2857,12 +2867,69 @@ static enum vkd3d_result sm6_parser_module_init(struct sm6_parser *sm6, const st return VKD3D_OK; }
+static enum vkd3d_result metadata_value_create_node(struct sm6_metadata_value *m, struct sm6_metadata_table *table, + unsigned int dst_idx, unsigned int end_count, const struct dxil_record *record, struct sm6_parser *sm6) +{ + struct sm6_metadata_node *node; + unsigned int i; + + m->type = VKD3D_METADATA_NODE; + if (!(m->value_type = sm6->metadata_type)) + { + WARN("Metadata type not found.\n"); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_METADATA, + "The type for metadata values was not found."); + return VKD3D_ERROR_INVALID_SHADER; + } + if (!(node = vkd3d_malloc(offsetof(struct sm6_metadata_node, operands[record->operand_count])))) + { + ERR("Failed to allocate metadata node with %u operands.\n", record->operand_count); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_OUT_OF_MEMORY, + "Out of memory allocating a metadata node with %u operands.", record->operand_count); + return VKD3D_ERROR_OUT_OF_MEMORY; + } + m->u.node = node; + + node->is_distinct = record->code == METADATA_DISTINCT_NODE; + + for (i = 0; i < record->operand_count; ++i) + { + uint64_t ref; + + ref = record->operands[i] - 1; + if (record->operands[i] >= 1 && ref >= end_count) + { + WARN("Invalid metadata index %"PRIu64".\n", ref); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_METADATA, + "Metadata index %"PRIu64" is invalid.", ref); + vkd3d_free(node); + return VKD3D_ERROR_INVALID_SHADER; + } + + if (!node->is_distinct && ref == dst_idx) + { + WARN("Metadata self-reference at index %u.\n", dst_idx); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_METADATA, + "Metadata index %u is self-referencing.", dst_idx); + vkd3d_free(node); + return VKD3D_ERROR_INVALID_SHADER; + } + + node->operands[i] = (record->operands[i] >= 1) ? &table->values[ref] : NULL; + } + + node->operand_count = record->operand_count; + + return VKD3D_OK; +} + static enum vkd3d_result sm6_parser_metadata_init(struct sm6_parser *sm6, const struct dxil_block *block, struct sm6_metadata_table *table) { struct sm6_metadata_value *values, *m; unsigned int i, count, table_idx; const struct dxil_record *record; + enum vkd3d_result ret;
for (i = 0, count = 0; i < block->record_count; ++i) count += block->records[i]->code != METADATA_NAME; @@ -2885,6 +2952,12 @@ static enum vkd3d_result sm6_parser_metadata_init(struct sm6_parser *sm6, const
switch (record->code) { + case METADATA_DISTINCT_NODE: + case METADATA_NODE: + if ((ret = metadata_value_create_node(m, table, table_idx, count, record, sm6)) < 0) + return ret; + break; + case METADATA_STRING: /* LLVM allows an empty string here. */ m->type = VKD3D_METADATA_STRING; @@ -2911,6 +2984,9 @@ static void sm6_metadata_value_destroy(struct sm6_metadata_value *m) { switch (m->type) { + case VKD3D_METADATA_NODE: + vkd3d_free(m->u.node); + break; case VKD3D_METADATA_STRING: vkd3d_free(m->u.string_value); break;
From: Conor McCarthy cmccarthy@codeweavers.com
--- libs/vkd3d-shader/dxil.c | 54 +++++++++++++++++++++++- libs/vkd3d-shader/vkd3d_shader_private.h | 1 + 2 files changed, 54 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/dxil.c b/libs/vkd3d-shader/dxil.c index d36224999..2c04f5d16 100644 --- a/libs/vkd3d-shader/dxil.c +++ b/libs/vkd3d-shader/dxil.c @@ -297,6 +297,7 @@ enum sm6_metadata_type { VKD3D_METADATA_NODE, VKD3D_METADATA_STRING, + VKD3D_METADATA_VALUE, };
struct sm6_metadata_node @@ -313,6 +314,7 @@ struct sm6_metadata_value union { char *string_value; + const struct sm6_value *value; struct sm6_metadata_node *node; } u; }; @@ -1601,6 +1603,11 @@ static inline bool sm6_value_is_undef(const struct sm6_value *value) return sm6_value_is_register(value) && value->u.reg.type == VKD3DSPR_UNDEF; }
+static bool sm6_value_is_icb(const struct sm6_value *value) +{ + return sm6_value_is_register(value) && value->u.reg.type == VKD3DSPR_IMMCONSTBUFFER; +} + static inline unsigned int sm6_value_get_constant_uint(const struct sm6_value *value) { if (!sm6_value_is_constant(value)) @@ -1831,6 +1838,17 @@ static size_t sm6_parser_get_value_index(struct sm6_parser *sm6, uint64_t idx) return i; }
+static const struct sm6_value *sm6_parser_get_value_safe(struct sm6_parser *sm6, unsigned int idx) +{ + if (idx < sm6->value_count) + return &sm6->values[idx]; + + WARN("Invalid value index %u.\n", idx); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_OPERAND, + "Invalid value index %u.", idx); + return NULL; +} + static size_t sm6_parser_get_value_idx_by_ref(struct sm6_parser *sm6, const struct dxil_record *record, const struct sm6_type *fwd_type, unsigned int *rec_idx) { @@ -2926,9 +2944,10 @@ static enum vkd3d_result metadata_value_create_node(struct sm6_metadata_value *m static enum vkd3d_result sm6_parser_metadata_init(struct sm6_parser *sm6, const struct dxil_block *block, struct sm6_metadata_table *table) { + unsigned int i, count, table_idx, value_idx; struct sm6_metadata_value *values, *m; - unsigned int i, count, table_idx; const struct dxil_record *record; + const struct sm6_value *value; enum vkd3d_result ret;
for (i = 0, count = 0; i < block->record_count; ++i) @@ -2968,6 +2987,39 @@ static enum vkd3d_result sm6_parser_metadata_init(struct sm6_parser *sm6, const } break;
+ case METADATA_VALUE: + if (!dxil_record_validate_operand_count(record, 2, 2, sm6)) + return VKD3D_ERROR_INVALID_SHADER; + + m->type = VKD3D_METADATA_VALUE; + if (!(m->value_type = sm6_parser_get_type(sm6, record->operands[0]))) + return VKD3D_ERROR_INVALID_SHADER; + + if (record->operands[1] > UINT_MAX) + WARN("Truncating value index %"PRIu64".\n", record->operands[1]); + value_idx = record->operands[1]; + if (!(value = sm6_parser_get_value_safe(sm6, value_idx))) + return VKD3D_ERROR_INVALID_SHADER; + + if (!sm6_value_is_constant(value) && !sm6_value_is_undef(value) && !sm6_value_is_icb(value) + && !sm6_value_is_function_dcl(value)) + { + WARN("Value at index %u is not a constant or a function declaration.\n", value_idx); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_METADATA, + "Metadata value at index %u is not a constant or a function declaration.", value_idx); + return VKD3D_ERROR_INVALID_SHADER; + } + m->u.value = value; + + if (value->type != m->value_type) + { + WARN("Type mismatch.\n"); + vkd3d_shader_parser_warning(&sm6->p, VKD3D_SHADER_WARNING_DXIL_TYPE_MISMATCH, + "The type of a metadata value does not match its referenced value at index %u.", value_idx); + } + + break; + default: FIXME("Unhandled metadata type %u.\n", record->code); vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_METADATA, diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index f94a12df7..060647a68 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -183,6 +183,7 @@ enum vkd3d_shader_error VKD3D_SHADER_WARNING_DXIL_INVALID_BLOCK_LENGTH = 8302, VKD3D_SHADER_WARNING_DXIL_INVALID_MODULE_LENGTH = 8303, VKD3D_SHADER_WARNING_DXIL_IGNORING_OPERANDS = 8304, + VKD3D_SHADER_WARNING_DXIL_TYPE_MISMATCH = 8305,
VKD3D_SHADER_ERROR_VSIR_NOT_IMPLEMENTED = 9000, VKD3D_SHADER_ERROR_VSIR_INVALID_HANDLER = 9001,
From: Conor McCarthy cmccarthy@codeweavers.com
--- libs/vkd3d-shader/dxil.c | 104 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 99 insertions(+), 5 deletions(-)
diff --git a/libs/vkd3d-shader/dxil.c b/libs/vkd3d-shader/dxil.c index 2695b9f61..9e591af25 100644 --- a/libs/vkd3d-shader/dxil.c +++ b/libs/vkd3d-shader/dxil.c @@ -333,6 +333,12 @@ struct sm6_metadata_table unsigned int count; };
+struct sm6_named_metadata +{ + char *name; + struct sm6_metadata_value value; +}; + struct sm6_parser { const uint32_t *ptr, *start, *end; @@ -359,6 +365,8 @@ struct sm6_parser size_t function_count;
struct sm6_metadata_table metadata_tables[VKD3D_SM6_MAX_METADATA_TABLES]; + struct sm6_named_metadata *named_metadata; + unsigned int named_metadata_count;
struct sm6_value *values; size_t value_count; @@ -2697,6 +2705,11 @@ static void sm6_parser_emit_ret(struct sm6_parser *sm6, const struct dxil_record ins->handler_idx = VKD3DSIH_NOP; }
+static bool sm6_metadata_value_is_node(const struct sm6_metadata_value *m) +{ + return m && m->type == VKD3D_METADATA_NODE; +} + static enum vkd3d_result sm6_parser_function_init(struct sm6_parser *sm6, const struct dxil_block *block, struct sm6_function *function) { @@ -2893,11 +2906,31 @@ static enum vkd3d_result sm6_parser_module_init(struct sm6_parser *sm6, const st return VKD3D_OK; }
+static bool sm6_parser_allocate_named_metadata(struct sm6_parser *sm6) +{ + struct dxil_block *block; + unsigned int i, j, count; + + for (i = 0, count = 0; i < sm6->root_block.child_block_count; ++i) + { + block = sm6->root_block.child_blocks[i]; + if (block->id != METADATA_BLOCK) + continue; + for (j = 0; j < block->record_count; ++j) + count += block->records[j]->code == METADATA_NAMED_NODE; + } + + if (!count) + return true; + + return !!(sm6->named_metadata = vkd3d_calloc(count, sizeof(*sm6->named_metadata))); +} + static enum vkd3d_result metadata_value_create_node(struct sm6_metadata_value *m, struct sm6_metadata_table *table, unsigned int dst_idx, unsigned int end_count, const struct dxil_record *record, struct sm6_parser *sm6) { struct sm6_metadata_node *node; - unsigned int i; + unsigned int i, offset;
m->type = VKD3D_METADATA_NODE; if (!(m->value_type = sm6->metadata_type)) @@ -2918,12 +2951,14 @@ static enum vkd3d_result metadata_value_create_node(struct sm6_metadata_value *m
node->is_distinct = record->code == METADATA_DISTINCT_NODE;
+ offset = record->code != METADATA_NAMED_NODE; + for (i = 0; i < record->operand_count; ++i) { uint64_t ref;
- ref = record->operands[i] - 1; - if (record->operands[i] >= 1 && ref >= end_count) + ref = record->operands[i] - offset; + if (record->operands[i] >= offset && ref >= end_count) { WARN("Invalid metadata index %"PRIu64".\n", ref); vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_METADATA, @@ -2941,7 +2976,15 @@ static enum vkd3d_result metadata_value_create_node(struct sm6_metadata_value *m return VKD3D_ERROR_INVALID_SHADER; }
- node->operands[i] = (record->operands[i] >= 1) ? &table->values[ref] : NULL; + node->operands[i] = (record->operands[i] >= offset) ? &table->values[ref] : NULL; + if (record->code == METADATA_NAMED_NODE && !sm6_metadata_value_is_node(node->operands[i])) + { + WARN("Named node operand is not a node.\n"); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_METADATA, + "The operand of a metadata named node is not a node."); + vkd3d_free(node); + return VKD3D_ERROR_INVALID_SHADER; + } }
node->operand_count = record->operand_count; @@ -2957,6 +3000,7 @@ static enum vkd3d_result sm6_parser_metadata_init(struct sm6_parser *sm6, const const struct dxil_record *record; const struct sm6_value *value; enum vkd3d_result ret; + char *name;
for (i = 0, count = 0; i < block->record_count; ++i) count += block->records[i]->code != METADATA_NAME; @@ -2970,7 +3014,7 @@ static enum vkd3d_result sm6_parser_metadata_init(struct sm6_parser *sm6, const } table->values = values;
- for (i = 0; i < block->record_count; ++i) + for (i = 0, name = NULL; i < block->record_count; ++i) { record = block->records[i];
@@ -2979,6 +3023,27 @@ static enum vkd3d_result sm6_parser_metadata_init(struct sm6_parser *sm6, const
switch (record->code) { + case METADATA_NAMED_NODE: + if (!name) + { + WARN("Named node has no name.\n"); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_METADATA, + "A metadata named node has no name."); + return VKD3D_ERROR_INVALID_SHADER; + } + + /* When DXC emits metadata value array reference indices it assumes named nodes + * are not included in the array. Store named nodes separately. */ + m = &sm6->named_metadata[sm6->named_metadata_count].value; + sm6->named_metadata[sm6->named_metadata_count].name = name; + name = NULL; + + if ((ret = metadata_value_create_node(m, table, UINT_MAX, count, record, sm6)) < 0) + return ret; + ++sm6->named_metadata_count; + /* Skip incrementing the table count. */ + continue; + case METADATA_DISTINCT_NODE: case METADATA_NODE: if ((ret = metadata_value_create_node(m, table, table_idx, count, record, sm6)) < 0) @@ -2998,6 +3063,23 @@ static enum vkd3d_result sm6_parser_metadata_init(struct sm6_parser *sm6, const } break;
+ case METADATA_NAME: + /* Check the next record to avoid freeing 'name' in all exit paths. */ + if (i + 1 == block->record_count || block->records[i + 1]->code != METADATA_NAMED_NODE) + { + WARN("Name is not followed by a named node.\n"); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_METADATA, + "A metadata node name is not followed by a named node."); + return VKD3D_ERROR_INVALID_SHADER; + } + /* LLVM allows an empty string here. */ + if (!(name = dxil_record_to_string(record, 0, sm6))) + { + ERR("Failed to allocate name.\n"); + return VKD3D_ERROR_OUT_OF_MEMORY; + } + continue; + case METADATA_STRING: /* LLVM allows an empty string here. */ m->type = VKD3D_METADATA_STRING; @@ -3081,6 +3163,12 @@ static void sm6_parser_metadata_cleanup(struct sm6_parser *sm6) sm6_metadata_value_destroy(&sm6->metadata_tables[i].values[j]); vkd3d_free(sm6->metadata_tables[i].values); } + for (i = 0; i < sm6->named_metadata_count; ++i) + { + sm6_metadata_value_destroy(&sm6->named_metadata[i].value); + vkd3d_free(sm6->named_metadata[i].name); + } + vkd3d_free(sm6->named_metadata); }
static void sm6_type_table_cleanup(struct sm6_type *types, size_t count) @@ -3357,6 +3445,12 @@ static enum vkd3d_result sm6_parser_init(struct sm6_parser *sm6, const uint32_t return ret; }
+ if (!sm6_parser_allocate_named_metadata(sm6)) + { + ERR("Failed to allocate named metadata array.\n"); + return VKD3D_ERROR_OUT_OF_MEMORY; + } + for (i = 0, j = 0; i < sm6->root_block.child_block_count; ++i) { block = sm6->root_block.child_blocks[i];
From: Conor McCarthy cmccarthy@codeweavers.com
--- libs/vkd3d-shader/dxil.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
diff --git a/libs/vkd3d-shader/dxil.c b/libs/vkd3d-shader/dxil.c index 2c04f5d16..2695b9f61 100644 --- a/libs/vkd3d-shader/dxil.c +++ b/libs/vkd3d-shader/dxil.c @@ -295,6 +295,7 @@ struct dxil_block
enum sm6_metadata_type { + VKD3D_METADATA_KIND, VKD3D_METADATA_NODE, VKD3D_METADATA_STRING, VKD3D_METADATA_VALUE, @@ -307,6 +308,12 @@ struct sm6_metadata_node struct sm6_metadata_value *operands[]; };
+struct sm6_metadata_kind +{ + uint64_t id; + char *name; +}; + struct sm6_metadata_value { enum sm6_metadata_type type; @@ -316,6 +323,7 @@ struct sm6_metadata_value char *string_value; const struct sm6_value *value; struct sm6_metadata_node *node; + struct sm6_metadata_kind kind; } u; };
@@ -2977,6 +2985,19 @@ static enum vkd3d_result sm6_parser_metadata_init(struct sm6_parser *sm6, const return ret; break;
+ case METADATA_KIND: + if (!dxil_record_validate_operand_min_count(record, 2, sm6)) + return VKD3D_ERROR_INVALID_SHADER; + + m->type = VKD3D_METADATA_KIND; + m->u.kind.id = record->operands[0]; + if (!(m->u.kind.name = dxil_record_to_string(record, 1, sm6))) + { + ERR("Failed to allocate name of a kind.\n"); + return VKD3D_ERROR_OUT_OF_MEMORY; + } + break; + case METADATA_STRING: /* LLVM allows an empty string here. */ m->type = VKD3D_METADATA_STRING; @@ -3039,6 +3060,9 @@ static void sm6_metadata_value_destroy(struct sm6_metadata_value *m) case VKD3D_METADATA_NODE: vkd3d_free(m->u.node); break; + case VKD3D_METADATA_KIND: + vkd3d_free(m->u.kind.name); + break; case VKD3D_METADATA_STRING: vkd3d_free(m->u.string_value); break;
From: Conor McCarthy cmccarthy@codeweavers.com
--- libs/vkd3d-shader/dxil.c | 112 +++++++++++++++++++++-- libs/vkd3d-shader/vkd3d_shader_private.h | 2 + 2 files changed, 105 insertions(+), 9 deletions(-)
diff --git a/libs/vkd3d-shader/dxil.c b/libs/vkd3d-shader/dxil.c index 9e591af25..fdcb84013 100644 --- a/libs/vkd3d-shader/dxil.c +++ b/libs/vkd3d-shader/dxil.c @@ -358,6 +358,8 @@ struct sm6_parser struct sm6_symbol *global_symbols; size_t global_symbol_count;
+ const char *entry_point; + struct vkd3d_shader_dst_param *output_params; struct vkd3d_shader_dst_param *input_params;
@@ -2710,6 +2712,11 @@ static bool sm6_metadata_value_is_node(const struct sm6_metadata_value *m) return m && m->type == VKD3D_METADATA_NODE; }
+static bool sm6_metadata_value_is_string(const struct sm6_metadata_value *m) +{ + return m && m->type == VKD3D_METADATA_STRING; +} + static enum vkd3d_result sm6_parser_function_init(struct sm6_parser *sm6, const struct dxil_block *block, struct sm6_function *function) { @@ -3135,6 +3142,77 @@ static enum vkd3d_result sm6_parser_metadata_init(struct sm6_parser *sm6, const return VKD3D_OK; }
+static const struct sm6_metadata_value *sm6_parser_find_named_metadata(struct sm6_parser *sm6, const char *name) +{ + const struct sm6_metadata_node *node; + unsigned int i; + + for (i = 0; i < sm6->named_metadata_count; ++i) + { + if (strcmp(sm6->named_metadata[i].name, name)) + continue; + + node = sm6->named_metadata[i].value.u.node; + if (!node->operand_count) + return NULL; + if (node->operand_count > 1) + { + FIXME("Ignoring %u extra operands for %s.\n", node->operand_count - 1, name); + vkd3d_shader_parser_warning(&sm6->p, VKD3D_SHADER_WARNING_DXIL_IGNORING_OPERANDS, + "Ignoring %u extra operands for metadata node %s.", node->operand_count - 1, name); + } + return node->operands[0]; + } + + return NULL; +} + +static enum vkd3d_result sm6_parser_entry_point_init(struct sm6_parser *sm6) +{ + const struct sm6_metadata_value *m = sm6_parser_find_named_metadata(sm6, "dx.entryPoints"); + const struct sm6_metadata_node *entry_node = m ? m->u.node : NULL; + const struct sm6_value *value; + + if (!entry_node || entry_node->operand_count < 2 || !(m = entry_node->operands[0])) + { + WARN("No entry point definition found.\n"); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_ENTRY_POINT, + "No entry point definition found in the metadata."); + return VKD3D_ERROR_INVALID_SHADER; + } + + if (m->type != VKD3D_METADATA_VALUE) + { + WARN("Entry point definition is not a value.\n"); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_ENTRY_POINT, + "Entry point definition is not a metadata value."); + return VKD3D_ERROR_INVALID_SHADER; + } + + value = m->u.value; + if (!sm6_value_is_function_dcl(value)) + { + WARN("Entry point value is not a function definition.\n"); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_ENTRY_POINT, + "Entry point metadata value does not contain a function definition."); + return VKD3D_ERROR_INVALID_SHADER; + } + + sm6->entry_point = value->u.function.name; + if (!sm6_metadata_value_is_string(entry_node->operands[1]) + || ascii_strcasecmp(sm6->entry_point, entry_node->operands[1]->u.string_value)) + { + WARN("Entry point function name %s mismatch.\n", sm6->entry_point); + vkd3d_shader_parser_warning(&sm6->p, VKD3D_SHADER_WARNING_DXIL_ENTRY_POINT_MISMATCH, + "Entry point function name %s does not match the name in metadata.", sm6->entry_point); + } + + sm6_parser_init_input_signature(sm6, &sm6->p.shader_desc.input_signature); + sm6_parser_init_output_signature(sm6, &sm6->p.shader_desc.output_signature); + + return VKD3D_OK; +} + static void sm6_metadata_value_destroy(struct sm6_metadata_value *m) { switch (m->type) @@ -3245,6 +3323,15 @@ static const struct vkd3d_shader_parser_ops sm6_parser_ops = .parser_destroy = sm6_parser_destroy, };
+static struct sm6_function *sm6_parser_get_function(const struct sm6_parser *sm6, const char *name) +{ + size_t i; + for (i = 0; i < sm6->function_count; ++i) + if (!ascii_strcasecmp(sm6->functions[i].declaration->u.function.name, name)) + return &sm6->functions[i]; + return NULL; +} + static enum vkd3d_result sm6_parser_init(struct sm6_parser *sm6, const uint32_t *byte_code, size_t byte_code_size, const char *source_name, struct vkd3d_shader_message_context *message_context) { @@ -3257,6 +3344,7 @@ static enum vkd3d_result sm6_parser_init(struct sm6_parser *sm6, const uint32_t enum bitcode_block_abbreviation abbr; struct vkd3d_shader_version version; struct dxil_block *block; + struct sm6_function *fn; enum vkd3d_result ret; unsigned int i, j;
@@ -3469,8 +3557,8 @@ static enum vkd3d_result sm6_parser_init(struct sm6_parser *sm6, const uint32_t return ret; }
- sm6_parser_init_output_signature(sm6, output_signature); - sm6_parser_init_input_signature(sm6, input_signature); + if ((ret = sm6_parser_entry_point_init(sm6)) < 0) + return ret;
if ((ret = sm6_parser_module_init(sm6, &sm6->root_block, 0)) < 0) { @@ -3494,14 +3582,20 @@ static enum vkd3d_result sm6_parser_init(struct sm6_parser *sm6, const uint32_t
sm6->p.shader_desc.ssa_count = sm6->ssa_next_id;
- for (i = 0; i < sm6->function_count; ++i) + if (!(fn = sm6_parser_get_function(sm6, sm6->entry_point))) { - if (!sm6_block_emit_instructions(sm6->functions[i].blocks[0], sm6)) - { - vkd3d_shader_error(message_context, &location, VKD3D_SHADER_ERROR_DXIL_OUT_OF_MEMORY, - "Out of memory emitting shader instructions."); - return VKD3D_ERROR_OUT_OF_MEMORY; - } + WARN("Failed to find entry point %s.\n", sm6->entry_point); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_ENTRY_POINT, + "The definition of the entry point function '%s' was not found.", sm6->entry_point); + return VKD3D_ERROR_INVALID_SHADER; + } + + assert(sm6->function_count == 1); + if (!sm6_block_emit_instructions(fn->blocks[0], sm6)) + { + vkd3d_shader_error(message_context, &location, VKD3D_SHADER_ERROR_DXIL_OUT_OF_MEMORY, + "Out of memory emitting shader instructions."); + return VKD3D_ERROR_OUT_OF_MEMORY; }
dxil_block_destroy(&sm6->root_block); diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 060647a68..a0140c674 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -177,6 +177,7 @@ enum vkd3d_shader_error VKD3D_SHADER_ERROR_DXIL_INVALID_OPERAND = 8012, VKD3D_SHADER_ERROR_DXIL_UNHANDLED_INTRINSIC = 8013, VKD3D_SHADER_ERROR_DXIL_INVALID_METADATA = 8014, + VKD3D_SHADER_ERROR_DXIL_INVALID_ENTRY_POINT = 8015,
VKD3D_SHADER_WARNING_DXIL_UNKNOWN_MAGIC_NUMBER = 8300, VKD3D_SHADER_WARNING_DXIL_UNKNOWN_SHADER_TYPE = 8301, @@ -184,6 +185,7 @@ enum vkd3d_shader_error VKD3D_SHADER_WARNING_DXIL_INVALID_MODULE_LENGTH = 8303, VKD3D_SHADER_WARNING_DXIL_IGNORING_OPERANDS = 8304, VKD3D_SHADER_WARNING_DXIL_TYPE_MISMATCH = 8305, + VKD3D_SHADER_WARNING_DXIL_ENTRY_POINT_MISMATCH = 8306,
VKD3D_SHADER_ERROR_VSIR_NOT_IMPLEMENTED = 9000, VKD3D_SHADER_ERROR_VSIR_INVALID_HANDLER = 9001,
From: Conor McCarthy cmccarthy@codeweavers.com
These can differ from the DXBC signatures by having multiple rows, and load/store instructions reference them by id instead of register index. --- libs/vkd3d-shader/dxbc.c | 2 + libs/vkd3d-shader/dxil.c | 358 ++++++++++++++++++++++- libs/vkd3d-shader/vkd3d_shader_private.h | 4 + 3 files changed, 360 insertions(+), 4 deletions(-)
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index dbbf8a5c4..a9a7aefe8 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -435,6 +435,8 @@ static int shader_parse_signature(const struct vkd3d_shader_dxbc_section_desc *s else e[i].min_precision = VKD3D_SHADER_MINIMUM_PRECISION_NONE;
+ e[i].interpolation_mode = VKD3DSIM_NONE; + TRACE("Stream: %u, semantic: %s, semantic idx: %u, sysval_semantic %#x, " "type %u, register idx: %u, use_mask %#x, input_mask %#x, precision %u.\n", e[i].stream_index, debugstr_a(e[i].semantic_name), e[i].semantic_index, e[i].sysval_semantic, diff --git a/libs/vkd3d-shader/dxil.c b/libs/vkd3d-shader/dxil.c index fdcb84013..48fbcaf13 100644 --- a/libs/vkd3d-shader/dxil.c +++ b/libs/vkd3d-shader/dxil.c @@ -154,6 +154,66 @@ enum bitcode_value_symtab_code VST_CODE_BBENTRY = 2, };
+enum dxil_component_type +{ + COMPONENT_TYPE_INVALID = 0, + COMPONENT_TYPE_I1 = 1, + COMPONENT_TYPE_I16 = 2, + COMPONENT_TYPE_U16 = 3, + COMPONENT_TYPE_I32 = 4, + COMPONENT_TYPE_U32 = 5, + COMPONENT_TYPE_I64 = 6, + COMPONENT_TYPE_U64 = 7, + COMPONENT_TYPE_F16 = 8, + COMPONENT_TYPE_F32 = 9, + COMPONENT_TYPE_F64 = 10, + COMPONENT_TYPE_SNORMF16 = 11, + COMPONENT_TYPE_UNORMF16 = 12, + COMPONENT_TYPE_SNORMF32 = 13, + COMPONENT_TYPE_UNORMF32 = 14, + COMPONENT_TYPE_SNORMF64 = 15, + COMPONENT_TYPE_UNORMF64 = 16, + COMPONENT_TYPE_PACKEDS8X32 = 17, + COMPONENT_TYPE_PACKEDU8X32 = 18, +}; + +enum dxil_semantic_kind +{ + SEMANTIC_KIND_ARBITRARY = 0, + SEMANTIC_KIND_VERTEXID = 1, + SEMANTIC_KIND_INSTANCEID = 2, + SEMANTIC_KIND_POSITION = 3, + SEMANTIC_KIND_RTARRAYINDEX = 4, + SEMANTIC_KIND_VIEWPORTARRAYINDEX = 5, + SEMANTIC_KIND_CLIPDISTANCE = 6, + SEMANTIC_KIND_CULLDISTANCE = 7, + SEMANTIC_KIND_OUTPUTCONTROLPOINTID = 8, + SEMANTIC_KIND_DOMAINLOCATION = 9, + SEMANTIC_KIND_PRIMITIVEID = 10, + SEMANTIC_KIND_GSINSTANCEID = 11, + SEMANTIC_KIND_SAMPLEINDEX = 12, + SEMANTIC_KIND_ISFRONTFACE = 13, + SEMANTIC_KIND_COVERAGE = 14, + SEMANTIC_KIND_INNERCOVERAGE = 15, + SEMANTIC_KIND_TARGET = 16, + SEMANTIC_KIND_DEPTH = 17, + SEMANTIC_KIND_DEPTHLESSEQUAL = 18, + SEMANTIC_KIND_DEPTHGREATEREQUAL = 19, + SEMANTIC_KIND_STENCILREF = 20, + SEMANTIC_KIND_DISPATCHTHREADID = 21, + SEMANTIC_KIND_GROUPID = 22, + SEMANTIC_KIND_GROUPINDEX = 23, + SEMANTIC_KIND_GROUPTHREADID = 24, + SEMANTIC_KIND_TESSFACTOR = 25, + SEMANTIC_KIND_INSIDETESSFACTOR = 26, + SEMANTIC_KIND_VIEWID = 27, + SEMANTIC_KIND_BARYCENTRICS = 28, + SEMANTIC_KIND_SHADINGRATE = 29, + SEMANTIC_KIND_CULLPRIMITIVE = 30, + SEMANTIC_KIND_COUNT = 31, + SEMANTIC_KIND_INVALID = SEMANTIC_KIND_COUNT, +}; + enum dx_intrinsic_opcode { DX_LOAD_INPUT = 4, @@ -2357,8 +2417,7 @@ static void sm6_parser_emit_signature(struct sm6_parser *sm6, const struct shade param = &ins->declaration.dst; }
- /* TODO: set the interpolation mode when signatures are loaded from DXIL metadata. */ - ins->flags = (handler_idx == VKD3DSIH_DCL_INPUT_PS) ? VKD3DSIM_LINEAR_NOPERSPECTIVE : 0; + ins->flags = e->interpolation_mode; *param = params[i]; } } @@ -2717,6 +2776,25 @@ static bool sm6_metadata_value_is_string(const struct sm6_metadata_value *m) return m && m->type == VKD3D_METADATA_STRING; }
+static bool sm6_metadata_get_uint_value(const struct sm6_parser *sm6, + const struct sm6_metadata_value *m, unsigned int *u) +{ + const struct sm6_value *value; + + if (!m || m->type != VKD3D_METADATA_VALUE) + return false; + + value = m->u.value; + if (!sm6_value_is_constant(value)) + return false; + if (!sm6_type_is_integer(value->type)) + return false; + + *u = register_get_uint_value(&value->u.reg); + + return true; +} + static enum vkd3d_result sm6_parser_function_init(struct sm6_parser *sm6, const struct dxil_block *block, struct sm6_function *function) { @@ -3142,6 +3220,67 @@ static enum vkd3d_result sm6_parser_metadata_init(struct sm6_parser *sm6, const return VKD3D_OK; }
+static enum vkd3d_shader_component_type vkd3d_component_type_from_dxil_component_type(enum dxil_component_type type) +{ + switch (type) + { + case COMPONENT_TYPE_I1: + return VKD3D_SHADER_COMPONENT_BOOL; + case COMPONENT_TYPE_I16: + case COMPONENT_TYPE_I32: + return VKD3D_SHADER_COMPONENT_INT; + case COMPONENT_TYPE_U16: + case COMPONENT_TYPE_U32: + return VKD3D_SHADER_COMPONENT_UINT; + case COMPONENT_TYPE_F16: + case COMPONENT_TYPE_F32: + case COMPONENT_TYPE_SNORMF32: + case COMPONENT_TYPE_UNORMF32: + return VKD3D_SHADER_COMPONENT_FLOAT; + case COMPONENT_TYPE_F64: + case COMPONENT_TYPE_SNORMF64: + case COMPONENT_TYPE_UNORMF64: + return VKD3D_SHADER_COMPONENT_DOUBLE; + default: + FIXME("Unhandled component type %u.\n", type); + return VKD3D_SHADER_COMPONENT_UINT; + } +} + +static enum vkd3d_shader_minimum_precision minimum_precision_from_dxil_component_type(enum dxil_component_type type) +{ + switch (type) + { + case COMPONENT_TYPE_F16: + return VKD3D_SHADER_MINIMUM_PRECISION_FLOAT_16; + case COMPONENT_TYPE_I16: + return VKD3D_SHADER_MINIMUM_PRECISION_INT_16; + case COMPONENT_TYPE_U16: + return VKD3D_SHADER_MINIMUM_PRECISION_UINT_16; + default: + return VKD3D_SHADER_MINIMUM_PRECISION_NONE; + } +} + +static const enum vkd3d_shader_sysval_semantic sysval_semantic_table[] = +{ + [SEMANTIC_KIND_ARBITRARY] = VKD3D_SHADER_SV_NONE, + [SEMANTIC_KIND_POSITION] = VKD3D_SHADER_SV_POSITION, + [SEMANTIC_KIND_TARGET] = VKD3D_SHADER_SV_NONE, +}; + +static enum vkd3d_shader_sysval_semantic sysval_semantic_from_dxil_semantic_kind(enum dxil_semantic_kind kind) +{ + if (kind < ARRAY_SIZE(sysval_semantic_table)) + { + return sysval_semantic_table[kind]; + } + else + { + return VKD3D_SHADER_SV_NONE; + } +} + static const struct sm6_metadata_value *sm6_parser_find_named_metadata(struct sm6_parser *sm6, const char *name) { const struct sm6_metadata_node *node; @@ -3167,11 +3306,219 @@ static const struct sm6_metadata_value *sm6_parser_find_named_metadata(struct sm return NULL; }
+static enum vkd3d_result sm6_parser_read_signature(struct sm6_parser *sm6, const struct sm6_metadata_value *m, + struct shader_signature *s) +{ + unsigned int i, j, column_count, operand_count, index; + const struct sm6_metadata_node *node, *element_node; + struct signature_element *elements, *e; + unsigned int values[10]; + + if (!m) + return VKD3D_OK; + + if (!sm6_metadata_value_is_node(m)) + { + WARN("Signature element list is not a node.\n"); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_SIGNATURE, + "Signature element list is not a metadata node."); + return VKD3D_ERROR_INVALID_SHADER; + } + + node = m->u.node; + operand_count = node->operand_count; + + if (!(elements = vkd3d_calloc(operand_count, sizeof(*elements)))) + { + ERR("Failed to allocate %u signature elements.\n", operand_count); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_OUT_OF_MEMORY, + "Out of memory allocating %u signature elements.", operand_count); + return VKD3D_ERROR_OUT_OF_MEMORY; + } + + for (i = 0; i < operand_count; ++i) + { + m = node->operands[i]; + + if (!sm6_metadata_value_is_node(m)) + { + WARN("Signature element is not a node.\n"); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_SIGNATURE, + "Signature element is not a metadata node."); + return VKD3D_ERROR_INVALID_SHADER; + } + + element_node = m->u.node; + if (element_node->operand_count < 10) + { + WARN("Invalid operand count %u.\n", element_node->operand_count); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_SIGNATURE, + "Invalid signature element operand count %u.", element_node->operand_count); + return VKD3D_ERROR_INVALID_SHADER; + } + if (element_node->operand_count > 11) + { + WARN("Ignoring %u extra operands.\n", element_node->operand_count - 11); + vkd3d_shader_parser_warning(&sm6->p, VKD3D_SHADER_WARNING_DXIL_IGNORING_OPERANDS, + "Ignoring %u extra operands for a signature element.", element_node->operand_count - 11); + } + + for (j = 0; j < 10; ++j) + { + /* 1 is the semantic name, 4 is semantic index metadata. */ + if (j == 1 || j == 4) + continue; + if (!sm6_metadata_get_uint_value(sm6, element_node->operands[j], &values[j])) + { + WARN("Failed to load uint value at index %u.\n", j); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_SIGNATURE, + "Signature element value at index %u is not an integer.", j); + return VKD3D_ERROR_INVALID_SHADER; + } + } + + e = &elements[i]; + + if (values[0] != i) + { + FIXME("Unsupported element id %u not equal to its index %u.\n", values[0], i); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_SIGNATURE, + "A non-sequential and non-zero-based element id is not supported."); + return VKD3D_ERROR_INVALID_SHADER; + } + + if (!sm6_metadata_value_is_string(element_node->operands[1])) + { + WARN("Element name is not a string.\n"); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_SIGNATURE, + "Signature element name is not a metadata string."); + return VKD3D_ERROR_INVALID_SHADER; + } + e->semantic_name = element_node->operands[1]->u.string_value; + + /* TODO: load from additional tag/value pairs. */ + e->stream_index = 0; + + e->component_type = vkd3d_component_type_from_dxil_component_type(values[2]); + e->min_precision = minimum_precision_from_dxil_component_type(values[2]); + + j = values[3]; + e->sysval_semantic = sysval_semantic_from_dxil_semantic_kind(j); + if (j != SEMANTIC_KIND_ARBITRARY && j != SEMANTIC_KIND_TARGET && e->sysval_semantic == VKD3D_SHADER_SV_NONE) + { + WARN("Unhandled semantic kind %u.\n", j); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_SIGNATURE, + "DXIL semantic kind %u is unhandled.", j); + return VKD3D_ERROR_INVALID_SHADER; + } + + if ((e->interpolation_mode = values[5]) >= VKD3DSIM_COUNT) + { + WARN("Unhandled interpolation mode %u.\n", e->interpolation_mode); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_SIGNATURE, + "Interpolation mode %u is unhandled.", e->interpolation_mode); + return VKD3D_ERROR_INVALID_SHADER; + } + + e->register_count = values[6]; + column_count = values[7]; + e->register_index = values[8]; + e->target_location = e->register_index; + if (e->register_index > MAX_REG_OUTPUT || e->register_count > MAX_REG_OUTPUT - e->register_index) + { + WARN("Invalid row start %u with row count %u.\n", e->register_index, e->register_count); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_SIGNATURE, + "A signature element starting row of %u with count %u is invalid.", + e->register_index, e->register_count); + return VKD3D_ERROR_INVALID_SHADER; + } + index = values[9]; + if (index >= VKD3D_VEC4_SIZE || column_count > VKD3D_VEC4_SIZE - index) + { + WARN("Invalid column start %u with count %u.\n", index, column_count); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_SIGNATURE, + "A signature element starting column %u with count %u is invalid.", index, column_count); + return VKD3D_ERROR_INVALID_SHADER; + } + + e->mask = vkd3d_write_mask_from_component_count(column_count) << index; + /* TODO: load from additional tag/value pairs. */ + e->used_mask = e->mask; + + m = element_node->operands[4]; + if (!sm6_metadata_value_is_node(m)) + { + WARN("Semantic index list is not a node.\n"); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_SIGNATURE, + "Signature element semantic index list is not a metadata node."); + return VKD3D_ERROR_INVALID_SHADER; + } + + element_node = m->u.node; + for (j = 0; j < element_node->operand_count; ++j) + { + if (!sm6_metadata_get_uint_value(sm6, element_node->operands[j], &index)) + { + WARN("Failed to get semantic index for row %u.\n", j); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_SIGNATURE, + "Signature element semantic index for row %u is not an integer.", j); + } + else if (!j) + { + e->semantic_index = index; + } + else if (index != e->semantic_index + j) + { + WARN("Semantic index %u for row %u is not of an incrementing sequence.\n", index, j); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_SIGNATURE, + "Signature element semantic index %u for row %u is not of an incrementing sequence.", index, j); + } + } + } + + vkd3d_free(s->elements); + s->elements = elements; + s->element_count = operand_count; + + return VKD3D_OK; +} + +static enum vkd3d_result sm6_parser_signatures_init(struct sm6_parser *sm6, const struct sm6_metadata_value *m) +{ + enum vkd3d_result ret; + + if (!sm6_metadata_value_is_node(m)) + { + WARN("Signature table is not a node.\n"); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_SIGNATURE, + "Signature table is not a metadata node."); + return VKD3D_ERROR_INVALID_SHADER; + } + + if (m->u.node->operand_count && (ret = sm6_parser_read_signature(sm6, m->u.node->operands[0], + &sm6->p.shader_desc.input_signature)) < 0) + { + return ret; + } + if (m->u.node->operand_count > 1 && (ret = sm6_parser_read_signature(sm6, m->u.node->operands[1], + &sm6->p.shader_desc.output_signature)) < 0) + { + return ret; + } + /* TODO: patch constant signature in operand 2. */ + + sm6_parser_init_input_signature(sm6, &sm6->p.shader_desc.input_signature); + sm6_parser_init_output_signature(sm6, &sm6->p.shader_desc.output_signature); + + return VKD3D_OK; +} + static enum vkd3d_result sm6_parser_entry_point_init(struct sm6_parser *sm6) { const struct sm6_metadata_value *m = sm6_parser_find_named_metadata(sm6, "dx.entryPoints"); const struct sm6_metadata_node *entry_node = m ? m->u.node : NULL; const struct sm6_value *value; + enum vkd3d_result ret;
if (!entry_node || entry_node->operand_count < 2 || !(m = entry_node->operands[0])) { @@ -3207,8 +3554,11 @@ static enum vkd3d_result sm6_parser_entry_point_init(struct sm6_parser *sm6) "Entry point function name %s does not match the name in metadata.", sm6->entry_point); }
- sm6_parser_init_input_signature(sm6, &sm6->p.shader_desc.input_signature); - sm6_parser_init_output_signature(sm6, &sm6->p.shader_desc.output_signature); + if (entry_node->operand_count >= 3 && (m = entry_node->operands[2]) + && (ret = sm6_parser_signatures_init(sm6, m)) < 0) + { + return ret; + }
return VKD3D_OK; } diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index a0140c674..b5171ba66 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -178,6 +178,7 @@ enum vkd3d_shader_error VKD3D_SHADER_ERROR_DXIL_UNHANDLED_INTRINSIC = 8013, VKD3D_SHADER_ERROR_DXIL_INVALID_METADATA = 8014, VKD3D_SHADER_ERROR_DXIL_INVALID_ENTRY_POINT = 8015, + VKD3D_SHADER_ERROR_DXIL_INVALID_SIGNATURE = 8016,
VKD3D_SHADER_WARNING_DXIL_UNKNOWN_MAGIC_NUMBER = 8300, VKD3D_SHADER_WARNING_DXIL_UNKNOWN_SHADER_TYPE = 8301, @@ -627,6 +628,8 @@ enum vkd3d_shader_interpolation_mode VKD3DSIM_LINEAR_NOPERSPECTIVE_CENTROID = 5, VKD3DSIM_LINEAR_SAMPLE = 6, VKD3DSIM_LINEAR_NOPERSPECTIVE_SAMPLE = 7, + + VKD3DSIM_COUNT = 8, };
enum vkd3d_shader_global_flags @@ -867,6 +870,7 @@ struct signature_element unsigned int mask; unsigned int used_mask; enum vkd3d_shader_minimum_precision min_precision; + enum vkd3d_shader_interpolation_mode interpolation_mode; /* Register index / location in the target shader. * If SIGNATURE_TARGET_LOCATION_UNUSED, this element should not be written. */ unsigned int target_location;
From: Conor McCarthy cmccarthy@codeweavers.com
--- libs/vkd3d-shader/dxil.c | 15 ++++++++++++--- tests/hlsl/entry-point-semantics.shader_test | 17 +++++++++++++---- 2 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/libs/vkd3d-shader/dxil.c b/libs/vkd3d-shader/dxil.c index 7e3a1257b..47b261949 100644 --- a/libs/vkd3d-shader/dxil.c +++ b/libs/vkd3d-shader/dxil.c @@ -2384,7 +2384,7 @@ static void sm6_parser_init_signature(struct sm6_parser *sm6, const struct shade { struct vkd3d_shader_dst_param *param; const struct signature_element *e; - unsigned int i; + unsigned int i, count;
for (i = 0; i < s->element_count; ++i) { @@ -2392,8 +2392,11 @@ static void sm6_parser_init_signature(struct sm6_parser *sm6, const struct shade
param = ¶ms[i]; dst_param_io_init(param, e, reg_type); - param->reg.idx[0].offset = i; - param->reg.idx_count = 1; + count = 0; + if (e->register_count > 1) + param->reg.idx[count++].offset = 0; + param->reg.idx[count++].offset = i; + param->reg.idx_count = count; } }
@@ -2427,6 +2430,12 @@ static void sm6_parser_emit_signature(struct sm6_parser *sm6, const struct shade
ins->flags = e->interpolation_mode; *param = params[i]; + + if (e->register_count > 1) + { + param->reg.idx[0].rel_addr = NULL; + param->reg.idx[0].offset = e->register_count; + } } }
diff --git a/tests/hlsl/entry-point-semantics.shader_test b/tests/hlsl/entry-point-semantics.shader_test index 6d355ab5c..d177b0376 100644 --- a/tests/hlsl/entry-point-semantics.shader_test +++ b/tests/hlsl/entry-point-semantics.shader_test @@ -84,7 +84,7 @@ float4 main(in apple a) : sv_target
[test] draw quad -todo(sm>=6) probe (0, 0) rgba (10.0, 20.0, 30.0, 40.0) +probe (0, 0) rgba (10.0, 20.0, 30.0, 40.0)
% Arrays of matrices get successive indexes. @@ -101,7 +101,12 @@ float4 main(in apple a) : sv_target
[test] draw quad -todo(sm>=6) probe (0, 0) rgba (10.0, 11.0, 30.0, 31.0) +probe (0, 0) rgba (10.0, 11.0, 30.0, 31.0) + + +% dxcompiler emits correct array addressing. +[require] +shader model < 6.0
% Arrays (even multi-dimensional) of struct elements are allowed. The fields in the different struct @@ -145,6 +150,10 @@ draw quad todo(sm>=6) probe (0, 0) rgba (10.0, 11.0, 20.0, 21.0)
+[require] +% reset requirements + + [pixel shader fail] struct apple { @@ -201,7 +210,7 @@ float4 main(in float4 tex0 : TEXCOORD0, in float4 tex1 : TEXCOORD1) : sv_target
[test] draw quad -todo(sm>=6) probe (0, 0) rgba (1.0, 2.0, 10.0, 20.0) +probe (0, 0) rgba (1.0, 2.0, 10.0, 20.0)
% Output semantics cannot be mapped to more than one value. @@ -272,7 +281,7 @@ float4 main(in float4 a : TEXCOORD0, in float3 b : TEXCOORD1) : sv_target
[test] draw quad -todo(sm>=6) probe (0, 0) rgba (10.0, 11.0, 20.0, 21.0) +probe (0, 0) rgba (10.0, 11.0, 20.0, 21.0)
% In SM4, duplicated input semantics can only have different types if they have the same layout and
From: Conor McCarthy cmccarthy@codeweavers.com
--- libs/vkd3d-shader/dxil.c | 84 ++++++++++++++++++++++-- libs/vkd3d-shader/vkd3d_shader_private.h | 1 + 2 files changed, 81 insertions(+), 4 deletions(-)
diff --git a/libs/vkd3d-shader/dxil.c b/libs/vkd3d-shader/dxil.c index 48fbcaf13..7e3a1257b 100644 --- a/libs/vkd3d-shader/dxil.c +++ b/libs/vkd3d-shader/dxil.c @@ -214,6 +214,14 @@ enum dxil_semantic_kind SEMANTIC_KIND_INVALID = SEMANTIC_KIND_COUNT, };
+enum dxil_element_additional_tag +{ + ADDITIONAL_TAG_STREAM_INDEX = 0, + ADDITIONAL_TAG_GLOBAL_SYMBOL = 1, /* not used */ + ADDITIONAL_TAG_RELADDR_MASK = 2, + ADDITIONAL_TAG_USED_MASK = 3, +}; + enum dx_intrinsic_opcode { DX_LOAD_INPUT = 4, @@ -3306,6 +3314,76 @@ static const struct sm6_metadata_value *sm6_parser_find_named_metadata(struct sm return NULL; }
+static void signature_element_read_additional_element_values(struct signature_element *e, + const struct sm6_metadata_node *node, struct sm6_parser *sm6) +{ + unsigned int i, operand_count, value; + enum dxil_element_additional_tag tag; + + if (node->operand_count < 11 || !node->operands[10]) + return; + + if (!sm6_metadata_value_is_node(node->operands[10])) + { + WARN("Additional values list is not a node.\n"); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_SIGNATURE, + "Signature element additional values list is not a metadata node."); + return; + } + + node = node->operands[10]->u.node; + if (node->operand_count & 1) + { + WARN("Operand count is not even.\n"); + vkd3d_shader_parser_warning(&sm6->p, VKD3D_SHADER_WARNING_DXIL_IGNORING_OPERANDS, + "Operand count for signature element additional tag/value pairs is not even."); + } + operand_count = node->operand_count & ~1u; + + for (i = 0; i < operand_count; i += 2) + { + if (!sm6_metadata_get_uint_value(sm6, node->operands[i], &tag) + || !sm6_metadata_get_uint_value(sm6, node->operands[i + 1], &value)) + { + WARN("Failed to extract tag/value pair.\n"); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_SIGNATURE, + "Signature element tag/value pair at index %u is not an integer pair.", i); + continue; + } + + switch (tag) + { + case ADDITIONAL_TAG_STREAM_INDEX: + e->stream_index = value; + break; + case ADDITIONAL_TAG_RELADDR_MASK: + /* A mask of components accessed via relative addressing. Seems to replace TPF 'dcl_index_range'. */ + if (value > VKD3DSP_WRITEMASK_ALL) + { + WARN("Invalid relative addressed mask %#x.\n", value); + vkd3d_shader_parser_warning(&sm6->p, VKD3D_SHADER_WARNING_DXIL_INVALID_MASK, + "Mask %#x of relative-addressed components is invalid.", value); + } + break; + case ADDITIONAL_TAG_USED_MASK: + if (value > VKD3DSP_WRITEMASK_ALL) + { + WARN("Invalid used mask %#x.\n", value); + vkd3d_shader_parser_warning(&sm6->p, VKD3D_SHADER_WARNING_DXIL_INVALID_MASK, + "Mask %#x of used components is invalid.", value); + value &= VKD3DSP_WRITEMASK_ALL; + } + e->used_mask = value; + break; + default: + FIXME("Unhandled tag %u, value %u.\n", tag, value); + vkd3d_shader_parser_warning(&sm6->p, VKD3D_SHADER_WARNING_DXIL_IGNORING_OPERANDS, + "Tag %#x for signature element additional value %#x is unhandled.", tag, value); + break; + } + } +} + static enum vkd3d_result sm6_parser_read_signature(struct sm6_parser *sm6, const struct sm6_metadata_value *m, struct shader_signature *s) { @@ -3396,9 +3474,6 @@ static enum vkd3d_result sm6_parser_read_signature(struct sm6_parser *sm6, const } e->semantic_name = element_node->operands[1]->u.string_value;
- /* TODO: load from additional tag/value pairs. */ - e->stream_index = 0; - e->component_type = vkd3d_component_type_from_dxil_component_type(values[2]); e->min_precision = minimum_precision_from_dxil_component_type(values[2]);
@@ -3442,9 +3517,10 @@ static enum vkd3d_result sm6_parser_read_signature(struct sm6_parser *sm6, const }
e->mask = vkd3d_write_mask_from_component_count(column_count) << index; - /* TODO: load from additional tag/value pairs. */ e->used_mask = e->mask;
+ signature_element_read_additional_element_values(e, element_node, sm6); + m = element_node->operands[4]; if (!sm6_metadata_value_is_node(m)) { diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index b5171ba66..2c84cb104 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -187,6 +187,7 @@ enum vkd3d_shader_error VKD3D_SHADER_WARNING_DXIL_IGNORING_OPERANDS = 8304, VKD3D_SHADER_WARNING_DXIL_TYPE_MISMATCH = 8305, VKD3D_SHADER_WARNING_DXIL_ENTRY_POINT_MISMATCH = 8306, + VKD3D_SHADER_WARNING_DXIL_INVALID_MASK = 8307,
VKD3D_SHADER_ERROR_VSIR_NOT_IMPLEMENTED = 9000, VKD3D_SHADER_ERROR_VSIR_INVALID_HANDLER = 9001,
From: Conor McCarthy cmccarthy@codeweavers.com
--- libs/vkd3d-shader/d3d_asm.c | 9 ++++---- libs/vkd3d-shader/spirv.c | 6 +++--- libs/vkd3d-shader/tpf.c | 2 +- libs/vkd3d-shader/vkd3d_shader_private.h | 27 ++++++++++++++++++++++++ 4 files changed, 36 insertions(+), 8 deletions(-)
diff --git a/libs/vkd3d-shader/d3d_asm.c b/libs/vkd3d-shader/d3d_asm.c index 566680be7..5a75cf25e 100644 --- a/libs/vkd3d-shader/d3d_asm.c +++ b/libs/vkd3d-shader/d3d_asm.c @@ -391,13 +391,14 @@ static unsigned int shader_get_float_offset(enum vkd3d_shader_register_type regi } }
-static void shader_dump_global_flags(struct vkd3d_d3d_asm_compiler *compiler, uint32_t global_flags) +static void shader_dump_global_flags(struct vkd3d_d3d_asm_compiler *compiler, + enum vkd3d_shader_global_flags global_flags) { unsigned int i;
static const struct { - unsigned int flag; + enum vkd3d_shader_global_flags flag; const char *name; } global_flag_info[] = @@ -423,7 +424,7 @@ static void shader_dump_global_flags(struct vkd3d_d3d_asm_compiler *compiler, ui }
if (global_flags) - vkd3d_string_buffer_printf(&compiler->buffer, "unknown_flags(%#x)", global_flags); + vkd3d_string_buffer_printf(&compiler->buffer, "unknown_flags(%#"PRIx64")", global_flags); }
static void shader_dump_sync_flags(struct vkd3d_d3d_asm_compiler *compiler, uint32_t sync_flags) @@ -1637,7 +1638,7 @@ static void shader_dump_instruction(struct vkd3d_d3d_asm_compiler *compiler,
case VKD3DSIH_DCL_GLOBAL_FLAGS: vkd3d_string_buffer_printf(buffer, " "); - shader_dump_global_flags(compiler, ins->flags); + shader_dump_global_flags(compiler, ins->declaration.global_flags); break;
case VKD3DSIH_DCL_HS_MAX_TESSFACTOR: diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 55bc4ad42..c6731040b 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -5377,7 +5377,7 @@ static size_t spirv_compiler_get_current_function_location(struct spirv_compiler static void spirv_compiler_emit_dcl_global_flags(struct spirv_compiler *compiler, const struct vkd3d_shader_instruction *instruction) { - unsigned int flags = instruction->flags; + enum vkd3d_shader_global_flags flags = instruction->declaration.global_flags;
if (flags & VKD3DSGF_FORCE_EARLY_DEPTH_STENCIL) { @@ -5392,9 +5392,9 @@ static void spirv_compiler_emit_dcl_global_flags(struct spirv_compiler *compiler }
if (flags & ~(VKD3DSGF_REFACTORING_ALLOWED | VKD3DSGF_ENABLE_RAW_AND_STRUCTURED_BUFFERS)) - FIXME("Unhandled global flags %#x.\n", flags); + FIXME("Unhandled global flags %#"PRIx64".\n", flags); else - WARN("Unhandled global flags %#x.\n", flags); + WARN("Unhandled global flags %#"PRIx64".\n", flags); }
static void spirv_compiler_emit_temps(struct spirv_compiler *compiler, uint32_t count) diff --git a/libs/vkd3d-shader/tpf.c b/libs/vkd3d-shader/tpf.c index 596a0c499..b93c1233b 100644 --- a/libs/vkd3d-shader/tpf.c +++ b/libs/vkd3d-shader/tpf.c @@ -1092,7 +1092,7 @@ static void shader_sm4_read_dcl_indexable_temp(struct vkd3d_shader_instruction * static void shader_sm4_read_dcl_global_flags(struct vkd3d_shader_instruction *ins, uint32_t opcode, uint32_t opcode_token, const uint32_t *tokens, unsigned int token_count, struct vkd3d_shader_sm4_parser *priv) { - ins->flags = (opcode_token & VKD3D_SM4_GLOBAL_FLAGS_MASK) >> VKD3D_SM4_GLOBAL_FLAGS_SHIFT; + ins->declaration.global_flags = (opcode_token & VKD3D_SM4_GLOBAL_FLAGS_MASK) >> VKD3D_SM4_GLOBAL_FLAGS_SHIFT; }
static void shader_sm5_read_fcall(struct vkd3d_shader_instruction *ins, uint32_t opcode, uint32_t opcode_token, diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 2c84cb104..ab148b3be 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -642,6 +642,32 @@ enum vkd3d_shader_global_flags VKD3DSGF_SKIP_OPTIMIZATION = 0x10, VKD3DSGF_ENABLE_MINIMUM_PRECISION = 0x20, VKD3DSGF_ENABLE_11_1_DOUBLE_EXTENSIONS = 0x40, + VKD3DSGF_ENABLE_SHADER_EXTENSIONS = 0x80, /* never emitted? */ + VKD3DSGF_BIND_FOR_DURATION = 0x100, + VKD3DSGF_ENABLE_VP_AND_RT_ARRAY_INDEX = 0x200, + VKD3DSGF_ENABLE_INNER_COVERAGE = 0x400, + VKD3DSGF_ENABLE_STENCIL_REF = 0x800, + VKD3DSGF_ENABLE_TILED_RESOURCE_INTRINSICS = 0x1000, + VKD3DSGF_ENABLE_RELAXED_TYPED_UAV_FORMATS = 0x2000, + VKD3DSGF_ENABLE_LVL_9_COMPARISON_FILTERING = 0x4000, + VKD3DSGF_ENABLE_UP_TO_64_UAVS = 0x8000, + VKD3DSGF_ENABLE_UAVS_AT_EVERY_STAGE = 0x10000, + VKD3DSGF_ENABLE_CS4_RAW_STRUCTURED_BUFFERS = 0x20000, + VKD3DSGF_ENABLE_RASTERIZER_ORDERED_VIEWS = 0x40000, + VKD3DSGF_ENABLE_WAVE_INTRINSICS = 0x80000, + VKD3DSGF_ENABLE_INT64 = 0x100000, + VKD3DSGF_ENABLE_VIEWID = 0x200000, + VKD3DSGF_ENABLE_BARYCENTRICS = 0x400000, + VKD3DSGF_FORCE_NATIVE_LOW_PRECISION = 0x800000, + VKD3DSGF_ENABLE_SHADINGRATE = 0x1000000, + VKD3DSGF_ENABLE_RAYTRACING_TIER_1_1 = 0x2000000, + VKD3DSGF_ENABLE_SAMPLER_FEEDBACK = 0x4000000, + VKD3DSGF_ENABLE_ATOMIC_INT64_ON_TYPED_RESOURCE = 0x8000000, + VKD3DSGF_ENABLE_ATOMIC_INT64_ON_GROUP_SHARED = 0x10000000, + VKD3DSGF_ENABLE_DERIVATIVES_IN_MESH_AND_AMPLIFICATION_SHADERS = 0x20000000, + VKD3DSGF_ENABLE_RESOURCE_DESCRIPTOR_HEAP_INDEXING = 0x40000000, + VKD3DSGF_ENABLE_SAMPLER_DESCRIPTOR_HEAP_INDEXING = 0x80000000, + VKD3DSGF_ENABLE_ATOMIC_INT64_ON_DESCRIPTOR_HEAP_RESOURCE = 0x100000000ull, };
enum vkd3d_shader_sync_flags @@ -1016,6 +1042,7 @@ struct vkd3d_shader_instruction const struct vkd3d_shader_src_param *predicate; union { + enum vkd3d_shader_global_flags global_flags; struct vkd3d_shader_semantic semantic; struct vkd3d_shader_register_semantic register_semantic; struct vkd3d_shader_primitive_type primitive_type;
From: Conor McCarthy cmccarthy@codeweavers.com
--- libs/vkd3d-shader/dxil.c | 118 ++++++++++++++++++++++- libs/vkd3d-shader/vkd3d_shader_private.h | 5 +- 2 files changed, 121 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/dxil.c b/libs/vkd3d-shader/dxil.c index 47b261949..e24f01324 100644 --- a/libs/vkd3d-shader/dxil.c +++ b/libs/vkd3d-shader/dxil.c @@ -222,6 +222,23 @@ enum dxil_element_additional_tag ADDITIONAL_TAG_USED_MASK = 3, };
+enum dxil_shader_properties_tag +{ + SHADER_PROPERTIES_FLAGS = 0, + SHADER_PROPERTIES_GEOMETRY = 1, + SHADER_PROPERTIES_DOMAIN = 2, + SHADER_PROPERTIES_HULL = 3, + SHADER_PROPERTIES_COMPUTE = 4, + SHADER_PROPERTIES_AUTO_BINDING_SPACE = 5, + SHADER_PROPERTIES_RAY_PAYLOAD_SIZE = 6, + SHADER_PROPERTIES_RAY_ATTRIB_SIZE = 7, + SHADER_PROPERTIES_SHADER_KIND = 8, + SHADER_PROPERTIES_MESH = 9, + SHADER_PROPERTIES_AMPLIFICATION = 10, + SHADER_PROPERTIES_WAVE_SIZE = 11, + SHADER_PROPERTIES_ENTRY_ROOT_SIG = 12, +}; + enum dx_intrinsic_opcode { DX_LOAD_INPUT = 4, @@ -1657,6 +1674,17 @@ static unsigned int register_get_uint_value(const struct vkd3d_shader_register * return reg->u.immconst_uint[0]; }
+static uint64_t register_get_uint64_value(const struct vkd3d_shader_register *reg) +{ + if (!register_is_constant(reg) || !data_type_is_integer(reg->data_type)) + return UINT64_MAX; + + if (reg->dimension == VSIR_DIMENSION_VEC4) + WARN("Returning vec4.x.\n"); + + return (reg->type == VKD3DSPR_IMMCONST64) ? reg->u.immconst_uint64[0] : reg->u.immconst_uint[0]; +} + static inline bool sm6_value_is_function_dcl(const struct sm6_value *value) { return value->value_type == VALUE_TYPE_FUNCTION; @@ -1755,6 +1783,8 @@ static enum vkd3d_data_type vkd3d_data_type_from_sm6_type(const struct sm6_type return VKD3D_DATA_UINT8; case 32: return VKD3D_DATA_UINT; + case 64: + return VKD3D_DATA_UINT64; default: FIXME("Unhandled width %u.\n", type->u.width); return VKD3D_DATA_UINT; @@ -2812,6 +2842,25 @@ static bool sm6_metadata_get_uint_value(const struct sm6_parser *sm6, return true; }
+static bool sm6_metadata_get_uint64_value(const struct sm6_parser *sm6, + const struct sm6_metadata_value *m, uint64_t *u) +{ + const struct sm6_value *value; + + if (!m || m->type != VKD3D_METADATA_VALUE) + return false; + + value = m->u.value; + if (!sm6_value_is_constant(value)) + return false; + if (!sm6_type_is_integer(value->type)) + return false; + + *u = register_get_uint64_value(&value->u.reg); + + return true; +} + static enum vkd3d_result sm6_parser_function_init(struct sm6_parser *sm6, const struct dxil_block *block, struct sm6_function *function) { @@ -3598,10 +3647,34 @@ static enum vkd3d_result sm6_parser_signatures_init(struct sm6_parser *sm6, cons return VKD3D_OK; }
+static void sm6_parser_emit_global_flags(struct sm6_parser *sm6, const struct sm6_metadata_value *m) +{ + enum vkd3d_shader_global_flags global_flags, mask, rotated_flags; + struct vkd3d_shader_instruction *ins; + + if (!sm6_metadata_get_uint64_value(sm6, m, &global_flags)) + { + WARN("Failed to load global flags.\n"); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_PROPERTIES, + "Global flags metadata value is not an integer."); + return; + } + /* Rotate SKIP_OPTIMIZATION from bit 0 to bit 4 to match vkd3d_shader_global_flags.. */ + mask = (VKD3DSGF_SKIP_OPTIMIZATION << 1) - 1; + rotated_flags = global_flags & mask; + rotated_flags = (rotated_flags >> 1) | ((rotated_flags & 1) << 4); + global_flags = (global_flags & ~mask) | rotated_flags; + + ins = sm6_parser_add_instruction(sm6, VKD3DSIH_DCL_GLOBAL_FLAGS); + ins->declaration.global_flags = global_flags; +} + static enum vkd3d_result sm6_parser_entry_point_init(struct sm6_parser *sm6) { const struct sm6_metadata_value *m = sm6_parser_find_named_metadata(sm6, "dx.entryPoints"); - const struct sm6_metadata_node *entry_node = m ? m->u.node : NULL; + const struct sm6_metadata_node *node, *entry_node = m ? m->u.node : NULL; + enum dxil_shader_properties_tag tag; + unsigned int i, operand_count; const struct sm6_value *value; enum vkd3d_result ret;
@@ -3645,6 +3718,49 @@ static enum vkd3d_result sm6_parser_entry_point_init(struct sm6_parser *sm6) return ret; }
+ if (entry_node->operand_count >= 5 && (m = entry_node->operands[4])) + { + if (!sm6_metadata_value_is_node(m)) + { + WARN("Shader properties list is not a node.\n"); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_PROPERTIES, + "Shader properties tag/value list is not a metadata node."); + return VKD3D_ERROR_INVALID_SHADER; + } + + node = m->u.node; + if (node->operand_count & 1) + { + WARN("Operand count is not even.\n"); + vkd3d_shader_parser_warning(&sm6->p, VKD3D_SHADER_WARNING_DXIL_IGNORING_OPERANDS, + "Operand count for shader properties tag/value pairs is not even."); + } + operand_count = node->operand_count & ~1u; + + for (i = 0; i < operand_count; i += 2) + { + if (!sm6_metadata_get_uint_value(sm6, node->operands[i], &tag)) + { + WARN("Tag is not an integer value.\n"); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_PROPERTIES, + "Shader properties tag at index %u is not an integer.", i); + return VKD3D_ERROR_INVALID_SHADER; + } + + switch (tag) + { + case SHADER_PROPERTIES_FLAGS: + sm6_parser_emit_global_flags(sm6, node->operands[i + 1]); + break; + default: + FIXME("Unhandled tag %#x.\n", tag); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_PROPERTIES, + "Shader properties tag %#x is unhandled.", tag); + break; + } + } + } + return VKD3D_OK; }
diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index ab148b3be..85041f2a5 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -179,6 +179,7 @@ enum vkd3d_shader_error VKD3D_SHADER_ERROR_DXIL_INVALID_METADATA = 8014, VKD3D_SHADER_ERROR_DXIL_INVALID_ENTRY_POINT = 8015, VKD3D_SHADER_ERROR_DXIL_INVALID_SIGNATURE = 8016, + VKD3D_SHADER_ERROR_DXIL_INVALID_PROPERTIES = 8017,
VKD3D_SHADER_WARNING_DXIL_UNKNOWN_MAGIC_NUMBER = 8300, VKD3D_SHADER_WARNING_DXIL_UNKNOWN_SHADER_TYPE = 8301, @@ -571,11 +572,13 @@ enum vkd3d_data_type VKD3D_DATA_CONTINUED, VKD3D_DATA_UNUSED, VKD3D_DATA_UINT8, + VKD3D_DATA_UINT64, };
static inline bool data_type_is_integer(enum vkd3d_data_type data_type) { - return data_type == VKD3D_DATA_INT || data_type == VKD3D_DATA_UINT8 || data_type == VKD3D_DATA_UINT; + return data_type == VKD3D_DATA_INT || data_type == VKD3D_DATA_UINT8 || data_type == VKD3D_DATA_UINT + || data_type == VKD3D_DATA_UINT64; }
enum vsir_dimension
From: Conor McCarthy cmccarthy@codeweavers.com
--- libs/vkd3d-shader/spirv.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index c6731040b..e1d2f45c0 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -3522,6 +3522,11 @@ static bool vkd3d_swizzle_is_equal(unsigned int dst_write_mask, return vkd3d_compact_swizzle(VKD3D_SHADER_NO_SWIZZLE, dst_write_mask) == vkd3d_compact_swizzle(swizzle, write_mask); }
+static bool vkd3d_swizzle_is_scalar(unsigned int swizzle) +{ + return swizzle == (swizzle | (swizzle << VKD3D_SHADER_SWIZZLE_SHIFT(1))); +} + static uint32_t spirv_compiler_emit_swizzle(struct spirv_compiler *compiler, uint32_t val_id, unsigned int val_write_mask, enum vkd3d_shader_component_type component_type, unsigned int swizzle, unsigned int write_mask) @@ -3724,6 +3729,26 @@ static void spirv_compiler_set_ssa_register_id(const struct spirv_compiler *comp compiler->ssa_register_ids[i] = val_id; }
+static uint32_t spirv_compiler_emit_load_ssa_reg(struct spirv_compiler *compiler, + const struct vkd3d_shader_register *reg, enum vkd3d_shader_component_type component_type, + unsigned int swizzle) +{ + struct vkd3d_spirv_builder *builder = &compiler->spirv_builder; + unsigned int component_idx; + uint32_t type_id, val_id; + + val_id = spirv_compiler_get_ssa_register_id(compiler, reg); + assert(val_id); + + if (reg->dimension == VSIR_DIMENSION_SCALAR) + return val_id; + + type_id = vkd3d_spirv_get_type_id(builder, component_type, 1); + assert(vkd3d_swizzle_is_scalar(swizzle)); + component_idx = vkd3d_swizzle_get_component(swizzle, 0); + return vkd3d_spirv_build_op_composite_extract1(builder, type_id, val_id, component_idx); +} + static uint32_t spirv_compiler_emit_load_reg(struct spirv_compiler *compiler, const struct vkd3d_shader_register *reg, DWORD swizzle, DWORD write_mask) { @@ -3745,7 +3770,7 @@ static uint32_t spirv_compiler_emit_load_reg(struct spirv_compiler *compiler, component_type = vkd3d_component_type_from_data_type(reg->data_type);
if (reg->type == VKD3DSPR_SSA) - return spirv_compiler_get_ssa_register_id(compiler, reg); + return spirv_compiler_emit_load_ssa_reg(compiler, reg, component_type, swizzle);
if (!spirv_compiler_get_register_info(compiler, reg, ®_info)) {
From: Conor McCarthy cmccarthy@codeweavers.com
--- libs/vkd3d-shader/dxil.c | 65 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+)
diff --git a/libs/vkd3d-shader/dxil.c b/libs/vkd3d-shader/dxil.c index e24f01324..57e2885de 100644 --- a/libs/vkd3d-shader/dxil.c +++ b/libs/vkd3d-shader/dxil.c @@ -26,6 +26,8 @@ #define BITCODE_MAGIC VKD3D_MAKE_TAG('B', 'C', 0xc0, 0xde) #define DXIL_OP_MAX_OPERANDS 17
+static const unsigned int dx_max_thread_group_size[3] = {1024, 1024, 64}; + enum bitcode_block_id { BLOCKINFO_BLOCK = 0, @@ -3669,6 +3671,65 @@ static void sm6_parser_emit_global_flags(struct sm6_parser *sm6, const struct sm ins->declaration.global_flags = global_flags; }
+static enum vkd3d_result sm6_parser_emit_thread_group(struct sm6_parser *sm6, const struct sm6_metadata_value *m) +{ + const struct sm6_metadata_node *node; + struct vkd3d_shader_instruction *ins; + unsigned int group_sizes[3]; + unsigned int i; + + if (sm6->p.shader_version.type != VKD3D_SHADER_TYPE_COMPUTE) + { + WARN("Shader of type %#x has thread group dimensions.\n", sm6->p.shader_version.type); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_PROPERTIES, + "Shader has thread group dimensions but is not a compute shader."); + return VKD3D_ERROR_INVALID_SHADER; + } + + if (!m || !sm6_metadata_value_is_node(m)) + { + WARN("Thread group dimension value is not a node.\n"); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_PROPERTIES, + "Thread group dimension metadata value is not a node."); + return VKD3D_ERROR_INVALID_SHADER; + } + + node = m->u.node; + if (node->operand_count != 3) + { + WARN("Invalid operand count %u.\n", node->operand_count); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_OPERAND_COUNT, + "Thread group dimension operand count %u is invalid.", node->operand_count); + return VKD3D_ERROR_INVALID_SHADER; + } + + for (i = 0; i < 3; ++i) + { + if (!sm6_metadata_get_uint_value(sm6, node->operands[i], &group_sizes[i])) + { + WARN("Thread group dimension is not an integer value.\n"); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_PROPERTIES, + "Thread group dimension metadata value is not an integer."); + return VKD3D_ERROR_INVALID_SHADER; + } + if (!group_sizes[i] || group_sizes[i] > dx_max_thread_group_size[i]) + { + char dim = "XYZ"[i]; + WARN("Invalid thread group %c dimension %u.\n", dim, group_sizes[i]); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_PROPERTIES, + "Thread group %c dimension %u is invalid.", dim, group_sizes[i]); + return VKD3D_ERROR_INVALID_SHADER; + } + } + + ins = sm6_parser_add_instruction(sm6, VKD3DSIH_DCL_THREAD_GROUP); + ins->declaration.thread_group_size.x = group_sizes[0]; + ins->declaration.thread_group_size.y = group_sizes[1]; + ins->declaration.thread_group_size.z = group_sizes[2]; + + return VKD3D_OK; +} + static enum vkd3d_result sm6_parser_entry_point_init(struct sm6_parser *sm6) { const struct sm6_metadata_value *m = sm6_parser_find_named_metadata(sm6, "dx.entryPoints"); @@ -3752,6 +3813,10 @@ static enum vkd3d_result sm6_parser_entry_point_init(struct sm6_parser *sm6) case SHADER_PROPERTIES_FLAGS: sm6_parser_emit_global_flags(sm6, node->operands[i + 1]); break; + case SHADER_PROPERTIES_COMPUTE: + if ((ret = sm6_parser_emit_thread_group(sm6, node->operands[i + 1])) < 0) + return ret; + break; default: FIXME("Unhandled tag %#x.\n", tag); vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_PROPERTIES,
From: Conor McCarthy cmccarthy@codeweavers.com
DXIL constant buffer sizes can be 32-bit scalar aligned. --- libs/vkd3d-shader/spirv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index e1d2f45c0..5542bc6c0 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -5663,7 +5663,8 @@ static void spirv_compiler_emit_cbv_declaration(struct spirv_compiler *compiler, reg.idx[1].offset = range->first; reg.idx[2].offset = range->last;
- size = size_in_bytes / (VKD3D_VEC4_SIZE * sizeof(uint32_t)); + size = align(size_in_bytes, VKD3D_VEC4_SIZE * sizeof(uint32_t)); + size /= (VKD3D_VEC4_SIZE * sizeof(uint32_t));
if ((push_cb = spirv_compiler_find_push_constant_buffer(compiler, range))) {
From: Conor McCarthy cmccarthy@codeweavers.com
--- libs/vkd3d-shader/dxbc.c | 1 + libs/vkd3d-shader/dxil.c | 220 +++++++++++++++++++++++ libs/vkd3d-shader/vkd3d_shader_main.c | 18 ++ libs/vkd3d-shader/vkd3d_shader_private.h | 4 + 4 files changed, 243 insertions(+)
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index a9a7aefe8..6f47560fc 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -550,6 +550,7 @@ void free_shader_desc(struct vkd3d_shader_desc *desc) shader_signature_cleanup(&desc->input_signature); shader_signature_cleanup(&desc->output_signature); shader_signature_cleanup(&desc->patch_constant_signature); + vkd3d_free(desc->descriptors); }
int shader_extract_from_dxbc(const struct vkd3d_shader_code *dxbc, diff --git a/libs/vkd3d-shader/dxil.c b/libs/vkd3d-shader/dxil.c index 57e2885de..4a1e1e108 100644 --- a/libs/vkd3d-shader/dxil.c +++ b/libs/vkd3d-shader/dxil.c @@ -25,6 +25,7 @@
#define BITCODE_MAGIC VKD3D_MAKE_TAG('B', 'C', 0xc0, 0xde) #define DXIL_OP_MAX_OPERANDS 17 +static const unsigned int SHADER_DESCRIPTOR_TYPE_COUNT = 4;
static const unsigned int dx_max_thread_group_size[3] = {1024, 1024, 64};
@@ -156,6 +157,29 @@ enum bitcode_value_symtab_code VST_CODE_BBENTRY = 2, };
+enum dxil_resource_kind +{ + RESOURCE_KIND_INVALID = 0, + RESOURCE_KIND_TEXTURE1D = 1, + RESOURCE_KIND_TEXTURE2D = 2, + RESOURCE_KIND_TEXTURE2DMS = 3, + RESOURCE_KIND_TEXTURE3D = 4, + RESOURCE_KIND_TEXTURECUBE = 5, + RESOURCE_KIND_TEXTURE1DARRAY = 6, + RESOURCE_KIND_TEXTURE2DARRAY = 7, + RESOURCE_KIND_TEXTURE2DMSARRAY = 8, + RESOURCE_KIND_TEXTURECUBEARRAY = 9, + RESOURCE_KIND_TYPEDBUFFER = 10, + RESOURCE_KIND_RAWBUFFER = 11, + RESOURCE_KIND_STRUCTUREDBUFFER = 12, + RESOURCE_KIND_CBUFFER = 13, + RESOURCE_KIND_SAMPLER = 14, + RESOURCE_KIND_TBUFFER = 15, + RESOURCE_KIND_RTACCELERATIONSTRUCTURE = 16, + RESOURCE_KIND_FEEDBACKTEXTURE2D = 17, + RESOURCE_KIND_FEEDBACKTEXTURE2DARRAY = 18, +}; + enum dxil_component_type { COMPONENT_TYPE_INVALID = 0, @@ -2820,6 +2844,11 @@ static bool sm6_metadata_value_is_node(const struct sm6_metadata_value *m) return m && m->type == VKD3D_METADATA_NODE; }
+static bool sm6_metadata_value_is_value(const struct sm6_metadata_value *m) +{ + return m && m->type == VKD3D_METADATA_VALUE; +} + static bool sm6_metadata_value_is_string(const struct sm6_metadata_value *m) { return m && m->type == VKD3D_METADATA_STRING; @@ -3374,6 +3403,194 @@ static const struct sm6_metadata_value *sm6_parser_find_named_metadata(struct sm return NULL; }
+static bool sm6_parser_resources_load_register_range(struct sm6_parser *sm6, + const struct sm6_metadata_node *node, struct vkd3d_shader_register_range *range) +{ + unsigned int size; + + if (!sm6_metadata_value_is_value(node->operands[1])) + { + WARN("Resource data type is not a value.\n"); + return false; + } + if (!sm6_type_is_pointer(node->operands[1]->value_type)) + { + WARN("Resource type is not a pointer.\n"); + vkd3d_shader_parser_warning(&sm6->p, VKD3D_SHADER_WARNING_DXIL_TYPE_MISMATCH, + "Resource metadata value type is not a pointer."); + } + + if (!sm6_metadata_get_uint_value(sm6, node->operands[3], &range->space)) + { + WARN("Failed to load register space.\n"); + return false; + } + if (!sm6_metadata_get_uint_value(sm6, node->operands[4], &range->first)) + { + WARN("Failed to load register first.\n"); + return false; + } + if (!sm6_metadata_get_uint_value(sm6, node->operands[5], &size)) + { + WARN("Failed to load register range size.\n"); + return false; + } + if (!size || (size != UINT_MAX && !vkd3d_bound_range(range->first, size, UINT_MAX))) + { + WARN("Invalid register range, first %u, size %u.\n", range->first, size); + return false; + } + range->last = (size == UINT_MAX) ? UINT_MAX : range->first + size - 1; + + return true; +} + +static enum vkd3d_result sm6_parser_resources_load_cbv(struct sm6_parser *sm6, + const struct sm6_metadata_node *node, struct vkd3d_shader_descriptor_info1 *d) +{ + if (node->operand_count < 7) + { + WARN("Invalid operand count %u.\n", node->operand_count); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_OPERAND_COUNT, + "Invalid operand count %u for a CBV descriptor.", node->operand_count); + return VKD3D_ERROR_INVALID_SHADER; + } + if (node->operand_count > 7 && node->operands[7]) + { + WARN("Ignoring %u extra operands.\n", node->operand_count - 7); + vkd3d_shader_parser_warning(&sm6->p, VKD3D_SHADER_WARNING_DXIL_IGNORING_OPERANDS, + "Ignoring %u extra operands for a CBV descriptor.", node->operand_count - 7); + } + + d->resource_type = VKD3D_SHADER_RESOURCE_BUFFER; + d->resource_data_type = VKD3D_SHADER_RESOURCE_DATA_UINT; + + if (!sm6_metadata_get_uint_value(sm6, node->operands[6], &d->buffer_size)) + { + WARN("Failed to load buffer size.\n"); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_RESOURCES, + "Constant buffer size metadata value is not an integer."); + return VKD3D_ERROR_INVALID_SHADER; + } + + return VKD3D_OK; +} + +static enum vkd3d_result sm6_parser_descriptor_type_init(struct sm6_parser *sm6, + enum vkd3d_shader_descriptor_type type, const struct sm6_metadata_node *descriptor_node, + size_t *resource_capacity) +{ + struct vkd3d_shader_desc *desc = &sm6->p.shader_desc; + struct vkd3d_shader_register_range range; + struct vkd3d_shader_descriptor_info1 *d; + const struct sm6_metadata_node *node; + const struct sm6_metadata_value *m; + enum vkd3d_result ret; + unsigned int i; + + for (i = 0; i < descriptor_node->operand_count; ++i) + { + m = descriptor_node->operands[i]; + if (!sm6_metadata_value_is_node(m)) + { + WARN("Resource descriptor is not a node.\n"); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_RESOURCES, + "Resource descriptor is not a metadata node."); + return VKD3D_ERROR_INVALID_SHADER; + } + + if (!vkd3d_array_reserve((void **)&desc->descriptors, resource_capacity, + desc->descriptor_count + 1, sizeof(*desc->descriptors))) + { + ERR("Failed to allocate resource array.\n"); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_OUT_OF_MEMORY, + "Out of memory allocating the resource array."); + return VKD3D_ERROR_OUT_OF_MEMORY; + } + + d = &desc->descriptors[desc->descriptor_count]; + memset(d, 0, sizeof(*d)); + d->type = type; + + node = m->u.node; + + switch (type) + { + case VKD3D_SHADER_DESCRIPTOR_TYPE_CBV: + if ((ret = sm6_parser_resources_load_cbv(sm6, node, d)) < 0) + return ret; + break; + default: + FIXME("Unsupported descriptor type %u.\n", type); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_RESOURCES, + "Resource descriptor type %u is unsupported.", type); + return VKD3D_ERROR_INVALID_SHADER; + } + + if (!sm6_metadata_get_uint_value(sm6, node->operands[0], &d->register_id)) + { + WARN("Failed to load resource id.\n"); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_RESOURCES, + "Resource id metadata value is not an integer."); + return VKD3D_ERROR_INVALID_SHADER; + } + + if (!sm6_parser_resources_load_register_range(sm6, node, &range)) + { + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_RESOURCES, + "Resource register range is invalid."); + return VKD3D_ERROR_INVALID_SHADER; + } + d->register_space = range.space; + d->register_index = range.first; + d->count = (range.last == UINT_MAX) ? UINT_MAX : range.last - range.first + 1; + + ++desc->descriptor_count; + } + + return VKD3D_OK; +} + +static enum vkd3d_result sm6_parser_resources_init(struct sm6_parser *sm6) +{ + const struct sm6_metadata_value *m = sm6_parser_find_named_metadata(sm6, "dx.resources"); + enum vkd3d_shader_descriptor_type type; + const struct sm6_metadata_node *node; + size_t resource_capacity = 0; + enum vkd3d_result ret; + + if (!m) + return VKD3D_OK; + + node = m->u.node; + if (node->operand_count != SHADER_DESCRIPTOR_TYPE_COUNT) + { + WARN("Unexpected descriptor type count %u.\n", node->operand_count); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_RESOURCES, + "Descriptor type count %u is invalid.", node->operand_count); + return VKD3D_ERROR_INVALID_SHADER; + } + + for (type = 0; type < SHADER_DESCRIPTOR_TYPE_COUNT; ++type) + { + if (!(m = node->operands[type])) + continue; + + if (!sm6_metadata_value_is_node(m)) + { + WARN("Resource list is not a node.\n"); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_RESOURCES, + "Resource list is not a metadata node."); + return VKD3D_ERROR_INVALID_SHADER; + } + + if ((ret = sm6_parser_descriptor_type_init(sm6, type, m->u.node, &resource_capacity)) < 0) + return ret; + } + + return VKD3D_OK; +} + static void signature_element_read_additional_element_values(struct signature_element *e, const struct sm6_metadata_node *node, struct sm6_parser *sm6) { @@ -4176,6 +4393,9 @@ static enum vkd3d_result sm6_parser_init(struct sm6_parser *sm6, const uint32_t if ((ret = sm6_parser_entry_point_init(sm6)) < 0) return ret;
+ if ((ret = sm6_parser_resources_init(sm6)) < 0) + return ret; + if ((ret = sm6_parser_module_init(sm6, &sm6->root_block, 0)) < 0) { if (ret == VKD3D_ERROR_OUT_OF_MEMORY) diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c index 052edeb50..310932d9e 100644 --- a/libs/vkd3d-shader/vkd3d_shader_main.c +++ b/libs/vkd3d-shader/vkd3d_shader_main.c @@ -1150,6 +1150,22 @@ static enum vkd3d_result convert_descriptor_info(struct vkd3d_shader_scan_descri return VKD3D_OK; }
+static bool clone_descriptor_info1_safe(struct vkd3d_shader_scan_descriptor_info1 *scan_descriptor_info, + struct vkd3d_shader_descriptor_info1 *descriptors, unsigned int descriptor_count) +{ + if (!scan_descriptor_info || !descriptor_count) + return true; + + if (!(scan_descriptor_info->descriptors = vkd3d_calloc(descriptor_count, + sizeof(*scan_descriptor_info->descriptors)))) + return false; + memcpy(scan_descriptor_info->descriptors, descriptors, + descriptor_count * sizeof(*scan_descriptor_info->descriptors)); + scan_descriptor_info->descriptor_count = descriptor_count; + + return true; +} + static void vkd3d_shader_free_scan_descriptor_info1(struct vkd3d_shader_scan_descriptor_info1 *scan_descriptor_info) { TRACE("scan_descriptor_info %p.\n", scan_descriptor_info); @@ -1179,6 +1195,8 @@ static int scan_with_parser(const struct vkd3d_shader_compile_info *compile_info { descriptor_info1 = &local_descriptor_info1; } + clone_descriptor_info1_safe(descriptor_info1, parser->shader_desc.descriptors, parser->shader_desc.descriptor_count); + signature_info = vkd3d_find_struct(compile_info->next, SCAN_SIGNATURE_INFO);
vkd3d_shader_scan_context_init(&context, compile_info, descriptor_info1, message_context); diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 85041f2a5..1305e4aff 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -180,6 +180,7 @@ enum vkd3d_shader_error VKD3D_SHADER_ERROR_DXIL_INVALID_ENTRY_POINT = 8015, VKD3D_SHADER_ERROR_DXIL_INVALID_SIGNATURE = 8016, VKD3D_SHADER_ERROR_DXIL_INVALID_PROPERTIES = 8017, + VKD3D_SHADER_ERROR_DXIL_INVALID_RESOURCES = 8018,
VKD3D_SHADER_WARNING_DXIL_UNKNOWN_MAGIC_NUMBER = 8300, VKD3D_SHADER_WARNING_DXIL_UNKNOWN_SHADER_TYPE = 8301, @@ -931,6 +932,9 @@ struct vkd3d_shader_desc { uint32_t used, external; } flat_constant_count[3]; + + struct vkd3d_shader_descriptor_info1 *descriptors; + size_t descriptor_count; };
struct vkd3d_shader_register_semantic
From: Conor McCarthy cmccarthy@codeweavers.com
--- libs/vkd3d-shader/dxil.c | 99 +++++++++++++++++++++++- libs/vkd3d-shader/vkd3d_shader_private.h | 6 ++ 2 files changed, 101 insertions(+), 4 deletions(-)
diff --git a/libs/vkd3d-shader/dxil.c b/libs/vkd3d-shader/dxil.c index de76fbefd..2984c3ddd 100644 --- a/libs/vkd3d-shader/dxil.c +++ b/libs/vkd3d-shader/dxil.c @@ -270,6 +270,7 @@ enum dx_intrinsic_opcode DX_LOAD_INPUT = 4, DX_STORE_OUTPUT = 5, DX_CREATE_HANDLE = 57, + DX_CBUFFER_LOAD_LEGACY = 59, };
struct sm6_pointer_info @@ -1598,6 +1599,11 @@ static const struct sm6_type *sm6_type_get_scalar_type(const struct sm6_type *ty } }
+static unsigned int sm6_type_max_vector_size(const struct sm6_type *type) +{ + return min((VKD3D_VEC4_SIZE * sizeof(uint32_t) * CHAR_BIT) / type->u.width, VKD3D_VEC4_SIZE); +} + static const struct sm6_type *sm6_parser_get_type(struct sm6_parser *sm6, uint64_t type_id) { if (type_id >= sm6->type_count) @@ -1702,7 +1708,7 @@ static const char *sm6_parser_get_global_symbol_name(const struct sm6_parser *sm
static unsigned int register_get_uint_value(const struct vkd3d_shader_register *reg) { - if (!register_is_constant(reg) || !data_type_is_integer(reg->data_type)) + if (!register_is_constant(reg) || (!data_type_is_integer(reg->data_type) && !data_type_is_bool(reg->data_type))) return UINT_MAX;
if (reg->dimension == VSIR_DIMENSION_VEC4) @@ -1751,6 +1757,11 @@ static inline bool sm6_value_is_register(const struct sm6_value *value) return value->value_type == VALUE_TYPE_REG; }
+static bool sm6_value_is_handle(const struct sm6_value *value) +{ + return value->value_type == VALUE_TYPE_HANDLE; +} + static inline bool sm6_value_is_constant(const struct sm6_value *value) { return sm6_value_is_register(value) && register_is_constant(&value->u.reg); @@ -1854,8 +1865,8 @@ static enum vkd3d_data_type vkd3d_data_type_from_sm6_type(const struct sm6_type return VKD3D_DATA_UINT; }
-static void register_init_ssa_scalar(struct vkd3d_shader_register *reg, const struct sm6_type *type, - struct sm6_parser *sm6) +static void register_init_ssa_vector(struct vkd3d_shader_register *reg, const struct sm6_type *type, + unsigned int component_count, struct sm6_parser *sm6) { enum vkd3d_data_type data_type; unsigned int id; @@ -1863,6 +1874,13 @@ static void register_init_ssa_scalar(struct vkd3d_shader_register *reg, const st id = sm6_parser_alloc_ssa_id(sm6); data_type = vkd3d_data_type_from_sm6_type(sm6_type_get_scalar_type(type, 0)); register_init_with_id(reg, VKD3DSPR_SSA, data_type, id); + reg->dimension = component_count > 1 ? VSIR_DIMENSION_VEC4 : VSIR_DIMENSION_SCALAR; +} + +static void register_init_ssa_scalar(struct vkd3d_shader_register *reg, const struct sm6_type *type, + struct sm6_parser *sm6) +{ + register_init_ssa_vector(reg, type, 1, sm6); }
static void dst_param_init(struct vkd3d_shader_dst_param *param) @@ -1879,6 +1897,13 @@ static inline void dst_param_init_scalar(struct vkd3d_shader_dst_param *param, u param->shift = 0; }
+static void dst_param_init_vector(struct vkd3d_shader_dst_param *param, unsigned int component_count) +{ + param->write_mask = (1u << component_count) - 1; + param->modifiers = 0; + param->shift = 0; +} + static void dst_param_init_ssa_scalar(struct vkd3d_shader_dst_param *param, const struct sm6_type *type, struct sm6_parser *sm6) { @@ -1904,6 +1929,14 @@ static void src_param_init_from_value(struct vkd3d_shader_src_param *param, cons param->reg = src->u.reg; }
+static void src_param_init_vector_from_reg(struct vkd3d_shader_src_param *param, + const struct vkd3d_shader_register *reg) +{ + param->swizzle = VKD3D_SHADER_NO_SWIZZLE; + param->modifiers = VKD3DSPSM_NONE; + param->reg = *reg; +} + static void register_address_init(struct vkd3d_shader_register *reg, const struct sm6_value *address, unsigned int idx, struct sm6_parser *sm6) { @@ -1936,6 +1969,17 @@ static void instruction_dst_param_init_ssa_scalar(struct vkd3d_shader_instructio dst->u.reg = param->reg; }
+static void instruction_dst_param_init_ssa_vector(struct sm6_parser *sm6, struct vkd3d_shader_instruction *ins, + unsigned int component_count) +{ + struct vkd3d_shader_dst_param *param = instruction_dst_params_alloc(ins, 1, sm6); + struct sm6_value *dst = sm6_parser_get_current_value(sm6); + + dst_param_init_vector(param, component_count); + register_init_ssa_vector(¶m->reg, sm6_type_get_scalar_type(dst->type, 0), component_count, sm6); + dst->u.reg = param->reg; +} + /* Recurse through the block tree while maintaining a current value count. The current * count is the sum of the global count plus all declarations within the current function. * Store into value_capacity the highest count seen. */ @@ -2000,6 +2044,18 @@ static size_t sm6_parser_get_value_index(struct sm6_parser *sm6, uint64_t idx) return i; }
+static bool sm6_value_validate_is_handle(const struct sm6_value *value, struct sm6_parser *sm6) +{ + if (!sm6_value_is_handle(value)) + { + WARN("Handle parameter of type %u is not a handle.\n", value->value_type); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_RESOURCE_HANDLE, + "A handle parameter passed to a DX intrinsic function is not a handle."); + return false; + } + return true; +} + static const struct sm6_value *sm6_parser_get_value_safe(struct sm6_parser *sm6, unsigned int idx) { if (idx < sm6->value_count) @@ -2578,6 +2634,39 @@ static const struct vkd3d_shader_descriptor_info1 *parser_get_descriptor(struct return NULL; }
+static void sm6_parser_emit_dx_cbuffer_load(struct sm6_parser *sm6, struct sm6_block *code_block, + enum dx_intrinsic_opcode op, const struct sm6_value **operands, struct vkd3d_shader_instruction *ins) +{ + struct sm6_value *dst = sm6_parser_get_current_value(sm6); + unsigned int component_count = VKD3D_VEC4_SIZE; + struct vkd3d_shader_src_param *src_param; + const struct sm6_value *buffer; + const struct sm6_type *type; + + buffer = operands[0]; + if (!sm6_value_validate_is_handle(buffer, sm6)) + return; + + vsir_instruction_init(ins, &sm6->p.location, VKD3DSIH_MOV); + + src_param = instruction_src_params_alloc(ins, 1, sm6); + src_param_init_vector_from_reg(src_param, &buffer->u.handle.reg); + type = sm6_type_get_scalar_type(dst->type, 0); + if (!type) + { + WARN("Failed to get result type.\n"); + } + else + { + src_param->reg.data_type = vkd3d_data_type_from_sm6_type(type); + component_count = sm6_type_max_vector_size(type); + } + register_address_init(&src_param->reg, operands[1], 2, sm6); + src_param->reg.idx_count = 3; + + instruction_dst_param_init_ssa_vector(sm6, ins, component_count); +} + static void sm6_parser_emit_dx_create_handle(struct sm6_parser *sm6, struct sm6_block *code_block, enum dx_intrinsic_opcode op, const struct sm6_value **operands, struct vkd3d_shader_instruction *ins) { @@ -2723,6 +2812,7 @@ static const struct sm6_dx_opcode_info sm6_dx_op_table[] = { [DX_LOAD_INPUT ] = {'o', "ii8i", sm6_parser_emit_dx_load_input}, [DX_STORE_OUTPUT ] = {'v', "ii8o", sm6_parser_emit_dx_store_output}, + [DX_CBUFFER_LOAD_LEGACY ] = {'o', "Hi", sm6_parser_emit_dx_cbuffer_load}, [DX_CREATE_HANDLE ] = {'H', "8ii1", sm6_parser_emit_dx_create_handle}, };
@@ -2770,7 +2860,8 @@ static bool sm6_parser_validate_dx_op(struct sm6_parser *sm6, enum dx_intrinsic_ for (i = 0; i < operand_count; ++i) { const struct sm6_value *value = operands[i]; - if (!sm6_value_is_register(value) || !sm6_parser_validate_operand_type(sm6, value->type, info->operand_info[i])) + if ((!sm6_value_is_register(value) && !sm6_value_is_handle(value)) + || !sm6_parser_validate_operand_type(sm6, value->type, info->operand_info[i])) { WARN("Failed to validate operand %u for dx intrinsic id %u, '%s'.\n", i + 1, op, name); vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_OPERAND, diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 71731b632..b67c0190b 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -181,6 +181,7 @@ enum vkd3d_shader_error VKD3D_SHADER_ERROR_DXIL_INVALID_SIGNATURE = 8016, VKD3D_SHADER_ERROR_DXIL_INVALID_PROPERTIES = 8017, VKD3D_SHADER_ERROR_DXIL_INVALID_RESOURCES = 8018, + VKD3D_SHADER_ERROR_DXIL_INVALID_RESOURCE_HANDLE = 8019,
VKD3D_SHADER_WARNING_DXIL_UNKNOWN_MAGIC_NUMBER = 8300, VKD3D_SHADER_WARNING_DXIL_UNKNOWN_SHADER_TYPE = 8301, @@ -583,6 +584,11 @@ static inline bool data_type_is_integer(enum vkd3d_data_type data_type) || data_type == VKD3D_DATA_UINT64; }
+static inline bool data_type_is_bool(enum vkd3d_data_type data_type) +{ + return data_type == VKD3D_DATA_BOOL; +} + enum vsir_dimension { VSIR_DIMENSION_NONE,
From: Conor McCarthy cmccarthy@codeweavers.com
--- libs/vkd3d-shader/dxil.c | 83 ++++++++++++++++++++++++ libs/vkd3d-shader/vkd3d_shader_private.h | 1 + 2 files changed, 84 insertions(+)
diff --git a/libs/vkd3d-shader/dxil.c b/libs/vkd3d-shader/dxil.c index 4a1e1e108..de76fbefd 100644 --- a/libs/vkd3d-shader/dxil.c +++ b/libs/vkd3d-shader/dxil.c @@ -269,6 +269,7 @@ enum dx_intrinsic_opcode { DX_LOAD_INPUT = 4, DX_STORE_OUTPUT = 5, + DX_CREATE_HANDLE = 57, };
struct sm6_pointer_info @@ -328,6 +329,7 @@ enum sm6_value_type { VALUE_TYPE_FUNCTION, VALUE_TYPE_REG, + VALUE_TYPE_HANDLE, };
struct sm6_function_data @@ -337,6 +339,12 @@ struct sm6_function_data unsigned int attribs_id; };
+struct sm6_handle_data +{ + const struct vkd3d_shader_descriptor_info1 *d; + struct vkd3d_shader_register reg; +}; + struct sm6_value { const struct sm6_type *type; @@ -346,6 +354,7 @@ struct sm6_value { struct sm6_function_data function; struct vkd3d_shader_register reg; + struct sm6_handle_data handle; } u; };
@@ -465,6 +474,7 @@ struct sm6_parser struct sm6_type *types; size_t type_count; struct sm6_type *metadata_type; + struct sm6_type *handle_type;
struct sm6_symbol *global_symbols; size_t global_symbol_count; @@ -1414,6 +1424,9 @@ static enum vkd3d_result sm6_parser_type_table_init(struct sm6_parser *sm6) break; }
+ if (!ascii_strcasecmp(struct_name, "dx.types.Handle")) + sm6->handle_type = type; + type->u.struc->name = struct_name; struct_name = NULL; break; @@ -1461,6 +1474,11 @@ static inline bool sm6_type_is_integer(const struct sm6_type *type) return type->class == TYPE_CLASS_INTEGER; }
+static bool sm6_type_is_bool(const struct sm6_type *type) +{ + return type->class == TYPE_CLASS_INTEGER && type->u.width == 1; +} + static inline bool sm6_type_is_i8(const struct sm6_type *type) { return type->class == TYPE_CLASS_INTEGER && type->u.width == 8; @@ -1805,6 +1823,8 @@ static enum vkd3d_data_type vkd3d_data_type_from_sm6_type(const struct sm6_type { switch (type->u.width) { + case 1: + return VKD3D_DATA_BOOL; case 8: return VKD3D_DATA_UINT8; case 32: @@ -2542,6 +2562,62 @@ static struct sm6_block *sm6_block_create() return block; }
+static const struct vkd3d_shader_descriptor_info1 *parser_get_descriptor(struct vkd3d_shader_parser *parser, + enum vkd3d_shader_descriptor_type type, unsigned int id) +{ + const struct vkd3d_shader_descriptor_info1 *d; + size_t i; + + for (i = 0; i < parser->shader_desc.descriptor_count; ++i) + { + d = &parser->shader_desc.descriptors[i]; + if (d->type == type && d->register_id == id) + return d; + } + + return NULL; +} + +static void sm6_parser_emit_dx_create_handle(struct sm6_parser *sm6, struct sm6_block *code_block, + enum dx_intrinsic_opcode op, const struct sm6_value **operands, struct vkd3d_shader_instruction *ins) +{ + const struct vkd3d_shader_descriptor_info1 *d; + enum vkd3d_shader_descriptor_type type; + struct vkd3d_shader_register *reg; + struct sm6_value *dst; + unsigned int id; + + type = sm6_value_get_constant_uint(operands[0]); + id = sm6_value_get_constant_uint(operands[1]); + if (!(d = parser_get_descriptor(&sm6->p, type, id))) + { + WARN("Failed to find resource type %#x, id %#x.\n", type, id); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_OPERAND, + "Descriptor for resource type %#x, id %#x was not found.", type, id); + return; + } + + /* NOP is used to flag no instruction emitted. */ + ins->handler_idx = VKD3DSIH_NOP; + + dst = sm6_parser_get_current_value(sm6); + dst->value_type = VALUE_TYPE_HANDLE; + dst->u.handle.d = d; + + reg = &dst->u.handle.reg; + vsir_register_init(reg, VKD3DSPR_CONSTBUFFER, VKD3D_DATA_FLOAT, 2); + reg->idx[0].offset = id; + register_address_init(reg, operands[2], 1, sm6); + if (!sm6_value_is_constant(operands[3])) + { + WARN("Non-uniform attribute is not constant.\n"); + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_OPERAND, + "Resource handle non-uniform attribute is not a constant."); + return; + } + reg->non_uniform = !!sm6_value_get_constant_uint(operands[3]); +} + static void sm6_parser_emit_dx_load_input(struct sm6_parser *sm6, struct sm6_block *code_block, enum dx_intrinsic_opcode op, const struct sm6_value **operands, struct vkd3d_shader_instruction *ins) { @@ -2636,8 +2712,10 @@ struct sm6_dx_opcode_info };
/* + 1 -> int1 8 -> int8 i -> int32 + H -> handle v -> void o -> overloaded */ @@ -2645,6 +2723,7 @@ static const struct sm6_dx_opcode_info sm6_dx_op_table[] = { [DX_LOAD_INPUT ] = {'o', "ii8i", sm6_parser_emit_dx_load_input}, [DX_STORE_OUTPUT ] = {'v', "ii8o", sm6_parser_emit_dx_store_output}, + [DX_CREATE_HANDLE ] = {'H', "8ii1", sm6_parser_emit_dx_create_handle}, };
static bool sm6_parser_validate_operand_type(struct sm6_parser *sm6, const struct sm6_type *type, char info_type) @@ -2654,10 +2733,14 @@ static bool sm6_parser_validate_operand_type(struct sm6_parser *sm6, const struc case 0: FIXME("Invalid operand count.\n"); return false; + case '1': + return sm6_type_is_bool(type); case '8': return sm6_type_is_i8(type); case 'i': return sm6_type_is_i32(type); + case 'H': + return type == sm6->handle_type; case 'v': return !type; case 'o': diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 1305e4aff..71731b632 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -574,6 +574,7 @@ enum vkd3d_data_type VKD3D_DATA_UNUSED, VKD3D_DATA_UINT8, VKD3D_DATA_UINT64, + VKD3D_DATA_BOOL, };
static inline bool data_type_is_integer(enum vkd3d_data_type data_type)
From: Conor McCarthy cmccarthy@codeweavers.com
--- libs/vkd3d-shader/dxil.c | 89 +++++++++++++++++++++ tests/hlsl/asfloat.shader_test | 2 +- tests/hlsl/cbuffer.shader_test | 16 ++-- tests/hlsl/expr-indexing.shader_test | 4 +- tests/hlsl/majority-pragma.shader_test | 26 +++--- tests/hlsl/majority-syntax.shader_test | 2 +- tests/hlsl/matrix-indexing.shader_test | 8 +- tests/hlsl/nested-arrays.shader_test | 2 +- tests/hlsl/object-field-offsets.shader_test | 4 +- tests/hlsl/storage-qualifiers.shader_test | 2 +- tests/hlsl/struct-array.shader_test | 2 +- tests/hlsl/swizzle-matrix.shader_test | 14 ++-- tests/hlsl/swizzles.shader_test | 6 +- tests/hlsl/uniform-semantics.shader_test | 4 +- tests/hlsl/vector-indexing.shader_test | 2 +- 15 files changed, 136 insertions(+), 47 deletions(-)
diff --git a/libs/vkd3d-shader/dxil.c b/libs/vkd3d-shader/dxil.c index 2984c3ddd..86d485cb8 100644 --- a/libs/vkd3d-shader/dxil.c +++ b/libs/vkd3d-shader/dxil.c @@ -1495,6 +1495,11 @@ static inline bool sm6_type_is_floating_point(const struct sm6_type *type) return type->class == TYPE_CLASS_FLOAT; }
+static bool sm6_type_is_scalar(const struct sm6_type *type) +{ + return type->class == TYPE_CLASS_INTEGER || type->class == TYPE_CLASS_FLOAT || type->class == TYPE_CLASS_POINTER; +} + static inline bool sm6_type_is_numeric(const struct sm6_type *type) { return type->class == TYPE_CLASS_INTEGER || type->class == TYPE_CLASS_FLOAT; @@ -1505,6 +1510,11 @@ static inline bool sm6_type_is_pointer(const struct sm6_type *type) return type->class == TYPE_CLASS_POINTER; }
+static bool sm6_type_is_aggregate(const struct sm6_type *type) +{ + return type->class == TYPE_CLASS_STRUCT || type->class == TYPE_CLASS_VECTOR || type->class == TYPE_CLASS_ARRAY; +} + static bool sm6_type_is_numeric_aggregate(const struct sm6_type *type) { unsigned int i; @@ -1575,6 +1585,29 @@ static const struct sm6_type *sm6_type_get_pointer_to_type(const struct sm6_type return NULL; }
+static const struct sm6_type *sm6_type_get_element_type_at_index(const struct sm6_type *type, unsigned int elem_idx) +{ + switch (type->class) + { + case TYPE_CLASS_ARRAY: + case TYPE_CLASS_VECTOR: + if (elem_idx != UINT_MAX && elem_idx >= type->u.array.count) + return NULL; + return type->u.array.elem_type; + + case TYPE_CLASS_POINTER: + return type->u.pointer.type; + + case TYPE_CLASS_STRUCT: + if (elem_idx >= type->u.struc->elem_count) + return NULL; + return type->u.struc->elem_types[elem_idx]; + + default: + return NULL; + } +} + /* Never returns null for elem_idx 0. */ static const struct sm6_type *sm6_type_get_scalar_type(const struct sm6_type *type, unsigned int elem_idx) { @@ -3001,6 +3034,59 @@ static void sm6_parser_emit_call(struct sm6_parser *sm6, const struct dxil_recor fn_value->u.function.name, &operands[1], operand_count - 1, ins, dst); }
+static void sm6_parser_emit_extractval(struct sm6_parser *sm6, const struct dxil_record *record, + struct vkd3d_shader_instruction *ins, struct sm6_value *dst) +{ + struct vkd3d_shader_src_param *src_param; + unsigned int elem_idx, i = 0; + const struct sm6_type *type; + const struct sm6_value *src; + + if (!(src = sm6_parser_get_value_by_ref(sm6, record, NULL, &i))) + return; + + if (!dxil_record_validate_operand_min_count(record, i + 1, sm6)) + return; + + if (record->operand_count > i + 1) + { + FIXME("Unhandled multiple indices.\n"); + return; + } + if (record->operands[i] >= VKD3D_VEC4_SIZE) + { + FIXME("Unhandled element index %"PRIu64".\n", record->operands[i]); + return; + } + elem_idx = record->operands[i]; + + type = src->type; + if (!sm6_type_is_aggregate(type)) + { + FIXME("Invalid extraction from non-aggregate.\n"); + return; + } + if (!(type = sm6_type_get_element_type_at_index(type, elem_idx))) + { + FIXME("Invalid element index %u.\n", elem_idx); + return; + } + if (!sm6_type_is_scalar(type)) + { + FIXME("Value is not of scalar type.\n"); + return; + } + dst->type = type; + + ins->handler_idx = VKD3DSIH_MOV; + + src_param = instruction_src_params_alloc(ins, 1, sm6); + src_param_init_from_value(src_param, src); + src_param->swizzle = vkd3d_shader_create_swizzle(elem_idx, elem_idx, elem_idx, elem_idx); + + instruction_dst_param_init_ssa_scalar(ins, sm6); +} + static void sm6_parser_emit_ret(struct sm6_parser *sm6, const struct dxil_record *record, struct sm6_block *code_block, struct vkd3d_shader_instruction *ins) { @@ -3156,6 +3242,9 @@ static enum vkd3d_result sm6_parser_function_init(struct sm6_parser *sm6, const case FUNC_CODE_INST_CALL: sm6_parser_emit_call(sm6, record, code_block, ins, dst); break; + case FUNC_CODE_INST_EXTRACTVAL: + sm6_parser_emit_extractval(sm6, record, ins, dst); + break; case FUNC_CODE_INST_RET: sm6_parser_emit_ret(sm6, record, code_block, ins); is_terminator = true; diff --git a/tests/hlsl/asfloat.shader_test b/tests/hlsl/asfloat.shader_test index 00238164c..d460240b1 100644 --- a/tests/hlsl/asfloat.shader_test +++ b/tests/hlsl/asfloat.shader_test @@ -36,7 +36,7 @@ float4 main() : sv_target uniform 0 float4 11 12 0 0 uniform 4 float4 13 14 0 0 uniform 8 float4 20 21 22 23 -todo(sm>=6) draw quad +draw quad probe (320,240) rgba (13.0, 21.0, 0.0, 0.0)
[pixel shader fail] diff --git a/tests/hlsl/cbuffer.shader_test b/tests/hlsl/cbuffer.shader_test index 59dda97a5..dbb49ea7e 100644 --- a/tests/hlsl/cbuffer.shader_test +++ b/tests/hlsl/cbuffer.shader_test @@ -13,7 +13,7 @@ float4 main() : sv_target
[test] uniform 0 float4 1.0 2.0 3.0 4.0 -todo(sm>=6) draw quad +draw quad probe all rgba (1.0, 2.0, 3.0, 4.0)
[pixel shader] @@ -31,7 +31,7 @@ float4 main() : sv_target
[test] uniform 0 float4 1.0 2.0 3.0 4.0 -todo(sm>=6) draw quad +draw quad probe all rgba (1.0, 2.0, 3.0, 4.0)
% SM1 buffer offset allocation follows different rules than SM4. @@ -72,7 +72,7 @@ uniform 0 float4 0.0 1.0 2.0 3.0 uniform 4 float4 4.0 5.0 6.0 7.0 uniform 8 float4 8.0 9.0 10.0 11.0 uniform 12 float4 12.0 13.0 14.0 15.0 -todo(sm>=6) draw quad +draw quad probe all rgba (0.0, 2.0, 4.0, 8.0)
@@ -93,7 +93,7 @@ float4 main() : sv_target uniform 0 float4 0.0 1.0 2.0 3.0 uniform 4 float4 4.0 5.0 6.0 7.0 uniform 8 float4 8.0 9.0 10.0 11.0 -todo(sm>=6) draw quad +draw quad probe all rgba (0.0, 4.0, 8.0, 9.0)
@@ -119,7 +119,7 @@ uniform 0 float4 0.0 1.0 2.0 3.0 uniform 4 float4 4.0 5.0 6.0 7.0 uniform 8 float4 8.0 9.0 10.0 11.0 uniform 12 float4 12.0 13.0 14.0 15.0 -todo(sm>=6) draw quad +draw quad probe all rgba (0.0, 4.0, 5.0, 6.0)
@@ -142,7 +142,7 @@ uniform 0 float4 1.0 0.0 0.0 0.0 uniform 4 float4 2.0 0.0 0.0 0.0 uniform 8 float4 3.0 0.0 0.0 0.0 uniform 12 float4 4.0 0.0 0.0 0.0 -todo draw quad +todo(sm<6) draw quad probe all rgba (1.0, 3.0, 3.0, 4.0)
@@ -221,7 +221,7 @@ float4 main() : sv_target
[test] uniform 0 float4 1.0 2.0 3.0 4.0 -todo(sm>=6) draw quad +draw quad probe all rgba (2.0, 3.0, 2.0, 3.0)
@@ -357,7 +357,7 @@ float4 main() : sv_target
[test] uniform 0 float4 1.0 2.0 3.0 4.0 -todo(sm>=6) draw quad +draw quad probe all rgba (3.0, 4.0, 3.0, 4.0)
diff --git a/tests/hlsl/expr-indexing.shader_test b/tests/hlsl/expr-indexing.shader_test index 1816c6eb7..1c598816e 100644 --- a/tests/hlsl/expr-indexing.shader_test +++ b/tests/hlsl/expr-indexing.shader_test @@ -40,7 +40,7 @@ float4 main() : sv_target
[test] uniform 0 float4 1.0 2.0 3.0 4.0 -todo(sm>=6) draw quad +draw quad probe all rgba (3.0, 3.0, 3.0, 3.0)
@@ -78,7 +78,7 @@ float4 main() : sv_target
[test] uniform 0 float4 1.0 2.0 3.0 4.0 -todo(sm>=6) draw quad +draw quad probe all rgba (4.0, 4.0, 4.0, 4.0)
diff --git a/tests/hlsl/majority-pragma.shader_test b/tests/hlsl/majority-pragma.shader_test index f7baa90b9..84dff63e0 100644 --- a/tests/hlsl/majority-pragma.shader_test +++ b/tests/hlsl/majority-pragma.shader_test @@ -40,7 +40,7 @@ float4 main() : sv_target [test] uniform 0 float4 0.1 0.2 0.0 0.0 uniform 4 float4 0.3 0.4 0.0 0.0 -todo(sm>=6) draw quad +draw quad probe all rgba (0.1, 0.2, 0.3, 0.4)
@@ -61,7 +61,7 @@ uniform 0 float4 0.0 0.0 0.0 0.0 uniform 4 float4 0.0 0.0 0.0 0.0 uniform 8 float4 0.5 0.6 0.0 0.0 uniform 12 float4 0.7 0.8 0.0 0.0 -todo(sm>=6) draw quad +draw quad probe all rgba (0.5, 0.6, 0.7, 0.8)
@@ -111,7 +111,7 @@ float4 main() : sv_target [test] uniform 0 float4 0.1 0.2 0.0 0.0 uniform 4 float4 0.3 0.4 0.0 0.0 -todo(sm>=6) draw quad +draw quad probe all rgba (0.1, 0.2, 0.3, 0.4)
@@ -149,7 +149,7 @@ uniform 0 float4 0.3 0.4 0.0 0.0 uniform 4 float4 0.0 0.0 0.0 0.0 uniform 8 float4 0.0 0.0 0.0 0.0 uniform 12 float4 0.5 0.6 0.0 0.0 -todo(sm>=6) draw quad +draw quad probe all rgba (0.3, 0.4, 0.5, 0.6)
@@ -173,7 +173,7 @@ float4 main() : sv_target [test] uniform 0 float4 0.1 0.2 0.0 0.0 uniform 4 float4 0.3 0.4 0.0 0.0 -todo(sm>=6) draw quad +draw quad probe all rgba (0.1, 0.2, 0.3, 0.4)
@@ -201,7 +201,7 @@ float4 main() : sv_target [test] uniform 0 float4 0.2 0.4 0.0 0.0 uniform 4 float4 0.3 0.5 0.0 0.0 -todo(sm>=6) draw quad +draw quad probe all rgba (0.2, 0.3, 0.4, 0.5)
@@ -221,7 +221,7 @@ uniform 0 float4 0.3 0.0 0.0 0.0 uniform 4 float4 0.4 0.0 0.0 0.0 uniform 8 float4 0.0 0.5 0.0 0.0 uniform 12 float4 0.0 0.6 0.0 0.0 -todo(sm>=6) draw quad +draw quad probe all rgba (0.3, 0.4, 0.5, 0.6)
% Compiler options @@ -245,7 +245,7 @@ uniform 0 float4 0.1 0.5 0.9 1.3 uniform 4 float4 0.2 0.6 1.0 1.4 uniform 8 float4 0.3 0.7 1.1 1.5 uniform 12 float4 0.4 0.8 1.2 1.6 -todo(sm>=6) draw quad +draw quad probe all rgba (0.2, 0.3, 0.6, 0.7) 1
[require] @@ -267,7 +267,7 @@ uniform 0 float4 0.1 0.5 0.9 1.3 uniform 4 float4 0.2 0.6 1.0 1.4 uniform 8 float4 0.3 0.7 1.1 1.5 uniform 12 float4 0.4 0.8 1.2 1.6 -todo(sm>=6) draw quad +draw quad probe all rgba (0.2, 0.3, 0.6, 0.7) 1
[require] @@ -289,7 +289,7 @@ uniform 0 float4 0.1 0.5 0.9 1.3 uniform 4 float4 0.2 0.6 1.0 1.4 uniform 8 float4 0.3 0.7 1.1 1.5 uniform 12 float4 0.4 0.8 1.2 1.6 -todo(sm>=6) draw quad +draw quad probe all rgba (0.5, 0.9, 0.6, 1.0) 1
[require] @@ -317,7 +317,7 @@ uniform 16 float4 1.7 2.1 2.5 2.9 uniform 20 float4 1.8 2.2 2.6 3.0 uniform 24 float4 1.9 2.3 2.7 3.1 uniform 28 float4 2.0 2.4 2.8 3.2 -todo(sm>=6) draw quad +draw quad probe all rgba (0.3, 0.4, 2.5, 2.9) 1
[require] @@ -345,7 +345,7 @@ uniform 16 float4 1.7 2.1 2.5 2.9 uniform 20 float4 1.8 2.2 2.6 3.0 uniform 24 float4 1.9 2.3 2.7 3.1 uniform 28 float4 2.0 2.4 2.8 3.2 -todo(sm>=6) draw quad +draw quad probe all rgba (1.2, 1.6, 3.1, 3.2) 1
[require] @@ -365,5 +365,5 @@ float4 main() : sv_target [test] uniform 0 float4 0.1 0.2 0.0 0.0 uniform 4 float4 0.3 0.4 0.0 0.0 -todo(sm>=6) draw quad +draw quad probe all rgba (0.1, 0.3, 0.2, 0.4) 1 diff --git a/tests/hlsl/majority-syntax.shader_test b/tests/hlsl/majority-syntax.shader_test index 63e5d2986..f1f5291ff 100644 --- a/tests/hlsl/majority-syntax.shader_test +++ b/tests/hlsl/majority-syntax.shader_test @@ -11,7 +11,7 @@ float4 main() : sv_target [test] uniform 0 float4 0.1 0.3 0.0 0.0 uniform 4 float4 0.2 0.4 0.0 0.0 -todo(sm>=6) draw quad +draw quad probe all rgba (0.1, 0.3, 0.2, 0.4)
[pixel shader fail(sm<6)] diff --git a/tests/hlsl/matrix-indexing.shader_test b/tests/hlsl/matrix-indexing.shader_test index a61983eef..170036475 100644 --- a/tests/hlsl/matrix-indexing.shader_test +++ b/tests/hlsl/matrix-indexing.shader_test @@ -11,7 +11,7 @@ uniform 0 float4 1.0 2.0 3.0 4.0 uniform 4 float4 5.0 6.0 7.0 8.0 uniform 8 float4 9.0 10.0 11.0 12.0 uniform 12 float4 13.0 14.0 15.0 16.0 -todo(sm>=6) draw quad +draw quad probe all rgba (1.0, 2.0, 10.0, 15.0)
[pixel shader] @@ -27,7 +27,7 @@ uniform 0 float4 1.0 2.0 3.0 4.0 uniform 4 float4 5.0 6.0 7.0 8.0 uniform 8 float4 9.0 10.0 11.0 12.0 uniform 12 float4 13.0 14.0 15.0 16.0 -todo(sm>=6) draw quad +draw quad probe all rgba (1.0, 2.0, 10.0, 15.0)
[pixel shader] @@ -43,7 +43,7 @@ uniform 0 float4 1.0 2.0 3.0 4.0 uniform 4 float4 5.0 6.0 7.0 8.0 uniform 8 float4 9.0 10.0 11.0 12.0 uniform 12 float4 13.0 14.0 15.0 16.0 -todo(sm>=6) draw quad +draw quad probe all rgba (1.0, 5.0, 7.0, 12.0)
[pixel shader] @@ -58,7 +58,7 @@ float4 main() : SV_TARGET [test] uniform 0 float4 1.0 2.0 3.0 0.0 uniform 4 float4 5.0 6.0 7.0 0.0 -todo(sm>=6) draw quad +draw quad probe all rgba (1.0, 3.0, 6.0, 7.0)
[pixel shader] diff --git a/tests/hlsl/nested-arrays.shader_test b/tests/hlsl/nested-arrays.shader_test index b7aeec442..c9ba186bd 100644 --- a/tests/hlsl/nested-arrays.shader_test +++ b/tests/hlsl/nested-arrays.shader_test @@ -21,5 +21,5 @@ uniform 8 float4 0.3 0.0 0.0 0.0 uniform 12 float4 0.4 0.0 0.0 0.0 uniform 16 float4 0.5 0.0 0.0 0.0 uniform 20 float4 0.6 0.0 0.0 0.0 -todo(sm>=6) draw quad +draw quad probe all rgba (0.4, 0.1, 0.6, 0.3) diff --git a/tests/hlsl/object-field-offsets.shader_test b/tests/hlsl/object-field-offsets.shader_test index d1741c3e4..9cc4581ba 100644 --- a/tests/hlsl/object-field-offsets.shader_test +++ b/tests/hlsl/object-field-offsets.shader_test @@ -19,7 +19,7 @@ float4 main() : sv_target [test] uniform 0 float4 1.0 2.0 3.0 4.0 uniform 4 float4 5.0 6.0 7.0 8.0 -todo(sm>=6) draw quad +draw quad probe all rgba (1.0, 2.0, 3.0, 0.0)
@@ -66,5 +66,5 @@ float4 main() : sv_target [test] uniform 0 float4 1.0 2.0 3.0 4.0 uniform 4 float4 5.0 6.0 7.0 8.0 -todo(sm>=6) draw quad +draw quad probe all rgba (1.0, 2.0, 5.0, 0.0) diff --git a/tests/hlsl/storage-qualifiers.shader_test b/tests/hlsl/storage-qualifiers.shader_test index 09385e3e4..86cea4713 100644 --- a/tests/hlsl/storage-qualifiers.shader_test +++ b/tests/hlsl/storage-qualifiers.shader_test @@ -42,5 +42,5 @@ void main(out float4 o : sv_target) [test] uniform 0 float4 0.1 0.0 0.0 0.0 uniform 4 float4 0.2 0.0 0.0 0.0 -todo(sm>=6) draw quad +draw quad probe all rgba (0.1, 0.2, 0.3, 0.4) diff --git a/tests/hlsl/struct-array.shader_test b/tests/hlsl/struct-array.shader_test index 4097f3835..aff0a677a 100644 --- a/tests/hlsl/struct-array.shader_test +++ b/tests/hlsl/struct-array.shader_test @@ -18,5 +18,5 @@ float4 main() : sv_target uniform 0 float4 0.1 0.2 0.0 0.0 uniform 4 float4 0.3 0.4 0.0 0.0 uniform 8 float4 0.5 0.6 0.0 0.0 -todo(sm>=6) draw quad +draw quad probe all rgba (0.2, 0.3, 0.6, 0.5) diff --git a/tests/hlsl/swizzle-matrix.shader_test b/tests/hlsl/swizzle-matrix.shader_test index 005522759..740d4d904 100644 --- a/tests/hlsl/swizzle-matrix.shader_test +++ b/tests/hlsl/swizzle-matrix.shader_test @@ -9,7 +9,7 @@ float4 main() : sv_target [test] uniform 0 float4 11 21 31 -1 uniform 4 float4 12 22 32 -1 -todo(sm>=6) draw quad +draw quad probe all rgba (21.0, 31.0, 11.0, 12.0)
@@ -24,7 +24,7 @@ float4 main() : sv_target [test] uniform 0 float4 11 21 31 -1 uniform 4 float4 12 22 32 -1 -todo(sm>=6) draw quad +draw quad probe all rgba (11.0, 31.0, 12.0, 32.0)
@@ -40,7 +40,7 @@ float4 main() : sv_target uniform 0 float4 11 12 -1 -1 uniform 4 float4 21 22 -1 -1 uniform 8 float4 31 32 -1 -1 -todo(sm>=6) draw quad +draw quad probe all rgba (11.0, 31.0, 12.0, 32.0)
@@ -169,8 +169,8 @@ float4 main() : sv_target
[test] uniform 0 float4 20 30 40 -1 -todo draw quad -todo probe all rgba (10.0, 20.0, 30.0, 40.0) +todo(sm<6) draw quad +todo(sm<6) probe all rgba (10.0, 20.0, 30.0, 40.0)
[pixel shader todo] @@ -187,8 +187,8 @@ float4 main() : sv_target
[test] uniform 0 float4 20 30 80 -1 -todo draw quad -todo probe all rgba (80.0, 30.0, 20.0, 10.0) +todo(sm<6) draw quad +todo(sm<6) probe all rgba (80.0, 30.0, 20.0, 10.0)
% Cannot repeat components when assigning to a swizzle. diff --git a/tests/hlsl/swizzles.shader_test b/tests/hlsl/swizzles.shader_test index ddfc09fc9..c3d3343f3 100644 --- a/tests/hlsl/swizzles.shader_test +++ b/tests/hlsl/swizzles.shader_test @@ -11,7 +11,7 @@ float4 main() : sv_target
[test] uniform 0 float4 0.0303 0.08 0.07 0.0202 -todo(sm>=6) draw quad +draw quad probe all rgba (0.0101, 0.0303, 0.0202, 0.0404)
@@ -149,7 +149,7 @@ float4 main() : sv_target
[test] uniform 0 float4 1.0 2.0 3.0 4.0 -todo(sm>=6) draw quad +draw quad probe all rgba (1.0, 2.0, 3.0, 4.0)
@@ -166,5 +166,5 @@ float4 main() : sv_target
[test] uniform 0 float4 1.0 2.0 3.0 4.0 -todo(sm>=6) draw quad +draw quad probe all rgba (1.0, 4.0, 2.0, 3.0) diff --git a/tests/hlsl/uniform-semantics.shader_test b/tests/hlsl/uniform-semantics.shader_test index 86e3b83f9..1125117fe 100644 --- a/tests/hlsl/uniform-semantics.shader_test +++ b/tests/hlsl/uniform-semantics.shader_test @@ -10,7 +10,7 @@ float4 main() : sv_target
[test] uniform 0 float 3.5 -todo(sm>=6) draw quad +draw quad probe all rgba (3.5, 3.5, 3.5, 3.5)
@@ -24,5 +24,5 @@ float4 main() : sv_target
[test] uniform 0 float4 4.0 5.0 6.0 7.0 -todo(sm>=6) draw quad +draw quad probe all rgba (4.0, 5.0, 4.0, 5.0) diff --git a/tests/hlsl/vector-indexing.shader_test b/tests/hlsl/vector-indexing.shader_test index 71a4ca26d..9f6f9a2ca 100644 --- a/tests/hlsl/vector-indexing.shader_test +++ b/tests/hlsl/vector-indexing.shader_test @@ -23,7 +23,7 @@ float4 main() : SV_TARGET
[test] uniform 0 float4 1.0 2.0 3.0 4.0 -todo(sm>=6) draw quad +draw quad probe all rgba (1.0, 2.0, 2.0, 3.0)