Commit Graph

5986 Commits

Author SHA1 Message Date
Henri Verbeet
1c01560321 vkd3d-shader/tpf: Return a vkd3d_shader_sysval_semantic from hlsl_sm4_usage_from_semantic(). 2024-09-02 19:12:53 +02:00
Anna (navi) Figueiredo Gomes
f5205da8e9 vkd3d-shader/spirv: Pass a vkd3d_shader_descriptor_info1 structure to spirv_compiler_build_descriptor_variable(). 2024-09-02 19:10:19 +02:00
Anna (navi) Figueiredo Gomes
672a8f5ce9 vkd3d-shader/spirv: Pass a vkd3d_shader_descriptor_info1 structure to spirv_compiler_emit_sampler_declaration(). 2024-09-02 18:59:37 +02:00
Anna (navi) Figueiredo Gomes
22aad955ec vkd3d-shader/spirv: Pass a vkd3d_shader_descriptor_info1 structure to spirv_compiler_emit_cbv_declaration(). 2024-09-02 18:58:29 +02:00
Anna (navi) Figueiredo Gomes
2a52ccf2c6 vkd3d-shader/spirv: Pass a vkd3d_shader_descriptor_info1 structure to spirv_compiler_emit_resource_declaration(). 2024-09-02 18:54:19 +02:00
Giovanni Mascellani
527966580e vkd3d-shader: Dump the converted shader too. 2024-08-29 19:17:07 +02:00
Giovanni Mascellani
1a0d6a4db4 vkd3d-shader: Use a hash to build the filename when dumping shaders.
This way the same shader is always dumped to the same path and when
launching the same program over and over we avoid both creating new
copies of the same file each time and overwriting different dumped
shaders.
2024-08-29 19:14:27 +02:00
Henri Verbeet
0e72aba0bc Release 1.13. 2024-08-29 12:08:46 +02:00
Elizabeth Figura
eb71a1722a vkd3d-shader: Use an extended version of vkd3d_shader_immediate_constant in vkd3d_shader_parameter1.
This is a proposed API change in 946, which won't make it into this release.

The intent is to allow slightly larger constants to be specified in the updated
vkd3d_shader_parameter1 structure. In particular, this is large enough to pass
4-dimensional integer or float vectors inline, which the proposed clip plane
implementation will use, as well as other Direct3D FFP parameters.

We could also simply add vkd3d_shader_immediate_constant1 as a separate union
member in vkd3d_shader_parameter1, but this API is a bit cleaner and simpler.
2024-08-28 12:08:37 +02:00
Henri Verbeet
f318e565f2 vkd3d-shader/spirv: Decorate non-array descriptor variables as well.
Commits 343c7942e1 and
94c74d2c00 moved applying the NonReadable
and Coherent decorations from spirv_compiler_emit_resource_declaration()
to spirv_compiler_build_descriptor_variable(), but unfortunately missed
the non-array path in the latter function.

The missing NonReadable decoration causes segmentation faults in
rasteriser-ordered-views.shader_test (among others) on my Intel SKL GT2
setup in particular.
2024-08-26 11:24:01 +02:00
Conor McCarthy
80e607e3e7 vkd3d: Free descriptor range information on error paths in d3d12_root_signature_info_from_desc(). (Valgrind)
Fixes memory leaks in test_create_root_signature().
2024-08-26 11:20:54 +02:00
Henri Verbeet
32dc7ff43b build: Actually run bitwise-assignment.shader_test.
Also fix the order of a couple of tests while we're touching this.
2024-08-22 16:32:40 +02:00
Francisco Casas
f5ed0d9efd tests/test-driver: Avoid double space when printing details.
Save screen real estate.
2024-08-22 16:22:29 +02:00
Francisco Casas
b701f8d393 tests/shader_runner: Explicitly require UAV load support.
The used UAV formats are explicitly added in the [require] section of
every test that uses them.

Some of these tests were failing on Intel UHD graphics 770 because of
missing support for additional UAV load types, explicitly requiring
these formats allows these tests to be skipped.
2024-08-22 16:22:18 +02:00
Francisco Casas
fb153bf5d4 tests/shader_runner: Don't skip shader compilation on missing caps.
Currently we are skipping compilation tests ([* shader] blocks) on
missing capabilities. This is not really necessary and it is useful to
test shader compilation even on machines that can't run these tests.

So, this commit moves the checks to the [test] blocks, skipping them
entirely when caps are not met.

To make the effects of enum test_action values more explicit, these
are renamed to TEST_ACTION_SKIP_COMPILATION and
TEST_ACTION_SKIP_EXECUTION.
2024-08-22 16:01:37 +02:00
Francisco Casas
19c23ca6f2 tests/shader_runner: Replace spaces with dashes in format names.
Probably good if we want to allow specifying several formats in the same
line, separated by spaces.

While at it, rename "r32g32 int" to "r32g32-sint".
2024-08-22 16:01:37 +02:00
Francisco Casas
cec62c54ad tests/shader_runner: Move parse_format() up. 2024-08-22 16:01:32 +02:00
Francisco Casas
164076d176 tests/shader_runner: Require explicit formats for UAV resources.
The current default is r32g32b32a32 but it requires special support
which is not available on all GPUs, so it is not a very convenient
default.

Instead of changing the default making it different from RTV resoures,
the format is required to always be explicit for UAVs.

The exceptions are counter_buffer and buffers with "stride", which don't
require a format because it is already implied.
2024-08-22 16:01:26 +02:00
Conor McCarthy
738ecc9eb1 vkd3d-shader/spirv: Free the spirv parameter info. 2024-08-20 21:27:58 +02:00
Francisco Casas
56cd64ccba tests: Test shader compilation with default values. 2024-08-20 21:26:26 +02:00
Francisco Casas
9fa8921b50 tests: Test shader compilation within braces. 2024-08-20 21:26:26 +02:00
Francisco Casas
1d24587405 tests: Test compile syntax on effects. 2024-08-20 21:26:26 +02:00
Francisco Casas
e9260bba3a tests: Test shader compilation within function definitions. 2024-08-20 21:26:26 +02:00
Francisco Casas
7363fd2816 tests: Add additional tests for function calls in state block rhs. 2024-08-20 21:26:26 +02:00
Francisco Casas
becdcec147 vkd3d-shader: Avoid div by zero on assert in vkd3d_calloc() (ubsan). 2024-08-20 21:26:26 +02:00
Anna (navi) Figueiredo Gomes
94c74d2c00 vkd3d-shader/spirv: Avoid decorating variables multiple times with Coherent. 2024-08-20 21:25:15 +02:00
Anna (navi) Figueiredo Gomes
a47c23fa1f vkd3d-shader/spirv: Use unique SPIR-V variables for descriptors where visibility differs.
In the case two uav descriptors are mapped to the same variable, and one is
read from while the other is not, the variable would get the NonReadable
decorator, while being read from later.
2024-08-20 21:23:31 +02:00
Anna (navi) Figueiredo Gomes
343c7942e1 vkd3d-shader/spirv: Avoid decorating variables multiple times with NonReadable.
The existing code reuses the same SPIR-V variable for all descriptors mapped to
the same Vulkan binding, and applies the NonReadable decoration based on the
VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_UAV_READ only. This potentially causes the
decoration to be applied twice, should two non-read descriptors be mapped to
the same variable, which isn't allowed in SPIR-V, and the validator complains.
2024-08-20 21:20:33 +02:00
Nikolay Sivov
c8cc1b1a24 vkd3d-shader/fx: Fix the matrix type class for fx_2_0.
CTAB type correctly reflects matrix majority, unlike effects
type data that does not respond to majority modifiers at all.
It doesn't transpose default values either.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-08-19 14:21:59 +02:00
Nikolay Sivov
b9e894f232 include: Fix a few typos in the IDL files.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-08-19 14:20:28 +02:00
Nikolay Sivov
f0a2e4bc25 vkd3d-shader/glsl: Fix a typo in a few messages.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-08-19 14:20:21 +02:00
Nikolay Sivov
d1b8a7e745 vkd3d: Fix a few typos in the comments.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-08-19 14:17:41 +02:00
Petrichor Park
4467c655f0 vkd3d-shader/hlsl: Factor out add_binary_expr() and use it for assignment operators.
This fixes a lot of internal compiler errors with assignment operators,
especially bitwise ones. The bitwise-assignment test has the motivating
examples.
2024-08-19 14:15:43 +02:00
Nikolay Sivov
ebc039d128 vkd3d-shader/fx: Resolve NULL values for SamplerState.Texture field.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-08-15 17:53:46 +02:00
Nikolay Sivov
873b182021 vkd3d-shader/fx: Support NULL constants for object fields.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-08-15 17:53:46 +02:00
Nikolay Sivov
c3075d6fb4 vkd3d-shader/hlsl: Adjust NULL type properties to make it usable in transformations.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-08-15 17:53:46 +02:00
Nikolay Sivov
aa0ea548e4 vkd3d-shader/fx: Handle SetPixelShader() and SetVertexShader().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-08-15 17:53:46 +02:00
Nikolay Sivov
2c533e494a vkd3d-shader/fx: Handle SetBlendState().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-08-15 17:53:46 +02:00
Anna (navi) Figueiredo Gomes
16e9872718 vkd3d: Use D3D12_SHADER_VISIBILITY_ALL for 32-bit root constants when using vk_heaps.
The existing code sets "stageFlags" to VK_SHADER_STAGE_ALL when
"use_vk_heaps" is true, but doesn't adjust the visibility. This
potentially violates the "Any two elements of pPushConstantRanges must
not include the same stage in stageFlags" constraint, and causes the
validation layers to complain accordingly.
2024-08-15 17:53:46 +02:00
Anna (navi) Figueiredo Gomes
6226f533af Add a .editorconfig file. 2024-08-14 22:05:59 +02:00
Nikolay Sivov
60ce81112b vkd3d-shader/fx: Support string annotations for fx_4+.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-08-14 22:00:35 +02:00
Nikolay Sivov
d4ae844bb6 vkd3d-shader/fx: Enable writing string objects for fx_4+.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-08-14 22:00:35 +02:00
Nikolay Sivov
89be723ad7 vkd3d-shader/hlsl: Treat "string" type name as case-insensitive.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-08-14 22:00:35 +02:00
Nikolay Sivov
1ce68cee2c vkd3d-shader/hlsl: Tokenize 'String' the same as 'string'.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-08-14 22:00:35 +02:00
Francisco Casas
412f91a14c vkd3d-shader/hlsl: Always work with the extern resource's component type.
We need to distinguish between the data type of a resource and the data
type of its components. These are usually the same except for 4.0
profiles where an array (or multi-dimensional array) of resources is
still considered a single resource, so it is possible for it to hold
more than one component.

In the latter case, we often need to access the type of a single
component (all components have the same type) instead of the type of the
whole array which often doesn't contain the required information, such
as sampler dimension.

This patch replaces the extern_resource.data_type field with the
extern_resource.component_type field, which points to the type of a
single component in the resource. Using it relieves many other code
paths from considering the possibility of the resource being an array.

This fixes runtime errors reported by UBSan, such as this:

    vkd3d/libs/vkd3d-shader/tpf.c:6075:87: runtime error: load of value 7, which is not a valid value for type '_Bool'

when trying to compile shaders that contain UAV arrays on 4.0 profiles.

Before this commit, tpf.c accesses the

    hlsl_type->e.resource.rasteriser_ordered

field, but on 4.0 and 4.1 profiles these code paths can also be reached
by UAV arrays which are HLSL_CLASS_ARRAY and this field is not supposed
to be accessed.

By coincidence, the value of hlsl_type->e.array.elements_count was being
read because these fields have the same offset in the hlsl_type.e union.
2024-08-14 21:57:21 +02:00
Henri Verbeet
9cf479d4bb vkd3d: Do not include assert.h. 2024-08-13 21:20:28 +02:00
Henri Verbeet
114578fc8a vkd3d-shader/fx: Replace assert() with VKD3D_ASSERT(). 2024-08-13 21:20:28 +02:00
Henri Verbeet
cd9879f237 vkd3d-common: Replace assert() with VKD3D_ASSERT(). 2024-08-13 21:20:28 +02:00
Francisco Casas
355d4c4a86 vkd3d-shader/hlsl: Skip writing string default values.
This causes a crash in the native compiler, but can only happen in
ps_5_0 were it is possible to declare structs that are both used in the
shader and contain strings.

    struct
    {
        float a;
        string b;
    } apple = {1, "foobar"};

    float4 main() : sv_target
    {
        return apple.a;
    }

In our case, hlsl_type_get_component_offset() triggered an assertion
failure because it does not expect the string type. So this is replaced
by an hlsl_error().
2024-08-13 21:19:04 +02:00
Francisco Casas
094e298c1c vkd3d-shader/hlsl: Parse string default values. 2024-08-13 21:19:01 +02:00