2269 Commits

Author SHA1 Message Date
Henri Verbeet
f732fb7889 Release 1.17. 2025-08-21 12:52:13 +02:00
Brendan Shanks
44fffee5e1 tests: Add dxcompiler.h to .gitignore. 2025-08-14 10:34:44 +02:00
Brendan Shanks
bb2a6a0322 include: Add additional generated files to .gitignore. 2025-08-14 10:34:44 +02:00
Henri Verbeet
975ba8f9da vkd3d-shader: Document that vkd3d_shader_scan() supports HLSL sources. 2025-08-14 10:33:45 +02:00
Francisco Casas
7007a1e264 vkd3d-compiler: Set a default target type even when preprocessing.
We largely ignore the target type when preprocessing, but still
dereference options.target_type in a couple of places. E.g. when setting
info.target_type. We could add more checks for options.preprocess_only
to account for that, but it seems more robust to make sure
options.target_type is never NULL.
2025-08-13 16:12:50 +02:00
Henri Verbeet
cab0bd07e5 vkd3d-shader/glsl: Resolve SSA values.
Since commit eaebef4265 we may receive
vsir generated from HLSL sources, which typically contains SSA values.
We could previously receive vsir with SSA values as well, but HLSL
sources would go through d3dbc/tpf as an intermediate step, making the
resulting vsir much less likely to contain SSA values.
2025-08-13 15:56:06 +02:00
Henri Verbeet
9336b4647c vkd3d-shader/d3d-asm: Resolve SSA values when outputting SM<6 assembly.
In particular, since commit eaebef4265 we
may receive vsir generated from HLSL sources, which typically contains
SSA values.
2025-08-13 15:55:31 +02:00
Henri Verbeet
8334386d99 vkd3d-shader/spirv: Avoid emitting duplicate built-in inputs in spirv_compiler_emit_input().
This works around an issue introduced by commit
66cb2815f0. SV_PRIMITIVE_ID inputs in
geometry shaders use VKD3DSPR_PRIMID registers, and we create the
corresponding SPIR-V inputs using spirv_compiler_emit_io_register().
Unfortunately we also have an input signature element for the same
input, and simply creating another PrimitiveId input would run into
VUID-StandaloneSpirv-OpEntryPoint-09658.

Before the commit mentioned above, we'd use DCL_INPUT instructions to
emit input declarations, and these would help to distinguish whether
VKD3DSPR_INPUT or VKD3DSPR_PRIMID registers were used for primitive ID
inputs. Note that we can't simply ignore input signature element with
SIGNATURE_TARGET_LOCATION_UNUSED; the DXIL parser emits SV_SAMPLE_INDEX
inputs with that target location, but does require them to use a
VKD3DSPR_INPUT register.
2025-08-13 15:54:12 +02:00
Francisco Casas
880cb1083f vkd3d-shader/ir: Use iterators in vsir_program_insert_point_coord(). 2025-08-07 20:43:28 +02:00
Francisco Casas
a91b880afa vkd3d-shader/ir: Use iterators in vsir_program_insert_point_size_clamp(). 2025-08-07 20:43:28 +02:00
Francisco Casas
0ed34c22c9 vkd3d-shader/ir: Use iterators in vsir_program_insert_point_size(). 2025-08-07 20:43:28 +02:00
Francisco Casas
14643b02f6 vkd3d-shader/ir: Use iterators in vsir_program_insert_clip_planes(). 2025-08-07 20:43:28 +02:00
Francisco Casas
bd52ed8918 vkd3d-shader/ir: Use iterators in vsir_program_insert_alpha_test(). 2025-08-07 20:43:28 +02:00
Henri Verbeet
f7890fc54c vkd3d-shader/hlsl: Support HLSL sources in vkd3d_shader_scan(). 2025-08-07 20:40:01 +02:00
Henri Verbeet
f95fc28851 vkd3d-shader/hlsl: Return a vsir program from hlsl_compile_shader().
This largely brings the HLSL frontend in line with the other frontends.
2025-08-07 20:40:01 +02:00
Henri Verbeet
85603dc9c6 vkd3d-shader/hlsl: Initialise the vsir program in hlsl_compile_shader().
Mostly in preparation for returning a vsir program from
hlsl_compile_shader() in the next commit.
2025-08-07 20:37:41 +02:00
Henri Verbeet
e7be5aa9fd vkd3d-shader/hlsl: Pass a vkd3d_shader_source_list pointer to hlsl_ctx_init().
Instead of storing the list inside struct hlsl_ctx. The source file
names in the list are used by the location information that the HLSL
frontend produces, and end up being referenced by the vsir program. If
we want the vsir program to be able to outlive the hlsl_ctx, its
location information can't reference data owned by the hlsl_ctx.
2025-08-07 20:33:24 +02:00
Henri Verbeet
7c37fc6a8b vkd3d-shader: Introduce struct vkd3d_shader_source_list. 2025-08-07 20:33:24 +02:00
Henri Verbeet
e4bb77ecef vkd3d-shader: Cleanup the vsir program on vsir_program_transform_early() failure in vsir_parse(). 2025-08-07 20:33:24 +02:00
Elizabeth Figura
f9bb84e5ef vkd3d-shader/d3dbc: Lower TEXCRD. 2025-08-07 19:30:29 +02:00
Elizabeth Figura
731b94f6f9 vkd3d-shader/d3dbc: Lower 1.4 TEXLD. 2025-08-07 19:05:25 +02:00
Elizabeth Figura
9c605c942c vkd3d-shader/d3dbc: Normalize ps 1.x output. 2025-08-07 18:55:40 +02:00
Elizabeth Figura
a4f69d4ae6 vkd3d-shader/d3dbc: Move TEXLD lowering to d3dbc_parse(). 2025-08-07 18:52:46 +02:00
Elizabeth Figura
2201c32e6d vkd3d-shader: Add descriptors from SAMPLE instructions if necessary.
This has no effect now, but will once we start lowering sm1 texturing
instructions before vsir_program_scan() is called.
2025-08-07 16:15:47 +02:00
Francisco Casas
f6d0c689ee vkd3d-shader/ir: Use iterators in vsir_program_materialise_phi_ssas_to_temps(). 2025-08-06 18:24:19 +02:00
Francisco Casas
aab02b1bca vkd3d-shader/ir: Use iterators in vsir_program_flatten_hull_shader_phases(). 2025-08-06 18:23:33 +02:00
Francisco Casas
6c840b80d6 vkd3d-shader/ir: Use iterators in cf_flattener_iterate_instruction_array(). 2025-08-06 18:19:55 +02:00
Francisco Casas
e428528a7c vkd3d-shader/ir: Use iterators in vsir_program_remove_dead_code(). 2025-08-06 18:19:55 +02:00
Francisco Casas
f818d052cd vkd3d-shader/ir: Remove the io_normaliser.instructions field.
It's effectively unused, and struct vkd3d_shader_instruction_array is
not meant to be copied by value. If io_normaliser.instructions were to
be modified it might leave program->instructions in an inconsistent
state.
2025-08-06 12:54:54 +02:00
Francisco Casas
b3badec039 vkd3d-shader/ir: Use iterators in vsir_program_normalise_io_registers(). 2025-08-06 12:53:52 +02:00
Francisco Casas
304caa885f vkd3d-shader/ir: Use iterators in vsir_program_normalise_flat_constants(). 2025-08-06 12:53:52 +02:00
Francisco Casas
37ca1b55c9 vkd3d-shader/ir: Use iterators in instruction_array_normalise_hull_shader_control_point_io(). 2025-08-06 12:53:52 +02:00
Francisco Casas
97e3877aa4 vkd3d-shader/ir: Use iterators in vsir_program_remap_output_signature(). 2025-08-06 12:53:52 +02:00
Francisco Casas
6dc9ff1bd8 vkd3d-shader/ir: Use iterators in vsir_program_ensure_diffuse().
The change in vsir_program_iterator_next() is necessary to allow us to
introduce instructions before the iterator using:

    vsir_program_iterator_prev(&it);
    vsir_program_iterator_inset_after(&it, n);
    vsir_program_iterator_next(&it);

This since (it.idx == SIZE_MAX) is equivalent to the iterator being
before the beginning of the list.
2025-08-06 12:53:37 +02:00
Henri Verbeet
ce20f9d4b2 tests/shader_runner_d3d12: Check whether the d3d12 device supports geometry shaders. 2025-08-06 12:04:16 +02:00
Henri Verbeet
47a183c75b tests/d3d12: Check whether the d3d12 device supports geometry shaders. 2025-08-06 12:04:16 +02:00
Shaun Ren
4bb880f9ed vkd3d-shader/hlsl: Support interlocked operations on non-indexed groupshared variables. 2025-08-05 16:33:08 +02:00
Shaun Ren
8d0d8d106b vkd3d-shader/hlsl: Support stores to raw groupshared variables. 2025-08-05 16:32:34 +02:00
Shaun Ren
c8d2d40b91 vkd3d-shader/hlsl: Support loads from groupshared variables. 2025-08-05 16:18:26 +02:00
Shaun Ren
fa560b589e vkd3d-shader/hlsl: Emit dcl_tgsm_raw instructions for raw groupshared variables. 2025-08-05 16:09:45 +02:00
Shaun Ren
3802344e97 vkd3d-shader/hlsl: Allocate groupshared registers. 2025-08-05 16:06:07 +02:00
Victor Chiletto
e615e435d9 vkd3d-shader/hlsl: Split matrix copies from resource loads. 2025-08-05 14:25:50 +02:00
Victor Chiletto
e718546ee5 vkd3d-shader/hlsl: Transform hlsl_ir_index into structured buffers into field specific hlsl_ir_resource_loads. 2025-08-05 14:25:50 +02:00
Victor Chiletto
5dbf859029 vkd3d-shader/hlsl: Parse SRV structured buffers. 2025-08-05 14:25:50 +02:00
Victor Chiletto
161d463f3c tests/hlsl: Add a few extra structured buffer matrix load + swizzle tests. 2025-08-05 14:25:44 +02:00
Henri Verbeet
721859005f tests: Strip reflection data from dxbc-tpf-hex shaders. 2025-08-04 15:00:02 +02:00
Henri Verbeet
243207701b tests/shader_runner: Parse hex blobs as a list of 32-bit integers. 2025-08-04 15:00:02 +02:00
Francisco Casas
5dca0da2da vkd3d-shader/hlsl: Use vsir_program_append() in generate_vsir_add_program_instruction(). 2025-08-04 14:58:14 +02:00
Francisco Casas
be5a9c2ca8 vkd3d-shader/hlsl: Use vsir_program_append() in sm1_generate_vsir_sampler_dcls(). 2025-08-04 14:52:50 +02:00
Francisco Casas
81488ce330 vkd3d-shader/hlsl: Use vsir_program_append() in sm1_generate_vsir_constant_defs(). 2025-08-04 14:47:58 +02:00
Francisco Casas
8717fe9c47 vkd3d-shader/dxil: Use iterators in sm6_parser_globals_init(). 2025-08-04 14:40:17 +02:00
Giovanni Mascellani
3817df1164 tests/shader_runner_metal: Run the Metal shader runner with DXIL shaders. 2025-08-04 14:34:23 +02:00
Giovanni Mascellani
d898923b1c tests/shader_runner_metal: Allow checking shader model 5.1 too. 2025-08-04 14:34:23 +02:00
Giovanni Mascellani
1d71cf9af1 vkd3d-shader/msl: Allocate SSA registers to temporaries. 2025-08-04 14:34:23 +02:00
Giovanni Mascellani
bec000b88e vkd3d-shader: Enable converting DXIL to MSL.
Only trivial shaders work so far.
2025-08-04 14:34:01 +02:00
Conor McCarthy
691dd49e49 vkd3d-shader/dxil: Handle SV_PrimitiveId outputs. 2025-08-04 11:54:46 +02:00
Conor McCarthy
1293db7536 tests/hlsl: Add a test for SV_PrimitiveId inputs and outputs. 2025-08-04 11:54:46 +02:00
Henri Verbeet
bd3d0f3495 vkd3d-shader/ir: Use vsir_program_append() in vsir_program_ensure_ret().
I think this is slightly nicer. It also happens to avoid a
-Warray-bounds warning on some versions of gcc that suggests the "ins"
pointer returned by vsir_program_iterator_next() may be NULL.
2025-07-31 15:01:29 +02:00
Conor McCarthy
b9fe19701c vkd3d-shader/dxil: Handle SV_ViewportArrayIndex. 2025-07-31 14:55:33 +02:00
Conor McCarthy
cd8cea6913 tests: Replace test_ps_viewport_index() with a shader runner test.
Mainly to allow testing the functionality in question with DXIL shaders
as well.
2025-07-31 14:55:33 +02:00
Henri Verbeet
55fe8df979 vkd3d: Set the maximum viewport count in d3d12_pipeline_state_get_or_create_pipeline().
VK_DYNAMIC_STATE_VIEWPORT and VK_DYNAMIC_STATE_SCISSOR specify that
viewports and scissor rectangles are dynamic state, but not their
counts.

It took a while to notice this issue because the existing code seemed to
largely work as intended on hardware implementations, but tests using
the additional viewports would fail on llvmpipe.
2025-07-31 14:55:33 +02:00
Henri Verbeet
74d8c23f71 include: Remove some redudant TAG_* definintions from vkd3d_shader_util.h.
We already have all of these in vkd3d_common.h.
2025-07-31 14:54:59 +02:00
Elizabeth Figura
d0ce3e61bf tests/hlsl: Add a regression test for packed SV_IsFrontFace.
This tests f0906e9c5c.
2025-07-31 14:54:15 +02:00
Elizabeth Figura
75cb4336ec vkd3d-shader/ir: Record the previous temp count before allocating any SSA values.
Due to the unintentional placement of this line, we were inadvertently
allocating every SSA value to a unique temp register, overflowing limits.
2025-07-30 15:36:38 +02:00
Henri Verbeet
67fd9bb76b vkd3d-shader/ir: Free program parameters on failure in vsir_program_init() if needed. 2025-07-30 15:35:54 +02:00
Henri Verbeet
f6a9def564 vkd3d-shader/spirv: Update the SPIR-V grammar JSON to the vulkan-sdk-1.4.313.0 release. 2025-07-30 15:11:19 +02:00
Henri Verbeet
bb2979aa4c vkd3d-shader/hlsl: Generate vsir signatures in hlsl_emit_vsir(). 2025-07-29 13:15:22 +02:00
Henri Verbeet
49b857c5b7 vkd3d-shader/hlsl: Initialise the vsir program in hlsl_emit_vsir(). 2025-07-29 13:15:22 +02:00
Henri Verbeet
dbaecb3f36 vkd3d-shader/hlsl: Introduce hlsl_compile_effect().
The goal being to allow hlsl_compile_shader() to return a vsir program.
2025-07-29 13:14:30 +02:00
Giovanni Mascellani
6805612918 vkd3d-shader: Use the structure names when creating the parameter allocators.
So that it doesn't depend on the instruction array implementation.
2025-07-29 13:13:53 +02:00
Giovanni Mascellani
247fbd869a vkd3d-shader/ir: Use iterators in vsir_program_ensure_ret(). 2025-07-29 13:12:58 +02:00
Giovanni Mascellani
812f6faa11 vkd3d-shader/ir: Use iterators in vsir_program_normalize_addr(). 2025-07-29 12:53:00 +02:00
Giovanni Mascellani
50afaf4ac6 vkd3d-shader: Use iterators in vsir_program_scan(). 2025-07-29 12:53:00 +02:00
Giovanni Mascellani
aba355896f vkd3d-shader/hlsl: Reject geometry shaders with instance count.
We currently emit a warning and miscompile them.
2025-07-29 12:51:06 +02:00
Giovanni Mascellani
22f84317c0 vkd3d-shader/ir: Check that GSINSTID registers have dimension VEC4.
I had set it to SCALAR in an earlier commit, but I hadn't noticed
it failed validation.

Also fix the HLSL compiler to emit them accordingly.

Fixes: dfc18781cc
2025-07-29 12:51:06 +02:00
Giovanni Mascellani
3797c922a5 tests/hlsl: Test SV_GSInstanceID. 2025-07-29 12:50:23 +02:00
Giovanni Mascellani
52b9ef0426 vkd3d-shader/spirv: Support precise flags on SAMPLE_INFO instructions. 2025-07-29 12:31:36 +02:00
Giovanni Mascellani
53754f0583 vkd3d-shader/spirv: Support precise flags on RESINFO instructions. 2025-07-29 12:31:23 +02:00
Giovanni Mascellani
bdccdd9996 vkd3d-shader/d3d-asm: Emit precise flags for a number of opcodes.
I've seen them specifically on RESINFO, but it general it makes
sense to print them for any opcode that expects a bit field in
the flags.
2025-07-29 12:28:09 +02:00
Giovanni Mascellani
f7866df201 vkd3d-shader/dxil: Emit gather offsets as signed.
This is important for the MSL generator, otherwise invalid MSL
is emitted.
2025-07-28 16:32:40 +02:00
Giovanni Mascellani
3cf35ce22e vkd3d-shader/msl: Convert the results of load and sample operations to the destination data type.
This should eventually go away when we properly enforce vsir typing,
but since for the moment we're resolving to hack, let's at least
make it compatible with DXIL.
2025-07-28 16:31:57 +02:00
Giovanni Mascellani
7df92b6e50 vkd3d-shader/msl: Reject shaders with duplicate I/O target locations.
We'll have to handle them eventually, but let's avoid generating
invalid code in the meantime.
2025-07-28 16:27:58 +02:00
Giovanni Mascellani
9476a235b2 vkd3d-shader/msl: Use the union type for SAMPLEMASK registers.
Function msl_print_assignment() doesn't currently handle bitcasts
when the left operand has a specific (rather than a union) type.

We could also fix the function, and maybe it wouldn't be a bad
idea anyway, but using the union type seems more in the spirit
of the MSL backend anyway.
2025-07-28 16:27:58 +02:00
Giovanni Mascellani
16b06c295b vkd3d-shader/msl: Emit indexable temps with the appropriate component count. 2025-07-28 16:27:58 +02:00
Giovanni Mascellani
6ed0bd0bab vkd3d-shader/msl: Ignore the interpolation mode for output variables.
They are meaningless, but some frontends (e.g., DXIL) set them
nevertheless.
2025-07-28 16:27:58 +02:00
Francisco Casas
19bc3ec104 vkd3d-shader/ir: Validate flags in RESINFO operations. 2025-07-28 16:26:16 +02:00
Francisco Casas
3a0a96b851 vkd3d-shader/ir: Validate flags in SAMPLE_INFO operations. 2025-07-28 16:26:16 +02:00
Nikolay Sivov
a4f5225229 vkd3d: Return success from d3d12_device_EnumerateMetaCommands().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-07-28 16:24:04 +02:00
Nikolay Sivov
2c49f04411 vkd3d-shader/fx: Do not attempt to parse expressions without code section. 2025-07-28 16:22:13 +02:00
Nikolay Sivov
dcd1747f12 vkd3d-shader/fx: Handle regular shader blobs when parsing the state data.
For the pass shader states this blob will contain compiled shaders, for other
state types it will contain expression code. Complex state data is stored separately,
tracing it back to actual state type will require keeping track of already parsed states.
2025-07-28 16:21:32 +02:00
Henri Verbeet
0652cb4adb demos/teapot: Add specular lighting. 2025-07-28 16:12:19 +02:00
Henri Verbeet
9b0087a111 vkd3d-shader/spirv: Emit OpLine instructions. 2025-07-28 16:11:29 +02:00
Henri Verbeet
b3cac7b86d vkd3d-shader: Call vsir_program_scan() for d3d-asm targets in vsir_program_compile().
Like we do for every other target.
2025-07-28 16:11:06 +02:00
Henri Verbeet
eaebef4265 vkd3d-shader/hlsl: Emit vsir from hlsl_emit_bytecode(). 2025-07-28 16:10:15 +02:00
Henri Verbeet
4300e6c8b5 vkd3d-shader/ir: Allow source operands of shift operations to have different data types. 2025-07-28 16:10:15 +02:00
Henri Verbeet
b3e367b099 vkd3d-shader/tpf: Update the comment describing the data type mapping in init_sm4_lookup_tables().
"R", "S", and "U" were removed, and "*" was added.
2025-07-24 19:12:49 +02:00
Henri Verbeet
a4c25b81c5 vkd3d-shader/hlsl: Get rid of the "hlsl" argument to hlsl_compile_shader(). 2025-07-23 17:25:19 +02:00
Henri Verbeet
f02405350e vkd3d-shader/ir: Consistently use VSIR_DATA_U32 for resinfo_uint destination operands.
Much like we do for sample_info_uint.
2025-07-23 17:23:40 +02:00
Henri Verbeet
b88be5b92b vkd3d-shader/ir: Consistently use VSIR_DATA_U32 for sample_info_uint destination operands.
The HLSL compiler already did this; the TPF and DXIL parsers did not.
Previously spirv_compiler_emit_sample_info() was unable to correctly
handle VSIR_DATA_U32 destinations; the new version is arguably simpler
as well.
2025-07-23 17:23:40 +02:00
Henri Verbeet
b8c73e4a2c vkd3d-shader/spirv: Use spirv_compiler_error() to report unhandled resinfo flags. 2025-07-23 17:23:40 +02:00
Henri Verbeet
ed2a06af35 vkd3d-shader/spirv: Use spirv_compiler_error() to report unhandled sample_info flags. 2025-07-23 17:23:40 +02:00
Henri Verbeet
7295a8d0b5 vkd3d-shader/ir: Explicitly initialise the "resource_data_type" field in vsir_instruction_init().
This depended on VKD3D_DATA_FLOAT/VSIR_DATA_F32 being the first
enumeration value, but that's no longer the case.
shader_dump_instruction() compares this against VSIR_DATA_F32 to
determine whether to call shader_dump_resource_data_type().
2025-07-23 17:23:01 +02:00
Henri Verbeet
795211141f vkd3d-shader/ir: Rename VKD3D_DATA_BOOL to VSIR_DATA_BOOL. 2025-07-23 17:19:28 +02:00
Henri Verbeet
aebe64ecac vkd3d-shader/ir: Rename VKD3D_DATA_UNUSED to VSIR_DATA_UNUSED. 2025-07-23 17:19:28 +02:00
Henri Verbeet
f74b56622a vkd3d-shader/ir: Rename VKD3D_DATA_CONTINUED to VSIR_DATA_CONTINUED. 2025-07-23 17:19:28 +02:00
Henri Verbeet
ca24aada9a vkd3d-shader/ir: Rename VKD3D_DATA_MIXED to VSIR_DATA_MIXED. 2025-07-23 17:19:28 +02:00
Henri Verbeet
b055a16e03 vkd3d-shader/ir: Rename VKD3D_DATA_OPAQUE to VSIR_DATA_OPAQUE. 2025-07-23 17:19:28 +02:00
Henri Verbeet
ed695cc551 vkd3d-shader/ir: Rename VKD3D_DATA_SNORM to VSIR_DATA_SNORM. 2025-07-23 17:19:28 +02:00
Henri Verbeet
ed27427508 vkd3d-shader/ir: Rename VKD3D_DATA_UNORM to VSIR_DATA_UNORM. 2025-07-23 17:19:28 +02:00
Giovanni Mascellani
2f4be1dbb6 vkd3d-shader: Use size_t in the string buffer. 2025-07-23 17:16:47 +02:00
Giovanni Mascellani
17ffd21113 vkd3d-shader/ir: Use size_t in the instruction array. 2025-07-23 17:16:43 +02:00
Giovanni Mascellani
bb51b976df vkd3d-shader/ir: Use size_t in the parameter allocator.
The idea is to, by default, use size_t for any quantity that is
a memory size or an array index.
2025-07-23 17:16:38 +02:00
Nikolay Sivov
83e54bdc0c vkd3d-shader/hlsl: Handle HLSL_RESOURCE_SAMPLE_LOD in sm1_generate_vsir_instr_resource_load().
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58063
2025-07-23 17:06:21 +02:00
Nikolay Sivov
969b6f5946 vkd3d-shader/ir: Handle TEXLDL instructions in vsir_program_lower_instructions().
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58063
2025-07-23 17:02:05 +02:00
Anna (navi) Figueiredo Gomes
a7266284ee vkd3d-shader/hlsl: Move hlsl_ir_function_decl->extern_vars to a local variable. 2025-07-23 16:56:06 +02:00
Anna (navi) Figueiredo Gomes
db80f09c7a vkd3d-shader/hlsl: Don't create a temporary copy for a uniform if one already exists.
This can currently never happen, because we only ever process each uniform
once. However, this will change once we support compiling multiple shaders
in effects.
2025-07-23 16:37:54 +02:00
Anna (navi) Figueiredo Gomes
f4d95af91d vkd3d-shader/hlsl: Add temporary variables to "dummy_scope" in prepend_uniform_copy().
These are not looked up by name, so we don't need them in a specific scope.

Moreover, since we generate the temporaries using the same storage
modifiers as the uniforms, hlsl_emit_bytecode() will treat them as new
uniforms if run multiple times. That function is currently only run
once, but this will change when compiling shaders in effects.
2025-07-23 16:33:35 +02:00
Anna (navi) Figueiredo Gomes
66895e2605 vkd3d-shader/hlsl: Reset "extern_vars" before processing "entry_func" in hlsl_emit_bytecode(). 2025-07-23 16:32:34 +02:00
Francisco Casas
844f33025e vkd3d-shader/hlsl: Dump processed function bodies. 2025-07-23 16:31:59 +02:00
Anna (navi) Figueiredo Gomes
f420e25fd5 vkd3d-shader/hlsl: Clone the entry point body and redirect processing to the clone. 2025-07-23 15:54:52 +02:00
Giovanni Mascellani
68cd72c7fc vkd3d-shader/ir: Validate ROUND_NI instructions. 2025-07-22 17:11:51 +02:00
Giovanni Mascellani
b3db78e3c1 vkd3d-shader/ir: Validate ROUND_NE instructions. 2025-07-22 17:11:51 +02:00
Giovanni Mascellani
f3f8056800 vkd3d-shader/ir: Validate RCP instructions. 2025-07-22 17:11:51 +02:00
Giovanni Mascellani
59738c7a4a vkd3d-shader/ir: Validate ORD instructions. 2025-07-22 17:11:51 +02:00
Giovanni Mascellani
6266f89827 vkd3d-shader/ir: Validate OR operations. 2025-07-22 17:11:51 +02:00
Giovanni Mascellani
1c7c66912b vkd3d-shader/ir: Validate NOT operations. 2025-07-22 17:11:51 +02:00
Giovanni Mascellani
4789295e91 vkd3d-shader/ir: Validate NEU operations. 2025-07-22 17:11:51 +02:00
Giovanni Mascellani
3234c428b3 vkd3d-shader/ir: Validate NEO operations. 2025-07-22 17:11:50 +02:00
Giovanni Mascellani
14ee6b86e0 vkd3d-shader/d3dbc: Use iterators in d3dbc_write_program_instructions(). 2025-07-22 17:11:19 +02:00
Giovanni Mascellani
4a1ca99cba vkd3d-shader/d3dbc: Use vsir_program_append() in d3dbc_parse(). 2025-07-22 17:11:19 +02:00
Giovanni Mascellani
42f53c82f3 vkd3d-shader/d3d-asm: Use iterators in d3d_asm_compile(). 2025-07-22 17:11:13 +02:00
Giovanni Mascellani
ddb65aac35 vkd3d-shader/glsl: Use iterators in vkd3d_glsl_generator_generate(). 2025-07-22 17:01:04 +02:00
Giovanni Mascellani
01068dada2 vkd3d-shader/msl: Use iterators in msl_generator_generate(). 2025-07-22 16:57:25 +02:00
Giovanni Mascellani
7d9a86790e vkd3d-shader/spirv: Use iterators in spirv_compiler_generate_spirv(). 2025-07-22 16:56:07 +02:00
Giovanni Mascellani
7e76e62db7 vkd3d-shader/tpf: Use iterators in tpf_write_program(). 2025-07-22 16:52:24 +02:00
Giovanni Mascellani
0789578175 vkd3d-shader/ir: Introduce vsir_program_append().
To append an instruction to the end of the vsir program.
2025-07-22 15:12:37 +02:00
Henri Verbeet
b4bf2af315 vkd3d-shader/ir: Consistently use VKD3D_DATA_UNUSED for STREAM registers. 2025-07-22 14:59:27 +02:00
Henri Verbeet
1487764e23 vkd3d-shader/ir: Rename VKD3D_DATA_UINT64 to VSIR_DATA_U64. 2025-07-22 14:57:26 +02:00
Henri Verbeet
742cce9a08 vkd3d-shader/ir: Rename VKD3D_DATA_UINT to VSIR_DATA_U32. 2025-07-22 14:57:26 +02:00
Henri Verbeet
163b87444f vkd3d-shader/ir: Rename VKD3D_DATA_UINT16 to VSIR_DATA_U16. 2025-07-22 14:57:26 +02:00
Henri Verbeet
40bbd61abd vkd3d-shader/ir: Rename VKD3D_DATA_UINT8 to VSIR_DATA_U8. 2025-07-22 14:57:26 +02:00
Henri Verbeet
a04e4e4010 vkd3d-shader/ir: Rename VKD3D_DATA_INT to VSIR_DATA_I32. 2025-07-22 14:57:26 +02:00
Henri Verbeet
8f05fbc75d demos/teapot: Animate the camera. 2025-07-22 14:56:51 +02:00
Giovanni Mascellani
13c9826c30 vkd3d-shader/ir: Check that OUTSTENCILREF registers have dimension SCALAR. 2025-07-22 14:55:18 +02:00
Giovanni Mascellani
7b36453b9d vkd3d-shader/ir: Check that PRIMID registers have dimension SCALAR. 2025-07-22 14:55:18 +02:00
Giovanni Mascellani
b3c1fb6740 vkd3d-shader/ir: Check that OUTPOINTID registers have dimension SCALAR. 2025-07-22 14:55:18 +02:00
Giovanni Mascellani
dfc18781cc vkd3d-shader/ir: Check that GSINSTID registers have dimension SCALAR. 2025-07-22 14:55:18 +02:00
Giovanni Mascellani
b02c3759be vkd3d-shader/ir: Check that SAMPLEMASK registers have dimension SCALAR.
Also fix the DXIL parser to emit them accordingly.
2025-07-22 14:55:18 +02:00
Giovanni Mascellani
226afa47c4 vkd3d-shader/ir: Check that THREADID registers have dimension VEC4. 2025-07-22 14:55:18 +02:00
Elizabeth Figura
f0906e9c5c vkd3d-shader/spirv: Use left-shifted writemasks for private variables for inputs.
One of the effects of I/O normalization, when it was introduced, was to shift
the writemask of all semantics to become 0-based—e.g., to convert .yz to .xy.
It did this by modifying the shader code, but did *not* modify the signature
masks.

The SPIR-V compiler, at the time, used both the write mask on the dcl_input
instruction and the signature masks. It also, due to the requirements of the
SPIR-V format, performed the same normalization, left-shifting each mask to
become zero-based. Despite this normalization now being performed earlier in
the aforementioned VSIR pass, the handling in the SPIR-V backend was never
removed.

When 66cb2815f0 was written, I either incorrectly
assumed that the signature mask was equal to the dcl_input write mask (at least,
in any well-formed shader), or (less likely) I noticed that the discrepancy
might exist but believed that the left-shifting normalization performed by the
spirv compiler covered all cases.

In either case it turns out there is one case where the difference was not
handled by the spirv compiler either. That is the case of a varying which has
a fixup function and therefore needs a private variable, which is currently true
for the SV_VertexID, SV_InstanceID, and SV_IsFrontFace varyings.

Thus, if one of those varyings has a signature mask other than .x, we currently
copy the SPIR-V builtin value to the relevant component of the private variable,
but subsequent code will load from the .x variable due to the normalization done
by shader_src_param_io_normalise().

This fixes a regression introduced by 66cb2815f0.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57433
2025-07-22 14:51:09 +02:00
Giovanni Mascellani
decc155cca vkd3d-shader/ir: Split updating DCL_TEMPS instructions to a dedicated pass.
So that it can be used in other contexts as well. And so that
register allocation can be run also when there is no need to update
or create DCL_TEMPS instructions.
2025-07-21 12:31:08 +02:00
Giovanni Mascellani
079e989b8e vkd3d-shader/ir: Update the program TEMP count when allocating TEMP registers. 2025-07-21 12:26:10 +02:00
Giovanni Mascellani
f5cd0b4a15 vkd3d-shader/ir: Check that THREADGROUPID registers have dimension VEC4. 2025-07-21 12:23:34 +02:00
Giovanni Mascellani
59253a5e7f vkd3d-shader/ir: Check that LOCALTHREADID registers have dimension VEC4. 2025-07-21 12:23:34 +02:00
Giovanni Mascellani
834f762cb5 vkd3d-shader/ir: Check that DEPTHOUTLE registers have dimension SCALAR.
Also fix the DXIL parser to emit them accordingly.
2025-07-21 12:23:34 +02:00
Giovanni Mascellani
18ef9a4f9f vkd3d-shader/ir: Check that DEPTHOUTGE registers have dimension SCALAR.
Also fix the DXIL parser to emit them accordingly.
2025-07-21 12:23:34 +02:00
Giovanni Mascellani
9f453fbb66 vkd3d-shader/ir: Check that DEPTHOUT registers have dimension SCALAR.
Also fix the DXIL parser to emit them accordingly.
2025-07-21 12:23:32 +02:00
Giovanni Mascellani
3d23ef6bf8 vkd3d-shader/ir: Check that COVERAGE registers have dimension VEC4.
Also fix the HLSL compiler and DXIL parser to emit them accordingly.
2025-07-21 12:21:23 +02:00
Giovanni Mascellani
ee0447b973 vkd3d-shader/ir: Check that LOCALTHREADINDEX registers have dimension VEC4.
Also fix the HLSL compiler and DXIL parser to emit them accordingly.
2025-07-21 12:18:49 +02:00
Giovanni Mascellani
61c46f95da vkd3d-shader/ir: Validate MUL operations. 2025-07-21 12:16:16 +02:00
Giovanni Mascellani
87545dc4fd vkd3d-shader/ir: Validate MIN operations. 2025-07-21 12:16:16 +02:00
Giovanni Mascellani
366c899a00 vkd3d-shader/ir: Validate MAX operations. 2025-07-21 12:16:16 +02:00
Giovanni Mascellani
5dd226ffeb vkd3d-shader/ir: Validate MAD operations. 2025-07-21 12:16:16 +02:00
Giovanni Mascellani
2237e251fa vkd3d-shader/ir: Validate LTU operations. 2025-07-21 12:16:16 +02:00
Giovanni Mascellani
34cb8c63f4 vkd3d-shader/ir: Validate LTO operations. 2025-07-21 12:16:14 +02:00
Giovanni Mascellani
a8e8a9ee64 vkd3d-shader/ir: Validate LOG operations. 2025-07-21 12:14:22 +02:00
Henri Verbeet
db149cd8cf vkd3d-shader/ir: Rename VKD3D_DATA_DOUBLE to VSIR_DATA_F64. 2025-07-21 12:10:43 +02:00
Henri Verbeet
c5c1c03430 vkd3d-shader/ir: Rename VKD3D_DATA_FLOAT to VSIR_DATA_F32. 2025-07-21 12:10:43 +02:00
Henri Verbeet
d1dcbc26e5 vkd3d-shader/ir: Rename VKD3D_DATA_HALF to VSIR_DATA_F16. 2025-07-21 12:10:43 +02:00
Henri Verbeet
0126beb3b2 vkd3d-shader/ir: Rename enum vkd3d_data_type to vsir_data_type. 2025-07-21 12:10:43 +02:00
Henri Verbeet
53dd048ad5 demos/teapot: Add a flat shading toggle. 2025-07-21 12:09:44 +02:00
Giovanni Mascellani
8d4222764c vkd3d-shader/ir: Use the iterator in vsir_program_lower_texldp(). 2025-07-21 12:07:08 +02:00
Giovanni Mascellani
5407c8b975 vkd3d-shader/ir: Use the iterator in vsir_program_lower_sm4_sincos(). 2025-07-21 12:07:08 +02:00
Giovanni Mascellani
55b8002bf6 vkd3d-shader/ir: Use the iterator in vsir_program_lower_sm1_sincos(). 2025-07-21 12:06:46 +02:00
Giovanni Mascellani
c1f7720075 vkd3d-shader/ir: Use the iterator in vsir_program_lower_udiv(). 2025-07-21 12:02:57 +02:00
Francisco Casas
0f18d25987 tests: Test semantic cascading signatures. 2025-07-21 11:57:01 +02:00
Francisco Casas
faeff50548 tests/hlsl: Add additional semantic cascading tests.
These test make the shader runner segfault before implementing it,
because it miscompiles and there are unused input layout elements.
So they are on their own commit.
2025-07-21 11:57:01 +02:00
Francisco Casas
a9a5c77222 vkd3d-shader/hlsl: Make input semantics on structs cascade down onto the fields. 2025-07-21 11:57:01 +02:00
Francisco Casas
7e9834ee36 vkd3d-shader/hlsl: Make output semantics on structs cascade down onto the fields. 2025-07-21 11:57:00 +02:00
Francisco Casas
f08fed5ffb vkd3d-shader/hlsl: Don't pass the semantic index in add_semantic_var(). 2025-07-21 11:57:00 +02:00
Francisco Casas
28f74a73aa vkd3d-shader/hlsl: Use the index in the hlsl_semantic when prepending input copies. 2025-07-21 11:57:00 +02:00
Francisco Casas
4f5d34265c vkd3d-shader/hlsl: Use the index in the hlsl_semantic when appending output copies. 2025-07-21 11:55:57 +02:00
Francisco Casas
9836c88ac6 tests/hlsl: Add semantic cascading tests.
Co-authored-by: Petrichor Park <ppark@codeweavers.com>
2025-07-21 11:20:14 +02:00
Giovanni Mascellani
7e66d0db6f vkd3d-shader/ir: Do not print a message for registers that are not being allocated. 2025-07-17 14:11:01 +02:00
Giovanni Mascellani
e9d3b9dfd3 vkd3d-shader/ir: Set dimension to VEC4 when converting SSAs to TEMPs. 2025-07-17 14:11:01 +02:00
Giovanni Mascellani
a7807dea08 vkd3d-shader/ir: Validate FTOU operations. 2025-07-17 14:08:10 +02:00
Giovanni Mascellani
ccc82a184b vkd3d-shader/ir: Validate FTOI operations. 2025-07-17 14:08:10 +02:00
Giovanni Mascellani
2c1d210d21 vkd3d-shader/ir: Validate ITOI operations. 2025-07-17 14:08:10 +02:00
Giovanni Mascellani
791a93d0b1 vkd3d-shader/ir: Validate ITOF operations. 2025-07-17 14:08:10 +02:00
Giovanni Mascellani
68ad2becdb vkd3d-shader/ir: Validate ISNAN operations. 2025-07-17 14:08:10 +02:00
Giovanni Mascellani
fb1fc9eb38 vkd3d-shader/ir: Validate ISINF operations. 2025-07-17 14:08:10 +02:00
Giovanni Mascellani
df18a05303 vkd3d-shader/ir: Validate ISFINITE operations. 2025-07-17 14:08:10 +02:00
Giovanni Mascellani
b287e7959c vkd3d-shader/ir: Sort vsir_validator_instructions[] alphabetically. 2025-07-17 14:08:06 +02:00
Giovanni Mascellani
195e62430e vkd3d-shader/ir: Use the iterator in vsir_program_lower_precise_mad(). 2025-07-17 14:04:28 +02:00
Giovanni Mascellani
a12d64fba1 vkd3d-shader/ir: Use the iterator in vsir_program_lower_texkill(). 2025-07-17 14:04:28 +02:00
Giovanni Mascellani
9867d48c3a vkd3d-shader/ir: Use the iterator in vsir_program_lower_ifc(). 2025-07-17 14:04:28 +02:00
Giovanni Mascellani
2d848b5bc0 vkd3d-shader/ir: Introduce an abstraction to iterate through vsir instructions. 2025-07-17 14:04:00 +02:00
Giovanni Mascellani
ba545669cd vkd3d-shader/ir: Validate ISHR operations. 2025-07-16 18:07:26 +02:00
Giovanni Mascellani
126ff8e4f5 vkd3d-shader/ir: Validate ISHL operations. 2025-07-16 18:07:26 +02:00
Giovanni Mascellani
94d999bd8a vkd3d-shader/ir: Validate IREM operations. 2025-07-16 18:07:26 +02:00
Giovanni Mascellani
636e9a91bb vkd3d-shader/ir: Validate INEG operations. 2025-07-16 18:07:26 +02:00
Giovanni Mascellani
7d92142fe0 vkd3d-shader/ir: Validate INE operations. 2025-07-16 18:07:26 +02:00
Giovanni Mascellani
d288d3c088 vkd3d-shader/ir: Validate IMIN operations. 2025-07-16 18:07:26 +02:00
Giovanni Mascellani
2a62b7035c vkd3d-shader/ir: Validate IMAX operations. 2025-07-16 18:07:26 +02:00
Giovanni Mascellani
5fc8baabfb vkd3d-shader/ir: Validate IMAD operations. 2025-07-16 18:07:26 +02:00
Giovanni Mascellani
56247130c1 vkd3d-shader/ir: Validate UAV flags in vsir programs. 2025-07-16 17:44:13 +02:00
Giovanni Mascellani
32bf71ba96 vkd3d-shader/ir: Validate descriptor flags in vsir programs. 2025-07-16 17:34:35 +02:00
Evan Tang
9c040caa40 vkd3d: Get rid of the default fragment shader from d3d12_pipeline_state_init_graphics().
Vulkan does support rendering without a fragment shader, and this seems
to work fine on current drivers. This commit gets rid of the last
embedded shader binary in libvkd3d, and may have a slight performance
advantage on hardware/drivers able to take advantage of the absence of a
fragment shader.
2025-07-16 17:30:11 +02:00
Evan Tang
5c0e6747b8 tests/d3d12: Add a colour attachment to test_draw_depth_no_ps().
To show that draws without fragment shader should leave colour
attachments unmodified.
2025-07-16 17:28:43 +02:00
Evan Tang
39db6731c0 vkd3d: Mask colour writes on graphics pipelines without fragment shaders.
Vulkan leaves the contents of colour attachments undefined in this case.
2025-07-16 16:54:55 +02:00
Nikolay Sivov
3163e589bc vkd3d-shader/fx: Explicitly handle bool state values when parsing.
For bools 0/1 values are treated as named values, outside of this
range it's zero/non-zero.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-07-14 18:38:21 +02:00
Nikolay Sivov
46c75137c7 vkd3d-shader/fx: Use the correct value range for bools in fx_4_0 state values.
The earlier fix a06ecb6867 is missing this.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-07-14 18:38:21 +02:00
Giovanni Mascellani
1a5a2969be vkd3d/resource: Write null descriptors with their correct type when using mutable descriptor types.
This fixes crashes in test_null_srv() and test_null_uav() with
llvmpipe and NVIDIA GPUs.
2025-07-14 18:37:13 +02:00
Giovanni Mascellani
fb91bd7b8b vkd3d: Move vkd3d_vk_descriptor_set_index_from_vk_descriptor_type() to resource.c.
It's only used there.
2025-07-14 18:36:35 +02:00
Nikolay Sivov
fc77bddb9c vkd3d-shader/fx: Improve register naming in the disassembly output.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-07-14 18:29:10 +02:00
Giovanni Mascellani
15561c1e56 vkd3d-shader/ir: Do not make a local copy of the instructions array in vsir_program_flatten_hull_shader_phases(). 2025-07-14 18:25:24 +02:00
Giovanni Mascellani
44ca7b7b1b vkd3d-shader/ir: Handle SSA registers when flattening hull shader phases.
Currently when a phase is duplicated more than once SSA registers
are not refreshed, therefore they are invalidly assigned more than
once.
2025-07-14 18:19:23 +02:00
Giovanni Mascellani
ad1aa739c2 vkd3d-shader/ir: Collect the hull shader phase flattener code together. 2025-07-14 18:19:23 +02:00
Henri Verbeet
b6725a3a00 demos/teapot: Add diffuse lighting. 2025-07-14 18:18:09 +02:00
Henri Verbeet
00f53b72a1 tests/shader_runner_gl: Implement geometry shaders. 2025-07-14 18:16:41 +02:00
Henri Verbeet
673c26a040 vkd3d-shader/msl: Implement VKD3DSGF_FORCE_EARLY_DEPTH_STENCIL. 2025-07-14 18:13:43 +02:00
Henri Verbeet
1a20395e6f vkd3d-shader/msl: Implement VSIR_OP_STORE_UAV_TYPED. 2025-07-14 18:13:43 +02:00
Henri Verbeet
955fff7570 tests/shader_runner_metal: Implement buffer textures. 2025-07-14 18:13:43 +02:00
Henri Verbeet
90b6412daa vkd3d-shader/msl: Implement VSIR_OP_UMAX and VSIR_OP_UMIN. 2025-07-14 18:13:43 +02:00
Giovanni Mascellani
ed464a4f4c vkd3d-shader/ir: Validate ILT instructions. 2025-07-14 18:12:22 +02:00
Giovanni Mascellani
715d23ebbb vkd3d-shader/ir: Validate IGE instructions. 2025-07-14 18:12:22 +02:00
Giovanni Mascellani
9f455667eb vkd3d-shader/ir: Validate IEQ instructions. 2025-07-14 18:12:22 +02:00
Giovanni Mascellani
c29e8188ff vkd3d-shader/ir: Validate IADD instructions. 2025-07-14 18:12:22 +02:00
Giovanni Mascellani
4d1fabd350 vkd3d-shader/ir: Validate HTAN instructions. 2025-07-14 18:12:22 +02:00
Giovanni Mascellani
e954f75862 vkd3d-shader/ir: Validate HSIN instructions. 2025-07-14 18:12:22 +02:00
Giovanni Mascellani
5dd452a5c7 vkd3d-shader/ir: Validate HCOS instructions. 2025-07-14 18:12:22 +02:00
Giovanni Mascellani
cc42581a34 tests/hlsl: Test uint64 comparisons. 2025-07-14 18:12:03 +02:00
Giovanni Mascellani
395d456386 tests/hlsl: Test int64 comparisons. 2025-07-14 18:10:20 +02:00
Giovanni Mascellani
98b0ca544a vkd3d-shader/ir: Test the data type when validating comparison operations.
I had forgot that bit.
2025-07-14 18:06:55 +02:00
Elizabeth Figura
0c3250122c vkd3d-shader/spirv: Do not use OpCopyMemory for partial writemasks in spirv_compiler_emit_mov().
This fixes instructions like "mov r0.xy, r1.xyzw".
2025-06-26 17:44:34 +02:00
Elizabeth Figura
f2238deea9 tests/hlsl: Add tests for cube textures. 2025-06-26 17:40:10 +02:00
Elizabeth Figura
e312207124 tests/shader_runner: Add support for cube resources. 2025-06-26 17:38:55 +02:00
Elizabeth Figura
b58ff893a5 tests/hlsl: Add tests for 3D textures. 2025-06-26 17:32:10 +02:00
Elizabeth Figura
587c2dc76e tests/shader_runner: Add support for 3D resources. 2025-06-26 17:31:34 +02:00
Henri Verbeet
04d3996b07 demos/teapot: Add an fps counter. 2025-06-26 16:09:42 +02:00
Henri Verbeet
22ebccfeb7 vkd3d-shader/ir: Create SSA values with the corresponding dimension in vsir_program_lower_udiv(). 2025-06-26 16:08:32 +02:00
Henri Verbeet
043f6f21b0 vkd3d-shader/ir: Create SSA values with the corresponding dimension in vsir_program_lower_sm4_sincos().
For example, in the final test from trigonometry.shader_test, we have:

    sincos r1.x <v4:float>, null <float>, l(3.00000000e+01) <s:float>

which currently gets turned into

    mov sr0.xyzw <v4:float>, l(3.00000000e+01) <s:float>
    sin r1.x <v4:float>, sr0.xyzw <v4:float>

That doesn't seem ideal, and should possibly be rejected by the
validator, but ends up working out well enough for the SPIR-V backend.
It's a bit more problematic to deal with for the GLSL backend.
2025-06-26 16:02:38 +02:00
Francisco Casas
96cd4cc954 vkd3d-shader/ir: Avoid a compiler warning in vsir_block_list_init().
The following warning appears during compilation with
gcc 15.1.1 20250425:

  In function 'vsir_block_list_init',
      inlined from 'vsir_block_init' at vkd3d/libs/vkd3d-shader/ir.c:3821:5,
      inlined from 'vsir_cfg_init' at vkd3d/libs/vkd3d-shader/ir.c:4285:28:
  vkd3d/libs/vkd3d-shader/ir.c:3758:5: warning: 'memset' writing 24 bytes into a region of size 0 overflows the destination [-Wstringop-overflow=]
   3758 |     memset(list, 0, sizeof(*list));
        |     ^
  In function 'vsir_cfg_init':
  lto1: note: destination object is likely at address zero

looking at the code in vsir_cfg_init() this seems like an spurious
warning. Looking on the internet, these bogus warnings with memset()
seem to be a common occurrence.

memset() is replaced with a zero value assignment to avoid this.
2025-06-26 15:56:43 +02:00
Francisco Casas
3376015d88 vkd3d-shader/hlsl: Update the enum hlsl_sampler_dim comment. 2025-06-26 15:55:58 +02:00
Giovanni Mascellani
3c469edc8e vkd3d-shader/ir: Validate GEU instructions. 2025-06-25 16:53:19 +02:00
Giovanni Mascellani
e267ea9551 vkd3d-shader/ir: Validate GEO instructions. 2025-06-25 16:52:28 +02:00
Giovanni Mascellani
8feeb07900 vkd3d-shader/ir: Validate FREM instructions. 2025-06-25 16:51:58 +02:00
Giovanni Mascellani
32cab7c81e vkd3d-shader/ir: Validate FRC instructions. 2025-06-25 16:51:02 +02:00
Giovanni Mascellani
afec7cc96b vkd3d-shader/ir: Validate EXP instructions. 2025-06-25 16:50:03 +02:00
Giovanni Mascellani
8cf7a12502 vkd3d-shader/ir: Validate EQU instructions. 2025-06-25 16:48:45 +02:00
Giovanni Mascellani
a6e6e36994 vkd3d-shader/ir: Validate DEQO instructions. 2025-06-25 16:47:52 +02:00
Giovanni Mascellani
17b0e0d1d9 vkd3d-shader/ir: Validate EQO instructions. 2025-06-25 16:46:59 +02:00
Giovanni Mascellani
596f02210d vkd3d-shader/ir: Lower UDIV to UDIV_SIMPLE and UREM. 2025-06-25 16:44:00 +02:00
Giovanni Mascellani
82ef9bf2e5 vkd3d-shader/ir: Introduce VSIR_OP_UREM.
It is meant to compute the unsigned integer remainder.
2025-06-25 16:43:34 +02:00
Giovanni Mascellani
78e0f8412d vkd3d-shader/ir: Introduce VSIR_OP_UDIV_SIMPLE.
It is meant to compute the unsigned integer division, without
computing the modulo at the same time.
2025-06-25 16:40:43 +02:00
Giovanni Mascellani
ada09d003d vkd3d-shader/ir: Repurpose IDIV to compute plain signed division.
It doesn't compute signed remainder any more.
2025-06-25 16:39:50 +02:00
Giovanni Mascellani
823a8724de vkd3d-shader/ir: Introduce VSIR_OP_IREM.
It is meant to compute the signed integer remainder.
2025-06-25 16:38:38 +02:00
Evan Tang
f4a4e2afec vkd3d: Replace the resource count field of struct d3d12_heap with an internal refcount.
When a heap was released at the same time as the last resource on that
heap, it was possible for both to see each other's
refcount/resource_count as 0 and both would try to destroy the heap.

Avoid that by converting "resource_count" to an internal refcount, which
holds an extra +1 if the main refcount is nonzero. The final release
will then be synchronized between the two since both will operate on
"internal_refcount".
2025-06-25 16:06:49 +02:00
Henri Verbeet
752a48f4ac vkd3d-shader/msl: Implement VSIR_OP_IMAX. 2025-06-25 16:00:34 +02:00
Henri Verbeet
543ee120fc vkd3d-shader/msl: Implement VSIR_OP_DSX_FINE and VSIR_OP_DSY_FINE. 2025-06-25 16:00:31 +02:00
Henri Verbeet
b9ce945e61 vkd3d-shader/msl: Implement VSIR_OP_DSX_COARSE and VSIR_OP_DSY_COARSE. 2025-06-25 16:00:27 +02:00
Henri Verbeet
06a0453762 vkd3d-shader/msl: Implement VSIR_OP_DSX and VSIR_OP_DSY. 2025-06-25 16:00:22 +02:00
Henri Verbeet
cdfaeb209a vkd3d-shader/msl: Implement VSIR_OP_CONTINUE. 2025-06-25 16:00:15 +02:00
Henri Verbeet
d219cccc99 vkd3d-shader/ir: Rename the VKD3DSIH_* enum elements to VSIR_OP_*. 2025-06-25 15:53:41 +02:00
Elizabeth Figura
cd43ab1ca2 vkd3d-shader/ir: Allow bitwise operations on VKD3D_DATA_INT. 2025-06-25 15:46:39 +02:00
Elizabeth Figura
bcb2acbdab vkd3d-shader/hlsl: Set the destination data type to UINT in sm4_generate_vsir_cast_from_bool().
Validation checks that the source and destination types are both integer.
2025-06-25 15:46:27 +02:00
Elizabeth Figura
a1eb53df3c vkd3d-shader/hlsl: Set the data type in sm4_generate_vsir_reg_from_deref(). 2025-06-25 15:43:15 +02:00
Elizabeth Figura
ecb19b33ba vkd3d-shader/hlsl: Output sm1 semantics with unique register_index values.
Match the register_index values from the d3dbc reader.
2025-06-25 15:43:15 +02:00
Elizabeth Figura
41cacba5ce vkd3d-shader/hlsl: Convert descriptor registers to pre-5.1 form in the TPF writer.
Rather than in the HLSL writer. This way we output vsir consistent with the vsir
we read, and the vsir that the backends expect [bringing us one step closer to
being able to feed the HLSL frontend directly into the individual backends.]
2025-06-25 15:42:51 +02:00
Giovanni Mascellani
3a4f95aca6 vkd3d-shader/ir: Do not crash when registers cannot be resolved to signature elements. 2025-06-25 15:40:12 +02:00
Elizabeth Figura
5452e79a19 vkd3d-shader/d3d-asm: Handle INT_MIN in shader_print_int_literal(). 2025-06-24 15:51:31 +02:00
Henri Verbeet
c2a01fff1e vkd3d-shader/msl: Implement support for static texel offsets in msl_sample(). 2025-06-24 15:32:59 +02:00
Henri Verbeet
6f8ce6df72 vkd3d-shader/msl: Implement VKD3DSIH_GATHER4_PO. 2025-06-24 15:32:59 +02:00
Henri Verbeet
449804623a vkd3d-shader/msl: Implement VKD3DSIH_GATHER4_C. 2025-06-24 15:32:59 +02:00
Henri Verbeet
841cf65a41 vkd3d-shader/msl: Implement VKD3DSIH_GATHER4. 2025-06-24 15:32:59 +02:00
Henri Verbeet
3cc404759d vkd3d-shader/msl: Implement VKD3DSIH_SAMPLE_LOD. 2025-06-24 15:32:59 +02:00
Giovanni Mascellani
99db7270f0 vkd3d-shader/ir: Validate DSY_FINE instructions. 2025-06-24 15:31:39 +02:00
Giovanni Mascellani
cbd508fce6 vkd3d-shader/ir: Validate DSY_COARSE instructions. 2025-06-24 15:31:39 +02:00
Giovanni Mascellani
7acebfc978 vkd3d-shader/ir: Validate DSY instructions. 2025-06-24 15:31:39 +02:00
Giovanni Mascellani
6bf25800c2 vkd3d-shader/ir: Validate DSX_FINE instructions. 2025-06-24 15:31:39 +02:00
Giovanni Mascellani
95e095992d vkd3d-shader/ir: Validate DSX_COARSE instructions. 2025-06-24 15:31:39 +02:00
Giovanni Mascellani
96bb2953cc vkd3d-shader/ir: Validate DSX instructions. 2025-06-24 15:31:39 +02:00
Giovanni Mascellani
ad320776a1 vkd3d-shader/ir: Validate DRCP instructions. 2025-06-24 15:31:39 +02:00
Giovanni Mascellani
19c2734d31 vkd3d-shader/ir: Validate DNE instructions. 2025-06-24 15:31:39 +02:00
Giovanni Mascellani
bcaa1d50b0 vkd3d-shader/ir: Validate data types for destination shifts. 2025-06-24 15:28:00 +02:00
Giovanni Mascellani
1862c28b90 vkd3d-shader/ir: Validate data types for SATURATE destination modifiers. 2025-06-24 15:27:48 +02:00
Giovanni Mascellani
318d7466a8 vkd3d-shader/ir: Validate data types for NOT source modifiers. 2025-06-24 15:27:38 +02:00
Giovanni Mascellani
65c23999e8 vkd3d-shader/ir: Validate data types for ABSNEG source modifiers. 2025-06-24 15:27:29 +02:00
Giovanni Mascellani
0252e2e660 vkd3d-shader/ir: Validate data types for ABS source modifiers. 2025-06-24 15:27:02 +02:00
Henri Verbeet
85dcbf7a51 demos/teapot: Add on-screen help. 2025-06-24 15:24:16 +02:00
Giovanni Mascellani
31581b0002 vkd3d-shader/ir: Lower IMUL and UMUL to IMUL_LOW. 2025-06-24 15:21:13 +02:00
Giovanni Mascellani
4a39db797b vkd3d-shader/ir: Introduce VKD3DSIH_IMUL_LOW.
It is meant to compute the lower word of an integer multiplication.
2025-06-24 15:15:56 +02:00
Shaun Ren
f3dec58423 vkd3d-shader/hlsl: Ignore the 'groupshared' modifier for non-compute shaders. 2025-06-24 14:54:25 +02:00
Shaun Ren
4ede2f1365 vkd3d-shader/hlsl: Allow memory barriers in SM4+ target profiles. 2025-06-24 14:51:34 +02:00
Shaun Ren
84a0a8ae86 vkd3d-shader/hlsl: Handle nodes with NULL data types in hlsl_replace_node(). 2025-06-24 14:50:43 +02:00
Shaun Ren
3bf232e841 vkd3d-shader/hlsl: Only dump store writemasks for single register types.
This fixes a segfault on matrix stores in dump_ir_store().
2025-06-24 14:50:21 +02:00
Conor McCarthy
d8edf20c2b vkd3d-shader/dxil: Convert constant buffer minimum-precision source registers. 2025-06-23 20:12:31 +02:00
Conor McCarthy
dda2ec1814 vkd3d-shader/ir: Allow constant buffer loads to have a minimum precision.
DXIL constant buffer loads can have precision modifiers.
2025-06-23 20:07:53 +02:00
Shaun Ren
b8cbe03308 vkd3d-shader/hlsl: Remove a leftover TODO message.
The max output size check for stream outputs is done via
validate_max_output_size().
2025-06-23 18:29:27 +02:00
Nikolay Sivov
ba5d5a8091 vkd3d-shader/fx: Fix the order of the "MaterialDiffuse" and "MaterialAmbient" state entries.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-06-23 18:28:41 +02:00
Nikolay Sivov
92c711a7d5 vkd3d-shader/fx: Add a format-specific callback to write state assignments.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-06-23 18:27:11 +02:00
Nikolay Sivov
3537feb45c vkd3d-shader/fx: Move entry count updates out of the state block writing helper.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-06-23 18:17:48 +02:00
Nikolay Sivov
43a29044d6 vkd3d-shader/fx: Move state decomposition to the fx_4_0-specific writing path.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-06-23 18:16:17 +02:00
Nikolay Sivov
9f9cf59b6e vkd3d-shader/fx: Use the same state data helpers for both fx_2_0 and fx_4+.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-06-23 18:12:27 +02:00
Nikolay Sivov
99d61aeb89 vkd3d-shader/fx: Use a version-independent structure for states.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-06-23 18:12:27 +02:00
Giovanni Mascellani
f6af47f9b6 vkd3d-shader/ir: Validate data types for DW source modifiers. 2025-06-23 18:11:22 +02:00
Giovanni Mascellani
bc4dda75dd vkd3d-shader/ir: Validate data types for DZ source modifiers. 2025-06-23 18:11:12 +02:00
Giovanni Mascellani
6ef23544f4 vkd3d-shader/ir: Validate data types for X2NEG source modifiers. 2025-06-23 18:11:01 +02:00
Giovanni Mascellani
2d783da3a7 vkd3d-shader/ir: Validate data types for X2 source modifiers. 2025-06-23 18:10:50 +02:00
Giovanni Mascellani
eec2b13dc6 vkd3d-shader/ir: Validate data types for COMP source modifiers. 2025-06-23 18:10:25 +02:00
Giovanni Mascellani
a115cd9ec0 vkd3d-shader/ir: Validate DMUL instructions. 2025-06-23 18:07:09 +02:00
Giovanni Mascellani
402c2bf10a vkd3d-shader/ir: Validate DMOV instructions. 2025-06-23 18:07:09 +02:00
Giovanni Mascellani
32746c664d vkd3d-shader/ir: Validate DMIN instructions. 2025-06-23 18:07:09 +02:00
Giovanni Mascellani
2f4038bae7 vkd3d-shader/ir: Validate DMAX instructions. 2025-06-23 18:07:09 +02:00
Giovanni Mascellani
bd4681622d vkd3d-shader/ir: Validate DLT instructions. 2025-06-23 18:07:09 +02:00
Giovanni Mascellani
dc33622919 vkd3d-shader/ir: Validate DIV instructions. 2025-06-23 18:07:09 +02:00
Giovanni Mascellani
666eb98ab6 vkd3d-shader/ir: Validate DGEO instructions. 2025-06-23 18:06:20 +02:00
Giovanni Mascellani
227df56c6c vkd3d-shader/ir: Validate DFMA instructions. 2025-06-23 18:00:55 +02:00
Giovanni Mascellani
2b922e6b8e vkd3d-shader/ir: Validate DDIV instructions. 2025-06-23 18:00:55 +02:00
Giovanni Mascellani
ead690a17a vkd3d-shader/ir: Validate DADD instructions. 2025-06-23 18:00:55 +02:00
Henri Verbeet
be2c8041d0 vkd3d-shader/d3dbc: Use TAG_CTAB in d3dbc_compile(). 2025-06-23 18:00:34 +02:00
Henri Verbeet
e5bf48a2ba vkd3d-shader/spirv: Do not require VKD3D_SHADER_BINDING_FLAG_IMAGE for sampler descriptors. 2025-06-23 18:00:10 +02:00
Francisco Casas
83979ec07a tests/hlsl: Fix up point-sprite.shader_test.
Write the shaders so that texcoord's register index in the vertex output
signature matches the register index in the pixel input signature
(o0 and v0 in this case) in SM4.
2025-06-23 17:59:20 +02:00
Francisco Casas
2e0cbff3a0 vkd3d-shader/hlsl: Allocate return variables before other outputs.
point-sprite.shader_test is not technically well formed since, in SM4,
the vertex output signature should be:

// Output signature:
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// sv_position              0   xyzw        0      POS   float   xyzw
// texcoord                 0   xy          1     NONE   float   xy

and the pixel input signature should be:

// Input signature:
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// texcoord                 0   xy          0     NONE   float   xy

so we are not passing "texcoord" properly to the pixel shader, even on
Windows.
2025-06-23 17:56:40 +02:00
Francisco Casas
e0359c5299 tests/hlsl: Test the allocation order of return semantics. 2025-06-23 17:53:03 +02:00
Francisco Casas
cf726cf521 tests/shader_runner_d3d12: Handle the "bug" qualifier on state creation failure. 2025-06-23 17:50:37 +02:00
Henri Verbeet
46265061c3 vkd3d-shader/msl: Implement VKD3DSIH_SAMPLE_GRAD. 2025-06-23 17:48:07 +02:00
Henri Verbeet
db89687807 vkd3d-shader/msl: Implement VKD3DSIH_SAMPLE_C_LZ 2025-06-23 17:48:07 +02:00
Henri Verbeet
f30510a9b3 vkd3d-shader/msl: Implement VKD3DSIH_SAMPLE_C. 2025-06-23 17:48:07 +02:00
Henri Verbeet
0c8bc0f42c vkd3d-shader/msl: Implement VKD3DSIH_SAMPLE_B. 2025-06-23 17:48:07 +02:00
Henri Verbeet
af8b3f94e7 vkd3d-shader/msl: Implement VKD3DSIH_SAMPLE. 2025-06-23 17:48:07 +02:00
Elizabeth Figura
d5237ec1cc vkd3d-shader/hlsl: Output SSA registers where possible. 2025-06-23 17:44:11 +02:00
Elizabeth Figura
288020bce8 vkd3d-shader/ir: Allocate SSA registers to temps. 2025-06-23 17:39:12 +02:00
Elizabeth Figura
7b9d04fff8 vkd3d-shader/ir: Track liveness in the SSA allocator. 2025-06-23 17:34:28 +02:00
Elizabeth Figura
5e4c61eba6 vkd3d-shader/ir: Introduce a stub SSA to temp allocation pass. 2025-06-23 17:32:59 +02:00
Elizabeth Figura
34dbd60e01 vkd3d-shader/hlsl: Add a register type field to struct hlsl_reg.
This will be used for temps. After moving temp allocation to vsir, some of these
will be VKD3DSPR_SSA, and some will not.
2025-06-23 17:28:40 +02:00
Conor McCarthy
9d490b83d4 vkd3d-shader/dxil: Add a null check for the type when validating non-void operands. 2025-06-19 20:45:28 +02:00
Conor McCarthy
c3110d2f94 vkd3d-shader/dxil: Check the destination value is invalid after calling a void function handler. 2025-06-19 20:45:28 +02:00
Conor McCarthy
a410c448ce vkd3d-shader/dxil: Validate the function return type after calling the handler.
The handler writes the destination value.
2025-06-19 20:44:54 +02:00
Nikolay Sivov
f135f7fe07 vkd3d-shader/hlsl: Add a stub for the noise() intrinsic.
This function is used in tx_1_0 code, but is also supported in
fx_2_0 and fx_4_0 expressions.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-06-19 20:36:27 +02:00
Giovanni Mascellani
93e1a8c784 vkd3d-shader/ir: Lower tpf SINCOS to the new COS and SIN instructions. 2025-06-19 20:33:09 +02:00
Giovanni Mascellani
37c2f709d1 vkd3d-shader/ir: Lower d3dbc SINCOS to the new COS and SIN instructions. 2025-06-19 20:32:55 +02:00
Giovanni Mascellani
6f092fb84a vkd3d-shader/ir: Introduce opcode SIN.
It is meant to compute sine.
2025-06-19 20:32:50 +02:00
Giovanni Mascellani
322f2e5496 vkd3d-shader/ir: Introduce opcode COS.
It is meant to compute cosine, and gradually replace SINCOS, at
least from a certain point in the pipeline on.
2025-06-19 20:32:41 +02:00
Giovanni Mascellani
b7fbd3c0f0 vkd3d-shader/ir: Validate data types for SIGNNEG source modifiers. 2025-06-19 20:11:41 +02:00
Giovanni Mascellani
3689d3076c vkd3d-shader/ir: Validate data types for SIGN source modifiers. 2025-06-19 20:10:21 +02:00
Giovanni Mascellani
e1ca552173 vkd3d-shader/ir: Validate data types for BIASNEG source modifiers. 2025-06-19 20:08:52 +02:00
Giovanni Mascellani
b2e1c3b90a vkd3d-shader/ir: Validate data types for BIAS source modifiers. 2025-06-19 20:06:35 +02:00
Giovanni Mascellani
eb3383b04e vkd3d-shader/ir: Validate data types for NEG source modifiers. 2025-06-19 20:03:17 +02:00
Giovanni Mascellani
46fac7f264 tests: Add a test for the partial precision destination modifier. 2025-06-19 19:48:56 +02:00
Giovanni Mascellani
4da83fe83b vkd3d-shader/ir: Validate ATAN instructions. 2025-06-19 19:28:42 +02:00
Giovanni Mascellani
813021e60b vkd3d-shader/ir: Validate ASIN instructions. 2025-06-19 19:28:42 +02:00
Giovanni Mascellani
16e142465c vkd3d-shader/ir: Validate AND instructions. 2025-06-19 19:28:41 +02:00
Giovanni Mascellani
0edd654c9e vkd3d-shader/ir: Validate ADD instructions. 2025-06-19 19:24:36 +02:00
Giovanni Mascellani
475e16b87f vkd3d-shader/ir: Validate ACOS instructions. 2025-06-19 19:24:36 +02:00
Giovanni Mascellani
65e896fd60 vkd3d-shader/ir: Validate ABS instructions. 2025-06-19 19:24:06 +02:00
Henri Verbeet
5911e410a8 demos/teapot: Add a tessellation demo. 2025-06-18 15:51:11 +02:00
Henri Verbeet
d572f4ac1f vkd3d: Use the DXBC checksum to construct a shader source name. 2025-06-18 15:50:18 +02:00
Henri Verbeet
cef3e07e3d vkd3d-shader/spirv: Emit an OpSource instruction with the source name. 2025-06-18 15:50:18 +02:00
Giovanni Mascellani
8b78747629 vkd3d-shader/dxil: Emit 16-bit UNDEFINED and INVALID values as minimum precision registers. 2025-06-18 15:48:55 +02:00
Giovanni Mascellani
b05153e6f9 vkd3d-shader/dxil: Emit 16-bit GROUPSHAREDMEM values as minimum precision registers. 2025-06-18 15:48:55 +02:00
Giovanni Mascellani
39603f4bc2 vkd3d-shader/dxil: Emit 16-bit structured TGSMs as minimum precision. 2025-06-18 15:48:55 +02:00
Giovanni Mascellani
5e1c8056ae vkd3d-shader/dxil: Emit 16-bit raw TGSMs as minimum precision. 2025-06-18 15:48:55 +02:00
Giovanni Mascellani
7c0da1747a vkd3d-shader/dxil: Allow constant zero values to be floating point.
This fixes commit 59fb3a7893, where
the floating point alternative was mistakenly ignored.
2025-06-16 17:41:20 +02:00
Nikolay Sivov
d08673bad1 vkd3d-shader/d3dbc: Use the actual instruction length in d3dbc_write_instruction().
The current calculation doesn't take indirect addressing into account.
This issue is easy to spot in disassembly, when we don't skip correctly
to the next instruction. On Windows the disassembler does not depend on
this it seems and skips naturally after processing all parameters that
may or may not use indirect addressing.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-06-16 17:35:37 +02:00
Nikolay Sivov
7281f4ed39 vkd3d-shader/fx: Add support for tx -> text output.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-06-16 16:19:47 +02:00
Nikolay Sivov
586b2b5a79 vkd3d-shader/fx: Add the "noise" opcode name.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-06-16 16:07:35 +02:00
Nikolay Sivov
e28af05957 vkd3d-shader/fx: Output indirect register access in arguments.
This uses the notation from Wine's d3dx9 effects runtime implementation.
Indirect addressing in fx_4_0 looks pretty much broken - it compiles
to something that produces non-sensical text disassembly and fails
runtime effect creation.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-06-16 16:06:41 +02:00
Nikolay Sivov
3f6013ea27 vkd3d-shader/fx: Output value expressions for fx_2_0.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-06-16 16:04:52 +02:00
Nikolay Sivov
ddb433d552 vkd3d-shader/fx: Explicitly check all known state assignment types for fx_2_0.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-06-16 16:04:52 +02:00
Nikolay Sivov
590ea03255 vkd3d-shader/fx: Remove the unused fx_4_fxlc_argument type.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-06-16 16:04:34 +02:00
Giovanni Mascellani
bf92190924 vkd3d-shader/ir: Rename VKD3D_SHADER_ERROR_VSIR_INVALID_HANDLER to VKD3D_SHADER_ERROR_VSIR_INVALID_OPCODE.
Following the way it is currently called in the code.
2025-06-16 16:03:07 +02:00
Henri Verbeet
c3c36d8517 demos: Introduce a helper function to create a projection matrix. 2025-06-16 16:02:23 +02:00
Henri Verbeet
eb988e95e1 vkd3d-shader/spirv: Use vsir_opcode_get_name() in spirv_compiler_emit_alu_instruction(). 2025-06-16 16:01:14 +02:00
Henri Verbeet
f46c8ea03c vkd3d-shader/spirv: Use vsir_opcode_get_name() in spirv_compiler_emit_ext_glsl_instruction(). 2025-06-16 16:01:14 +02:00
Henri Verbeet
81279b763b vkd3d-shader/spirv: Use vsir_opcode_get_name() in spirv_compiler_emit_bitfield_instruction(). 2025-06-16 16:01:14 +02:00
Henri Verbeet
0778fb93df vkd3d-shader/spirv: Use vsir_opcode_get_name() in spirv_compiler_emit_comparison_instruction(). 2025-06-16 16:01:14 +02:00
Henri Verbeet
616fea0c2b vkd3d-shader/spirv: Use vsir_opcode_get_name() in spirv_compiler_emit_deriv_instruction(). 2025-06-16 16:01:14 +02:00
Henri Verbeet
a8ca1f95c5 demos: Map the Win32 A-Z keys to a-z.
Matching what we produce on XCB and macOS.
2025-06-11 20:31:34 +02:00
Henri Verbeet
229f792db6 demos: Print the GPU and platform we're running on. 2025-06-11 20:30:39 +02:00
Henri Verbeet
8eeefc2906 vkd3d-shader/spirv: Use vsir_opcode_get_name() in spirv_compiler_emit_sample(). 2025-06-11 20:28:38 +02:00
Henri Verbeet
d92ef93611 vkd3d-shader/spirv: Use vsir_opcode_get_name() in spirv_compiler_emit_atomic_instruction(). 2025-06-11 20:28:38 +02:00
Henri Verbeet
6aeb168d63 vkd3d-shader/spirv: Use vsir_opcode_get_name() in spirv_compiler_handle_instruction(). 2025-06-11 20:28:38 +02:00
Henri Verbeet
dfb3494600 vkd3d-shader/msl: Use vsir_opcode_get_name() in msl_unhandled(). 2025-06-11 20:28:38 +02:00
Henri Verbeet
a5ff884605 vkd3d-shader/ir: Use vsir_opcode_get_name() in the validator. 2025-06-11 20:28:38 +02:00
Henri Verbeet
9c2643b9f7 vkd3d-shader/msl: Implement VKD3DSIH_LD2DMS. 2025-06-11 20:27:54 +02:00
Henri Verbeet
2d90f51d57 tests/shader_runner_metal: Implement resource copies. 2025-06-11 20:27:54 +02:00
Henri Verbeet
5899d8f54b vkd3d-shader/msl: Implement VKD3DSIH_XOR. 2025-06-11 20:27:54 +02:00
Henri Verbeet
36a999e09f vkd3d-shader/msl: Implement VKD3DSIH_ULT. 2025-06-11 20:27:54 +02:00
Henri Verbeet
6a159a5565 vkd3d-shader/msl: Implement VKD3DSIH_INEG. 2025-06-11 20:27:54 +02:00
Nikolay Sivov
1913f5e6f9 vkd3d-shader/fx: Parse array selector expressions for fx_2_0.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-06-11 20:09:05 +02:00
Nikolay Sivov
90032acbcf vkd3d-shader/fx: Rename the constant argument helper to be version-neutral.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-06-11 20:08:59 +02:00
Nikolay Sivov
d403705de9 vkd3d-shader/fx: Add a helper to print literals.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-06-11 20:07:38 +02:00
Nikolay Sivov
b098af3ef8 vkd3d-shader/fx: Use more generic names for the literal constant array.
It's going to be reused for 64-bit floats too.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-06-11 20:07:25 +02:00
Nikolay Sivov
f525399545 vkd3d-shader/fx: Read instruction arguments in full before printing them.
The binary format stores destination argument after sources. Each
argument takes either 3 tokens or 5 tokens, when indexed. For simplicity
read them all first, and print destination first.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-06-11 20:04:27 +02:00
Nikolay Sivov
d6a4084321 vkd3d-shader/fx: Use a version-neutral name for the opcode table.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-06-11 18:25:42 +02:00
Nikolay Sivov
47b9316a86 vkd3d-shader/fx: Give fxlvm-specific constants a version-neutral name.
Those are reusable for fx_2_0 preshaders.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-06-11 18:21:30 +02:00
Giovanni Mascellani
94cbb333f8 vkd3d-shader/dxil: Emit 16-bit ICB values as minimum precision registers. 2025-06-11 18:20:23 +02:00
Giovanni Mascellani
0b5a96d963 vkd3d-shader/dxil: Emit 16-bit SSA values as minimum precision registers. 2025-06-11 18:20:23 +02:00
Giovanni Mascellani
73940cde73 vkd3d-shader/dxil: Emit 16-bit IDXTEMP values as minimum precision registers. 2025-06-11 18:20:23 +02:00
Giovanni Mascellani
5e86d5c21b vkd3d-shader/dxil: Emit 16-bit arrays as minimum precision types.
The type is not explicitly annotated as minimum precision, because
no backend currently cares about that bit anyway. We're still
relying on the fact that in SM 6.0 16-bit types are always
understood as minimum precision.
2025-06-11 18:20:20 +02:00
Giovanni Mascellani
1d780e1a6b vkd3d-shader/dxil: Emit 16-bit CONSTANT values as minimum precision registers. 2025-06-11 18:10:12 +02:00
Henri Verbeet
14477b1066 demos: Allow Vulkan to determine the swapchain image count.
We currently always use 3. That's not a bad choice, but doesn't take the
minImageCount/maxImageCount of the Vulkan implementation into account.
2025-06-10 17:51:15 +02:00
Henri Verbeet
cea7b4e920 tests/shader_runner: Introduce the "f32" probe format. 2025-06-10 17:49:13 +02:00
Henri Verbeet
9c987e5a0b tests/shader_runner: Introduce the "u32" probe format. 2025-06-10 17:48:19 +02:00
Henri Verbeet
95cf0a8b2c tests/shader_runner: Introduce the "i32" probe format. 2025-06-10 17:47:32 +02:00
Henri Verbeet
73820756d1 tests/shader_runner: Introduce the "f64" probe format. 2025-06-10 17:46:51 +02:00
Henri Verbeet
b09e9159ba tests/shader_runner: Introduce the "u64" probe format. 2025-06-10 17:46:51 +02:00
Henri Verbeet
261cdb0f29 tests/shader_runner: Rename the "ri64" probe format to "i64". 2025-06-10 17:46:51 +02:00
Henri Verbeet
7dfa9e8f81 vkd3d-shader/msl: Implement VKD3DSIH_DISCARD. 2025-06-10 17:45:06 +02:00
Henri Verbeet
f538085e41 vkd3d-shader/msl: Implement switches. 2025-06-10 17:45:06 +02:00
Henri Verbeet
79be1d3051 vkd3d-shader/msl: Implement loops. 2025-06-10 17:45:06 +02:00
Henri Verbeet
a570932b82 vkd3d-shader/msl: Implement VKD3DSIH_IMUL. 2025-06-10 17:45:06 +02:00
Henri Verbeet
a2eb3324d4 vkd3d-shader/msl: Implement VKD3DSIH_ILT. 2025-06-10 17:45:06 +02:00
Henri Verbeet
83ed825e5a vkd3d-shader/ir: Use vsir_opcode_get_name() in vsir_program_lower_instructions(). 2025-06-10 17:44:18 +02:00
Henri Verbeet
c8e6d35e17 vkd3d-shader/glsl: Use vsir_opcode_get_name() in shader_glsl_unhandled(). 2025-06-10 17:44:18 +02:00
Henri Verbeet
66c0530a05 vkd3d-shader/d3dbc: Use vsir_opcode_get_name() in d3dbc_write_vsir_instruction(). 2025-06-10 17:44:18 +02:00
Henri Verbeet
6a06929f6b vkd3d-shader/d3dbc: Use vsir_opcode_get_name() in shader_sm1_get_opcode_info_from_vsir_instruction(). 2025-06-10 17:44:18 +02:00
Henri Verbeet
1214359022 vkd3d-shader/ir: Introduce vsir_opcode_get_name(). 2025-06-10 17:44:18 +02:00
Giovanni Mascellani
1b389f29c5 vkd3d-shader/dxil: Remove field "reg" from struct sm6_value.
The VSIR register is now always generated dynamically and we
don't have to carry it around.
2025-06-10 17:40:17 +02:00
Giovanni Mascellani
20d8ba7f8d vkd3d-shader/dxil: Introduce sm6_value_get_constant_float().
Similarly to sm6_value_get_constant_uint() and
sm6_value_get_constant_uint64().
2025-06-10 17:40:17 +02:00
Giovanni Mascellani
873043226c vkd3d-shader/dxil: Rewrite sm6_parser_init_ssa_value() in terms of the SM6 value.
Instead of using the VSIR register.
2025-06-10 17:40:17 +02:00
Giovanni Mascellani
59fb3a7893 vkd3d-shader/dxil: Rewrite sm6_value_is_constant_zero() in terms of the SM6 value.
Instead of using the VSIR register.
2025-06-10 17:40:17 +02:00
Giovanni Mascellani
31e4cbba2e vkd3d-shader/dxil: Rewrite sm6_value_get_constant_uint64() in terms of the SM6 value.
Instead of using the VSIR register.
2025-06-10 17:40:17 +02:00
Giovanni Mascellani
2e3f99e61e vkd3d-shader/dxil: Rewrite sm6_value_get_constant_uint() in terms of the SM6 value.
Instead of using the VSIR register.
2025-06-10 17:40:17 +02:00
Giovanni Mascellani
f4f2617584 vkd3d-shader/dxil: Rewrite sm6_value_is_ssa() in terms of the value type. 2025-06-10 17:40:17 +02:00
Giovanni Mascellani
361ecd6cf5 vkd3d-shader/dxil: Rewrite sm6_value_is_undef() in terms of the value type. 2025-06-10 17:40:17 +02:00
Giovanni Mascellani
0ac20b3029 vkd3d-shader/dxil: Rewrite sm6_value_is_constant() in terms of the value type. 2025-06-10 17:40:17 +02:00
Nikolay Sivov
fcb5650dbf vkd3d-shader/fx: Use a separate table for sampler states in fx_2_0.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-06-10 17:39:30 +02:00
Nikolay Sivov
b22ebe73bc vkd3d-shader/fx: Do not print padding bytes of fx_2_0 strings. 2025-06-10 17:39:18 +02:00
Nikolay Sivov
8aacee8eae vkd3d-shader/fx: Add a few missing fxlc opcode names.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-06-10 17:34:41 +02:00
Giovanni Mascellani
8da518f2cd tests: Fix the shader model requirements for a ps_5_0 shader.
In practice this is irrelevant, but better get our tests
consistent.
2025-06-09 16:22:19 +02:00
Giovanni Mascellani
45ef9fdbe8 tests: Add a test about discontiguous input swizzles in bytecode format. 2025-06-09 16:22:19 +02:00
Henri Verbeet
d881356ab2 vkd3d-shader/msl: Implement VKD3DSIH_IGE. 2025-06-09 16:20:53 +02:00
Henri Verbeet
3673b65485 vkd3d-shader/msl: Implement VKD3DSIH_IADD. 2025-06-09 16:20:53 +02:00
Henri Verbeet
cc33439f19 vkd3d-shader/msl: Implement VKD3DSIH_EQO. 2025-06-09 16:20:53 +02:00
Henri Verbeet
fc6249a228 vkd3d-shader/msl: Implement support for VKD3DSPR_SAMPLEMASK registers. 2025-06-09 16:20:53 +02:00
Henri Verbeet
ea5cf883fa vkd3d-shader/msl: Implement support for VKD3DSPR_IDXTEMP registers. 2025-06-09 16:20:53 +02:00
Francisco Casas
66d0c2a426 tests/d3d12: Avoid out-of-bounds access when evaluating ok() args (ubsan).
Compiling and running with UBSan reported the following errors:

tests/d3d12.c:31063:5: runtime error: index 4 out of bounds for type 'float [4][8]'
tests/d3d12.c:31063:5: runtime error: index 8 out of bounds for type 'float [8]'
tests/d3d12.c:31063:5: runtime error: load of address 0x557ee85a1500 with insufficient space for an object of type 'const float'
tests/d3d12.c:31248:5: runtime error: index 4 out of bounds for type 'float [4][4]'
tests/d3d12.c:31248:5: runtime error: index 4 out of bounds for type 'float [4]'
tests/d3d12.c:31248:5: runtime error: load of address 0x557ee85a10d0 with insufficient space for an object of type 'const float'
2025-06-09 16:09:22 +02:00
Giovanni Mascellani
d65be3d0c5 tests: Skip test_graphics_compute_queue_synchronization() on paravirtualized MoltenVK.
This used to work when the macOS runner had a Sonoma host system.
Now it has Sequoia, even if the guest is still Sonoma, and the
test crashes with:

    [mvk-error] VK_TIMEOUT: MTLCommandBuffer "vkQueueSubmit MTLCommandBuffer on Queue 3-0" execution failed (code 2): Caused GPU Hang Error (00000003:kIOGPUCommandBufferCallbackErrorHang)
    vkd3d:56072:err:vkd3d_wait_for_gpu_timeline_semaphore Failed to wait for Vulkan timeline semaphore, vr -4.

Upgrading MoltenVK or the guest to Sequoia doesn't seem to help.
I haven't investigated the problem, but my experience is that
the paravirtualized Metal driver has a number of problems.
2025-06-05 16:50:15 +02:00
Giovanni Mascellani
7e134f85a4 vkd3d-shader/dxil: Do not set the value type in sm6_parser_function_init().
It is rewritten in all branches that produce a value.

VALUE_TYPE_REG is therefore never set and can be retired at last.
2025-06-05 16:05:09 +02:00
Giovanni Mascellani
0e406cf0a8 vkd3d-shader/dxil: Do not set the value type in sm6_parser_declare_global().
It is rewritten in all branches.
2025-06-05 16:05:09 +02:00
Giovanni Mascellani
00b3fb96d9 vkd3d-shader/dxil: Store a SM6 value in sm6_phi.
Rather than a VSIR register.
2025-06-05 16:05:09 +02:00
Giovanni Mascellani
a9a3100cca vkd3d-shader/dxil: Represent non uniformness in the SM6 value. 2025-06-05 16:05:09 +02:00
Giovanni Mascellani
af5e5fe31b vkd3d-shader/dxil: Generate specialized values in sm6_parser_emit_cast() for trivial casts.
There is currently no need to make a special case for 16-bit
values, since the SPIR-V backend currently confuses them with
32-bit values. The generated VSIR code is not correct, but that
will have to be handled at a different level.
2025-06-05 16:05:09 +02:00
Elizabeth Figura
5e6def0843 vkd3d-shader/preproc: Store EOF state per buffer.
We may immediately push a new file or expansion.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=43481
2025-06-05 16:04:02 +02:00
Elizabeth Figura
d768ea6709 vkd3d-shader/preproc: Swap to the INITIAL state after ending a buffer. 2025-06-05 16:04:02 +02:00
Elizabeth Figura
0eb5fee633 vkd3d-shader/preproc: Parse comments in #include and #line directives. 2025-06-05 16:04:02 +02:00
Henri Verbeet
5ea697b8eb vkd3d-shader/msl: Handle SV_SAMPLE_INDEX inputs. 2025-06-05 15:58:44 +02:00
Henri Verbeet
34d8be3b2e tests/shader_runner_metal: Set the pipeline sample count in metal_runner_draw(). 2025-06-05 15:58:44 +02:00
Henri Verbeet
a8defb4e21 tests/shader_runner_metal: Implement multi-sample readback. 2025-06-05 15:58:44 +02:00
Henri Verbeet
1cdfed919a vkd3d-shader/msl: Simplify SV_DEPTH handling. 2025-06-05 15:58:44 +02:00
Henri Verbeet
cf312e14a9 vkd3d-shader/msl: Handle SV_VERTEX_ID inputs. 2025-06-05 15:58:44 +02:00
Henri Verbeet
e948098ae3 vkd3d-shader/msl: Handle SV_POSITION inputs. 2025-06-05 15:58:44 +02:00
Henri Verbeet
f14a0dfe07 vkd3d-shader/msl: Implement support for indirect constant buffer addressing. 2025-06-05 15:58:01 +02:00
Henri Verbeet
0b829db149 vkd3d-shader/msl: Continue when the SRV descriptor binding isn't specified in msl_ld().
Mostly to aid debugging.
2025-06-05 15:55:01 +02:00
Henri Verbeet
fadcbf3eeb vkd3d-shader/msl: Slightly improve the error messages for unspecified descriptor bindings.
This also makes them consistent with the ones used by the GLSL backend.
2025-06-05 15:55:01 +02:00
Henri Verbeet
6a93c503cd vkd3d-shader/msl: Get rid of the "lod" field of struct msl_resource_type_info.
1D read() is specified to support a level/lod parameter. The MSL
specification claims it needs to be 0 because "mipmaps are not supported
for 1D textures", but that restriction isn't documented for the
"mipmapLevelCount" property of MTLTextureDescriptor. Other APIs do
supported mipmapped 1D textures. Multi-sample textures aren't supported
by msl_ld(), so we don't need to worry about them.
2025-06-05 15:55:01 +02:00
Henri Verbeet
02d7d6038d vkd3d-shader/msl: Reject cube and multi-sample texel fetches in msl_ld().
The cube variants are simply disallowed in Direct3D, and currently
mishandled by msl_ld(). It's less clear whether multi-sample fetches
should be allowed, and how they're supposed to behave if they are,
although typically the "ld2dms" instruction would be used for those.
They're not supported on the MSL side either way.
2025-06-05 15:55:01 +02:00
Henri Verbeet
671fbfea7d vkd3d-shader/msl: Ensure we have a non-NULL "resource_type_info" pointer in msl_ld().
Since we're going to dereference it.
2025-06-05 15:55:01 +02:00
Giovanni Mascellani
87fe08fe0e tests/hlsl: Test TGSMs with minimum precision unsigned integers. 2025-06-05 15:50:23 +02:00
Giovanni Mascellani
1d77d51ca4 tests/hlsl: Test some quirks of TGSMs with SM < 5.0.
I'm not specifically interested in that, but since I ran into
those idiosyncrasies while writing other TGSM tests I decided that
it might turn out useful to keep them.
2025-06-05 15:50:04 +02:00
Giovanni Mascellani
bda2be3423 vkd3d-shader/hlsl: Reject programs with group shared variables.
Currently the modifier is ignored and the program is miscompiled.
2025-06-05 15:50:04 +02:00
Giovanni Mascellani
0236308866 tests/hlsl: Test minimum precision IDXTEMP registers. 2025-06-05 15:50:01 +02:00
Giovanni Mascellani
f1b36edc07 ci: Enable testing with DXC again on macOS.
This was disabled by commit 653e4f47ac.
2025-06-04 13:07:17 +02:00
Giovanni Mascellani
a4c727ac40 tests: Mark some tests in calculate-lod.shader_test as buggy on MoltenVK < 1.2.11. 2025-06-04 13:04:53 +02:00
Giovanni Mascellani
c82d1aac4d tests: Mark some tests in arithmetic-int-uniform.shader_test as buggy on MoltenVK < 1.2.11.
The bug is already solved on recent MoltenVK versions, but the CI
is stuck with 1.2.9, so it's useful to filter these failures out.
2025-06-04 13:04:53 +02:00
Giovanni Mascellani
7f04060f33 vkd3d-shader/dxil: Handle 16-bit values uniformly in sm6_map_cast_op().
This makes the logic more transparent, and it eases handling
native 16-bit values once they will be supported.
2025-06-04 13:03:57 +02:00
Giovanni Mascellani
b9ce828451 vkd3d-shader/dxil: Validate that floating-point extension casts increase bit width. 2025-06-04 13:01:51 +02:00
Giovanni Mascellani
a91fb0523a vkd3d-shader/dxil: Validate that integer extension casts increase bit width. 2025-06-04 13:01:51 +02:00
Giovanni Mascellani
a90b74baaa vkd3d-shader/dxil: Validate that floating-point truncation casts decrease bit width.
Similarly to the integer case.
2025-06-04 13:01:45 +02:00
Giovanni Mascellani
0e006715d8 vkd3d-shader/dxil: Do not use field "reg" in of sm6_value when writing bitcasts.
It's going to be removed; the generated register data type is the
right thing to look at here.
2025-06-04 12:34:21 +02:00
Elizabeth Figura
9552dab5aa vkd3d-shader: Use the correct union members for raw and structured resources. 2025-06-04 12:10:39 +02:00
Henri Verbeet
85d2703c03 tests/shader_runner: Introduce a "tessellation-shader" cap.
Similar to how we have the "geometry-shader" cap. In principle shader
model 5+ implies support for tessellation shaders, but the Vulkan,
OpenGL, and Metal runners are able to support most of shader model 5+
without the underlying GPU (or API) necessarily supporting tessellation
shaders.
2025-06-04 12:10:10 +02:00
Shaun Ren
2b257caea9 vkd3d-shader/hlsl: Don't optimize semantic register allocations in SM1.
This matches the behaviour of fxc/d3dcompiler.
2025-06-02 20:53:00 +02:00
Nikolay Sivov
b6ef417e71 vkd3d-shader/fx: Handle bool types when parsing fx_2_0 assignment values. 2025-06-02 20:51:38 +02:00
Nikolay Sivov
c895f63a1c vkd3d-shader/fx: Fix a crash in fx -> d3d-asm when named values are not defined. 2025-06-02 20:51:38 +02:00
Nikolay Sivov
108f4fe47e vkd3d-shader/fx: Fix reading the assignment value base type when parsing fx_2_0. 2025-06-02 20:51:33 +02:00
Nikolay Sivov
4e2fefdfdf vkd3d-shader/fx: Use correct array sizes for the fx_2_0 states. 2025-06-02 20:43:44 +02:00
Nikolay Sivov
4ef4baa6bf vkd3d-shader/fx: Fix some typos in fx_2_0 state names. 2025-06-02 20:43:44 +02:00
Nikolay Sivov
68386f5180 vkd3d-shader/fx: Print packoffset() modifiers in fx -> d3d-asm output.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-06-02 20:43:44 +02:00
Nikolay Sivov
6b2800fa99 vkd3d-shader/fx: Print explicit buffer bind points in fx -> d3d-asm output.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-06-02 20:43:27 +02:00
Nikolay Sivov
e33189546a vkd3d-shader/fx: Use variable unpacked size when setting buffer sizes.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-06-02 20:41:37 +02:00
Giovanni Mascellani
9f0185f304 vkd3d-shader/msl: Support the ABSNEG source modifier. 2025-06-02 20:36:42 +02:00
Giovanni Mascellani
bc0dd891c3 vkd3d-shader/glsl: Support the ABSNEG source modifier. 2025-06-02 20:35:48 +02:00
Giovanni Mascellani
ed60dd5926 tests: Add a test for the ABSNEG source modifier. 2025-06-02 20:33:13 +02:00
Giovanni Mascellani
10be58a74f vkd3d-shader/msl: Ignore the PARTIALPRECISION destination modifier. 2025-06-02 20:33:01 +02:00
Giovanni Mascellani
9f5db1e3e4 vkd3d-shader/glsl: Ignore the PARTIALPRECISION destination modifier. 2025-06-02 20:32:46 +02:00
Giovanni Mascellani
df8b611334 vkd3d-shader/msl: Accept and ignore the REFACTORING_ALLOWED global flag. 2025-06-02 20:32:36 +02:00
Giovanni Mascellani
5998723e7c vkd3d-shader/glsl: Accept and ignore the REFACTORING_ALLOWED global flag. 2025-06-02 20:31:19 +02:00
Giovanni Mascellani
215dfe0450 tests/hlsl: Mark some tests in wave-ops-float.shader_test as buggy on MoltenVK.
I haven't investigated the problem, but since the tests work for
other implementations and MoltenVK is not always perfect it's likely
that the problem is there.
2025-06-02 20:22:58 +02:00
Giovanni Mascellani
0b9268a91b tests/hlsl: Mark some tests in geometry.shader_test as buggy on MoltenVK.
They use geometry shaders, which MoltenVK doesn't support. However
D3D12 has no way to indicate they're unsupported, so the problem
doesn't surface as a failed draw, but rather as a draw that doesn't
do anything.
2025-06-02 20:22:43 +02:00
Giovanni Mascellani
ea4f1dece5 tests/hlsl: Mark a test in entry-point-semantics.shader_test as buggy on MoltenVK with DXIL.
It seems that SPIRV-Cross is generating bad MSL code, and Metal
rejects it.
2025-06-02 20:22:35 +02:00
Giovanni Mascellani
c8b07e9fa6 tests/hlsl: Mark a test in register-reservation-resources.shader_test as todo on MoltenVK with DXIL.
I haven't investigated what's happening.
2025-06-02 20:22:22 +02:00
Giovanni Mascellani
898bc5c4c8 tests/hlsl: Mark a test in sm6-uav-rwtexture.shader_test as todo on MoltenVK.
I haven't investigated what's happening.
2025-06-02 20:22:12 +02:00
Giovanni Mascellani
de8dbdc2cb tests/hlsl: Add a test reading from a minimum precision floating-point array. 2025-06-02 20:18:30 +02:00
Giovanni Mascellani
12da0f9d24 tests/hlsl: Add some more minimum precision floating-point tests. 2025-06-02 20:18:21 +02:00
Giovanni Mascellani
308d3aa676 tests/hlsl: Add a test reading from a minimum precision signed integer array. 2025-06-02 20:18:09 +02:00
Giovanni Mascellani
7f7077a156 tests/hlsl: Use the appropriate RTV format in shader-interstage-interface.shader_test. 2025-06-02 20:18:04 +02:00
Giovanni Mascellani
8106c5a199 tests/hlsl: Test the interstage interface for minimum precision types. 2025-06-02 20:17:56 +02:00
Giovanni Mascellani
752b13b111 tests/hlsl: Test sampling with minimum precision floating-point numbers. 2025-06-02 20:17:48 +02:00
Elizabeth Figura
847c008b49 vkd3d-shader/ir: Split TEX into two separate vsir opcodes.
The two have the same d3dbc opcode, but have different names and different semantics.
2025-06-02 20:13:52 +02:00
Elizabeth Figura
b25362e036 vkd3d-shader/ir: Split TEXCOORD into two separate vsir opcodes.
The two have the same d3dbc opcode, but have different names and different semantics.
2025-06-02 20:12:27 +02:00
Henri Verbeet
618d8e6a4a vkd3d-shader/msl: Make the generated main function static.
We only need to export the entry point.
2025-06-02 20:11:08 +02:00
Henri Verbeet
7929ba9747 vkd3d-shader: Move vkd3d_siv_from_sysval_indexed() to hlsl_codegen.c. 2025-06-02 20:10:46 +02:00
Henri Verbeet
9983d9c4de tests/hlsl: Slightly adjust the bias values in the sample-bias tests.
The expected λ value for the tests in question is about 0.59, which
after linear mipmap interpolation should result in a sampled value of
about 0.41. The quantisation step was added to allow results as high as
0.43, as seen on some implementations.

AMD Radeon Pro Vega 20 on macOS 15.5 returns a sampled value of about
0.39, with both Vulkan/MoltenVK and MSL/Metal. This is not an issue with
the bias calculation; the same behaviour could be reproduced with
SampleLevel(), as used in the sample-level tests, if those tests used
more exciting values for the "level" parameter. It also doesn't appear
to be a general Metal issue; Intel UHD Graphics 630 does return the
expected values on the same setup. Instead, this appears to be a mipmap
interpolation issue on this particular GPU/driver. Mapping the sampled
values for "level" from 0.0 to 1.0, it seems the interpolation factor
used is "saturate(frac(λ) * 1.25 - 0.125)", instead of the normal
"frac(λ)".

Fascinating as that may be, the test here mainly cares about whether the
bias value was applied correctly, and in that regard a sampled value of
0.39 isn't any worse than the 0.43 we already accept. This commit
adjusts the bias value so that the expected sampled value is 0.45, which
makes the accepted error the same on both the positive and negative
side.
2025-06-02 20:08:04 +02:00
Shaun Ren
d5dcf31123 vkd3d-shader/hlsl: Store stream index in struct hlsl_semantic.
In addition, support stream indices in tpf_write_signature().
2025-06-02 19:59:22 +02:00
Shaun Ren
d368d18527 vkd3d-shader/hlsl: Generate vsir instructions for indexed output streams in geometry shaders. 2025-06-02 19:53:25 +02:00
Shaun Ren
7da7ccaf45 vkd3d-shader/hlsl: Emit dcl_stream instructions for SM5 geometry shaders. 2025-06-02 19:53:25 +02:00
Giovanni Mascellani
a743d9ae60 vkd3d-shader/dxil: Remove bitcast helpers.
They are useless, since the source is already a union with the
needed types.
2025-06-02 19:52:25 +02:00
Giovanni Mascellani
0a1e7b5f64 vkd3d-shader/dxil: Generate CONSTANT values in sm6_parser_constants_init() for null scalars. 2025-06-02 19:52:25 +02:00
Giovanni Mascellani
79ec2fe9f2 vkd3d-shader/dxil: Generate specialized values in sm6_parser_constants_init() for casts.
Depending on the casted operand, the generated values can be
ICB, IDXTEMP or GROUPSHAREDMEM.

The cast decoding code is entirely moved to the second pass, so
that we avoid abusing registers to temporarily store other data.
2025-06-02 19:51:22 +02:00
Giovanni Mascellani
93fb51c899 vkd3d-shader/dxil: Generate CONSTANT values in sm6_parser_constants_init() for floating-point values. 2025-06-02 19:46:23 +02:00
Giovanni Mascellani
d36e37555a vkd3d-shader/dxil: Generate CONSTANT values in sm6_parser_constants_init() for integer values. 2025-06-02 19:46:23 +02:00
Giovanni Mascellani
c050c8be75 vkd3d-shader/dxil: Do not touch the parser current value in instruction_dst_param_init_temp_vector().
The stored value is never read, the caller will overwrite it with
the SSA register generated by the whole DXIL instruction.

Since the helper is always used for UINT instructions, change and
rename it accordingly, so we don't have the problem of finding out
which data type to use.
2025-06-02 19:45:54 +02:00
Nikolay Sivov
87ec2d9897 vkd3d-shader/fx: Fix writing fx_2_0 structure parameters.
Currently structure type descriptions get interleaved with variable
length string data. The solution is to write all fixed length fields
first, then append strings.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-05-27 20:24:24 +02:00
Giovanni Mascellani
bb50117747 ci: Really use DXC 1.8.2502 for macOS.
In theory commit 7b07d77396 already
did that, but in practice it ended up picking a commit from the
1.8.2405 branch, where a few of our tests fail. Since I hope to
soon enable DXC for macOS again, it's useful to fix that oversight.
2025-05-27 19:44:27 +02:00
Giovanni Mascellani
365f6d3be9 tests/hlsl: Mark some tests in uav-atomics.shader_test as working on MoltenVK. 2025-05-27 19:32:45 +02:00
Giovanni Mascellani
85dcd03642 tests/hlsl: Mark some tests in wave-ops-int.shader_test as buggy on MoltenVK.
It seems that SPIRV-Cross is generating bad MSL code, and Metal
rejects it.
2025-05-27 19:32:35 +02:00
Giovanni Mascellani
9ab1cadaa5 tests/hlsl: Mark some tests in wave-ops-uint.shader_test as buggy on MoltenVK.
It seems that SPIRV-Cross is generating bad MSL code, and Metal
rejects it.
2025-05-27 19:32:19 +02:00
Giovanni Mascellani
6fe0d71ae1 tests/hlsl: Mark a test in gather-offset.shader_test as buggy on MoltenVK with d3d12.
It seems that SPIRV-Cross is generating bad MSL code, and Metal
rejects it.
2025-05-27 19:31:38 +02:00
Giovanni Mascellani
70c51984c9 tests/hlsl: Mark some tests in clip-cull-distance.shader_test as buggy on MoltenVK with d3d12.
They either use geometry shaders or cull distances, which MoltenVK
doesn't support. However d3d12 has no way to indicate they're
unsupported, so the problem doesn't surface as a failed draw,
but rather as a draw that doesn't do anything.
2025-05-27 19:30:21 +02:00
Giovanni Mascellani
7261b40df7 tests/hlsl: Mark a test in object-references.shader_test as todo on MoltenVK with DXIL.
I haven't investigated what's happening in detail. However vkd3d
emits this message, which makes me think the problem is ours:

    vkd3d:62178588:fixme:spirv_compiler_get_descriptor_binding Could not find descriptor binding for type 0, space 0, registers [0:2], shader type 0.
2025-05-27 19:29:56 +02:00
Giovanni Mascellani
e6267dd6b4 tests/hlsl: Do not test for overflowing 16-bit texture sampling.
The behavior is not uniform across drivers; in my tests AMD
performs as expected by the test, but WARP and NVIDIA return
infinity.
2025-05-27 17:45:09 +02:00
Giovanni Mascellani
bd1b737e4e tests/hlsl: Test minimum precision stride for floating point numbers too. 2025-05-27 17:45:07 +02:00
Giovanni Mascellani
d214f9ebca tests/hlsl: Test minimum precision stride for signed integers too. 2025-05-27 17:43:07 +02:00
Giovanni Mascellani
6a699d2872 tests/hlsl: Test minimum precision floating point numbers. 2025-05-27 17:40:29 +02:00
Giovanni Mascellani
1496ddc52f tests/hlsl: Test native 16-bit floating point numbers. 2025-05-27 17:40:29 +02:00
Giovanni Mascellani
deb3b74c66 tests/hlsl: Test casting 16-bit integers to doubles. 2025-05-27 17:40:12 +02:00
Giovanni Mascellani
adca5a66e7 tests/hlsl: Test casting minimum precision integers to doubles. 2025-05-27 17:20:19 +02:00
Giovanni Mascellani
f7c2fbfe85 tests/hlsl: Test casting doubles to minimum precision integers. 2025-05-27 17:20:14 +02:00
Henri Verbeet
ffafa7fdaa tests/hlsl: Get rid of a MSL todo in geometry.shader_test.
The Metal/MSL runner doesn't support geometry shaders, so the test is
never executed on that runner.
2025-05-27 17:15:10 +02:00
Henri Verbeet
ee85e6b534 tests/hlsl: Require the "geometry-shader" cap for the relevant clip/cull-distance tests. 2025-05-27 17:15:10 +02:00
Henri Verbeet
5581c42a79 tests/shader_runner_d3d11: Direct3D 11 supports geometry shaders. 2025-05-27 17:15:10 +02:00
Henri Verbeet
0a28abd8f6 tests/shader_runner_metal: Try harder to find a suitable device. 2025-05-27 17:12:36 +02:00
Henri Verbeet
e17a98f870 vkd3d-shader: Remove some newlines from vkd3d-shader error messages. 2025-05-27 17:12:13 +02:00
Nikolay Sivov
c4c7f10d99 vkd3d-shader/fx: Fix the total buffer size calculation in write_fx_4_buffer().
The total size should take variable alignment/padding into account.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-05-24 21:32:22 +02:00
Nikolay Sivov
2e40154801 vkd3d-shader/fx: Use the correct field indices when writing structure default values.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-05-24 21:27:01 +02:00
Nikolay Sivov
a06ecb6867 vkd3d-shader/fx: Use the correct value range for bool initializers.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-05-24 21:24:59 +02:00
Nikolay Sivov
11d4fcff46 vkd3d-shader/fx: Handle nameless structure types.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-05-24 21:19:42 +02:00
Shaun Ren
a4e43402e5 vkd3d-shader/hlsl: Support void pass-through hull shader control point functions. 2025-05-24 21:13:00 +02:00
Shaun Ren
e7b2ca28ab vkd3d-shader/hlsl: Fix the register string for patch arrays in debug_register(). 2025-05-24 21:03:56 +02:00
Elizabeth Figura
f5e0c47811 vkd3d-shader/ir: Use add_signature_element() to add clip planes.
In particular, ensure that the semantic name is not NULL. This is necessary to
avoid a crash when a later pass using vsir_signature_find_element_by_name(),
e.g. vsir_program_insert_vertex_fog(), iterates over the signature including the
new element.
2025-05-24 21:02:17 +02:00
Giovanni Mascellani
3fb662c9e7 tests/hlsl: Remove some tests from minimum-precision.shader_test.
Most of them fail on any native implementation I can put my hands
on, including the CI. Equivalent, but hopefully better, tests
were added to arithmetic-uint.shader_test and
arithmetic-int-uniform.shader_test.
2025-05-24 21:00:32 +02:00
Giovanni Mascellani
cb1ee9cdd5 tests/hlsl: Test minimum precision 16-bit signed integers. 2025-05-24 20:59:34 +02:00
Giovanni Mascellani
a477502a05 tests/hlsl: Test minimum precision 16-bit unsigned integers. 2025-05-24 20:57:42 +02:00
Giovanni Mascellani
fdc173506e tests/hlsl: Test minimum precision stride in constant buffers. 2025-05-24 20:54:42 +02:00
Giovanni Mascellani
bd6dbd096f vkd3d-shader/dxil: Reimplement aggregate indexing using specialized value types.
As opposed to just touching the vsir register description, which
should be removed soon.
2025-05-24 20:44:45 +02:00
Giovanni Mascellani
6a85df013b vkd3d-shader/dxil: Pass a reference to the SM6 parser to sm6_register_from_value(). 2025-05-24 20:44:45 +02:00
Giovanni Mascellani
b0940729ff vkd3d-shader/dxil: Pass a reference to the SM6 parser to src_param_init_from_value(). 2025-05-24 20:44:45 +02:00
Giovanni Mascellani
6b9df6b7a5 vkd3d-shader/dxil: Pass a reference to the SM6 parser to src_params_init_from_operands(). 2025-05-24 20:44:45 +02:00
Henri Verbeet
fe747b065f vkd3d-shader: Also output vkd3d_shader_vnote() messages using WARN. 2025-05-24 20:41:39 +02:00
Henri Verbeet
ef3e10a14e vkd3d-shader: Also output vkd3d_shader_vwarning() messages using WARN. 2025-05-24 20:41:39 +02:00
Henri Verbeet
9156de0593 vkd3d-shader: Also output vkd3d_shader_verror() messages using WARN. 2025-05-24 20:41:39 +02:00
Shaun Ren
4eab50755e tests: Test signature reflection for geometry shader outputs. 2025-05-24 20:38:36 +02:00
Shaun Ren
a58b1f7011 vkd3d-shader/hlsl: Implement output semantics for geometry shaders. 2025-05-24 20:38:36 +02:00
Shaun Ren
18ec4caded vkd3d-shader/tpf: Read the DCL_OUTPUT_SGV instruction.
Introduce VSIR op VKD3DSIH_DCL_OUTPUT_SGV.
2025-05-24 20:38:36 +02:00
Henri Verbeet
a93d258a86 Release 1.16. 2025-05-20 11:35:48 +02:00
Henri Verbeet
379b297d2c build: Add the Objective-C API JSON to the distribution. 2025-05-15 14:13:07 +02:00
Henri Verbeet
07d8fe0462 build: Add the SPIR-V grammar JSON to the distribution. 2025-05-15 14:13:07 +02:00
Giovanni Mascellani
129b3a8c4b tests: Check that shader-visible descriptor heaps have a valid GPU descriptor handle start.
We currently check that non-shader-visible heaps have a NULL
handle, but that doesn't seem to be guaranteed: beside WARP, also
NVIDIA drivers still return a valid pointer. And that's a pretty
useless check anyway; rather, check that shader-visible heaps
have a valid pointer, which is more interesting.
2025-05-15 14:11:10 +02:00
Giovanni Mascellani
1aa33ebc80 tests: Allow creating GPU upload heaps.
They are write-combine heaps on L1 memory, and were introduced
recently in Direct3D 12.
2025-05-15 14:10:53 +02:00
Giovanni Mascellani
d5410e3115 tests: Expect success when creating resources in certain cases.
Currently the tests expect that creating buffers in COMMON or
COPY_SOURCE state on UPLOAD heaps or in COMMON state on READBACK
heaps leads to a failure. I tested WARP, AMD and NVIDIA, and in
all cases the operations is successful.

I think the D3D12 runtime used reject resources created in the
configurations detailed above, but it doesn't any more (both
using the latest Agility SDK and the runtime distributed with
an updated Windows 11 system). However the CI still uses an
earlier runtime, so the old behavior is still allowed as
broken.
2025-05-15 14:09:23 +02:00
Henri Verbeet
f5a26fd2b8 vkd3d-shader/dxil: Document the supported dxbc-dxil transformations. 2025-05-14 15:10:44 +02:00
Henri Verbeet
1efbcebed4 build: Sort the $(vkd3d_shader_tests) list. 2025-05-14 15:10:18 +02:00
Elizabeth Figura
c1adf54a44 vkd3d-shader/hlsl: Forbid referring to typedefs with "struct". 2025-05-14 15:09:48 +02:00
Elizabeth Figura
8ca50a2f7e tests/hlsl: Add more tests for struct syntax. 2025-05-14 15:09:42 +02:00
Elizabeth Figura
5ad2e7ee6d vkd3d-shader/hlsl: Fix an incorrect error message for referring to non-struct types with "struct".
We cannot be redefining struct types in this rule, only referring to already
defined types. Struct type definition is handled by named_struct_spec, which
complains if the type was defined at all, regardless of class.
2025-05-14 15:08:13 +02:00
Elizabeth Figura
bfa655a01f vkd3d-shader/ir: Use the .w component of the existing swizzle when lowering texldb. 2025-05-14 15:07:46 +02:00
Elizabeth Figura
e16176672a vkd3d-shader/hlsl: Validate "numthreads" attribute values. 2025-05-14 14:56:42 +02:00
Elizabeth Figura
cfb59828f3 tests/hlsl: Add more tests for the "numthreads" attribute. 2025-05-14 14:56:42 +02:00
Elizabeth Figura
a06b9f6646 vkd3d-shader/hlsl: Do not emit HLSL_OP1_ABS for unsigned types. 2025-05-14 14:55:59 +02:00
Elizabeth Figura
cdc74a9377 vkd3d-shader/hlsl: Emit an error when min16uint is used in d3dbc target profiles.
Fixes: 18ca7affad
2025-05-14 14:12:19 +02:00
Elizabeth Figura
8f6616993b vkd3d-shader/spirv: Do not declare inputs with an empty used_mask.
This is motivated by SampleId, whose presence or absence determines whether a
fragment shader runs at sample frequency or not.

In HLSL, if SV_SampleIndex is declared but not used, this results in a signature
entry, but no dcl instruction (and a zero used mask in the signature entry).
Whether the shader will actually run at sample frequency is inconsistent. NVidia
does, AMD does not, and WARP does for d3d12 but not for d3d11.

Previously vkd3d-shader relied on the dcl instruction, thereby aligning with
AMD. This was changed by 66cb2815f0. This commit
restores the previous behaviour.
2025-05-14 14:09:28 +02:00
Elizabeth Figura
65e1ef047f vkd3d-shader/spirv: Return void from spirv_compiler_emit_input(). 2025-05-14 14:09:28 +02:00
Elizabeth Figura
d40422592a vkd3d-shader/ir: Merge tess factor used masks together.
Encountered with the domain shader in
test_domain_shader_one_patch_constant_input().
2025-05-14 14:09:21 +02:00
Henri Verbeet
d4032f7d09 demos: Build with -fno-lto.
Some versions of Clang do not properly pass include paths to the
assembler when LTO is enabled. That's a problem for the DEMO_EMBED macro
used by the demos, since it relies on .incbin. To make matters even
better, compilation fails, but doesn't return an error code; the
resulting binary is simply broken. Fortunately we don't really care
about LTO for the demos, so we can simply disable it. See also
https://github.com/llvm/llvm-project/issues/112920

Thanks to Giovanni for tracking down some of the pieces of this issue.
2025-05-14 14:06:37 +02:00
Henri Verbeet
3c8fd8a2f2 ci: Build the demos on macOS. 2025-05-12 15:38:01 +02:00
Henri Verbeet
a2d5358ac6 demos: Avoid objc_msgSend_fpret() on ARM64 macOS.
It's unavailable, and unnecessary.
2025-05-12 15:38:01 +02:00
Giovanni Mascellani
dd34899e97 vkd3d-shader/dxil: Call register_get_float_value() directly in sm6_value_get_constant_float().
sm6_metadata_get_float_value() already calls sm6_value_is_constant()
itself, and some compilers (rightly) emit a warning that the conversion
of UINT_MAX to float changes the value.
2025-05-12 15:37:27 +02:00
Anna (navi) Figueiredo Gomes
820430001f vkd3d-shader/hlsl: Use the source data type in clone_interlocked(). 2025-05-12 15:31:09 +02:00
Elizabeth Figura
4a5411aa6e vkd3d-shader/hlsl: Return a uint1 from GetRenderTargetSampleCount(). 2025-05-12 15:29:23 +02:00
Elizabeth Figura
4cdea712d0 tests/hlsl: Show that GetRenderTargetSampleCount() returns a vector. 2025-05-12 15:28:49 +02:00
Giovanni Mascellani
42df4517c6 vkd3d-shader/dxil: Generate GROUPSHAREDMEM values in sm6_parser_declare_tgsm_structured(). 2025-05-12 15:24:23 +02:00
Giovanni Mascellani
fd918062d6 vkd3d-shader/dxil: Generate GROUPSHAREDMEM values in sm6_parser_declare_tgsm_raw(). 2025-05-12 15:24:23 +02:00
Giovanni Mascellani
cb5a548740 vkd3d-shader/dxil: Generate IDXTEMP values in sm6_parser_declare_indexable_temp(). 2025-05-12 15:24:23 +02:00
Giovanni Mascellani
8635a7ff6e vkd3d-shader/dxil: Generate ICB values in sm6_parser_declare_icb(). 2025-05-12 15:24:23 +02:00
Giovanni Mascellani
1d88638bd3 vkd3d-shader/dxil: Rename VALUE_TYPE_ICB to VALUE_TYPE_DATA.
And other related identifiers similarly.

Currently we use VALUE_TYPE_ICB to indicate a raw chunk of data
(which can be used as an immediate constant buffer, but also for
initializing an indexable temporary) and VALUE_TYPE_REG with
register type VKD3DSPR_IMMCONSTBUFFER to indicate an actual ICB
register.

Since we are now switching to represent the register type directly
in the SM6 value, it seems sensible to use VALUE_TYPE_ICB for an
ICB register. Indeed, since what we're currently describing with
VALUE_TYPE_ICB is not necessarily related to an ICB register, it
makes sense to use a more general name, which is therefore being
introduced with this commit.
2025-05-12 15:24:23 +02:00
Nikolay Sivov
960244bf1e vkd3d-shader/fx: Use appropriate BlendState description when tracing.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-05-06 19:01:09 +02:00
Nikolay Sivov
5d5d892830 vkd3d-shader/fx: Use the same BlendState states description for both fx_4_1 and fx_5_0.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-05-06 18:58:03 +02:00
Nikolay Sivov
d660a0d2ae tests: Add a fx_4_1 compilation test for the BlendState states.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-05-06 18:58:03 +02:00
Giovanni Mascellani
fd1f74f44d vkd3d-shader/dxil: Generate INVALID values in sm6_parser_emit_unhandled(). 2025-05-06 18:55:19 +02:00
Giovanni Mascellani
44e0b17606 vkd3d-shader/dxil: Generate INVALID values in sm6_parser_constants_init(). 2025-05-06 18:55:18 +02:00
Giovanni Mascellani
7381598310 vkd3d-shader/dxil: Generate UNDEFINED values in sm6_parser_constants_init().
VALUE_TYPE_UNDEFINED means that a value is explicitly undefined,
equivalently to what was first represented with is_undefined.
VALUE_TYPE_INVALID will be introduced for values that arise from
invalid programs.
2025-05-06 18:55:18 +02:00
Giovanni Mascellani
e9e02884e5 vkd3d-shader/dxil: Generate SSA values in sm6_parser_emit_phi(). 2025-05-06 18:55:18 +02:00
Giovanni Mascellani
7c344bdfd0 vkd3d-shader/dxil: Generate SSA values in sm6_parser_emit_cmpxchg(). 2025-05-06 18:55:18 +02:00
Giovanni Mascellani
326f3624d9 vkd3d-shader/dxil: Generate SSA values in sm6_parser_emit_dx_sincos(). 2025-05-06 18:55:18 +02:00
Giovanni Mascellani
527c1518f2 vkd3d-shader/dxil: Generate SSA values in sm6_parser_emit_dx_atomic_binop(). 2025-05-06 18:55:18 +02:00
Henri Verbeet
b389fa89e4 demos: Make the demos work in the macOS build. 2025-05-06 18:42:09 +02:00
Francisco Casas
7b07d77396 ci: Update the DXC version used on the CI to 1.8.2502. 2025-05-06 18:39:02 +02:00
Henri Verbeet
cb4b5641ea vkd3d: Handle multiple fence NULL event waits in d3d12_device_SetEventOnMultipleFenceCompletion(). 2025-05-06 18:29:06 +02:00
Henri Verbeet
3fabac3f70 vkd3d: Handle multiple fence ANY waits in d3d12_device_SetEventOnMultipleFenceCompletion(). 2025-05-06 18:29:06 +02:00
Henri Verbeet
9222f5e5b1 vkd3d: Handle multiple fence ALL waits in d3d12_device_SetEventOnMultipleFenceCompletion(). 2025-05-06 18:29:06 +02:00
Henri Verbeet
52b947a005 vkd3d: Handle single fence waits in d3d12_device_SetEventOnMultipleFenceCompletion().
By forwarding to ID3D12Fence_SetEventOnCompletion().
2025-05-06 18:29:06 +02:00
Henri Verbeet
3ea84156c7 vkd3d: Validate the fence count in d3d12_device_SetEventOnMultipleFenceCompletion(). 2025-05-06 18:29:06 +02:00
Henri Verbeet
75ce9cef92 tests/d3d12: Test ID3D12Device1_SetEventOnMultipleFenceCompletion(). 2025-05-06 18:29:06 +02:00
Henri Verbeet
e54070c2d7 vkd3d: Introduce d3d12_fence_add_waiting_event(). 2025-05-06 18:29:06 +02:00
Henri Verbeet
615dce0eaa vkd3d: Introduce struct vkd3d_null_event.
This effectively moves "null_event_cond" from struct d3d12_fence and
"latch" from struct vkd3d_waiting_event together into a separate
structure, as well as storing the signalling function in struct
vkd3d_waiting_event instead of getting it from struct d3d12_device. I
think that largely makes sense on its own, but storing the signalling
function in struct vkd3d_waiting_event also allows us to more easily
implement d3d12_device_SetEventOnMultipleFenceCompletion() in a
subsequent commit.
2025-05-06 18:29:06 +02:00
Giovanni Mascellani
4289ec60a1 vkd3d-shader/dxil: Do not encode the offset twice for structured TGSM loads.
Currently structured TGSM loads are encoded to something like this:

    ld_structured sr12 <s:float>, sr1 <s:uint>, l(0) <s:uint>, g0[sr1 <s:uint> + 0] <s:float>

Notice how the TGSM offset, expressed by sr1, is encoded twice in
the instruction. In TPF there is no expectation of two indices
in the resource source, so let's avoid producing it for DXIL as
well. The same instruction will therefore become:

    ld_structured sr12 <s:float>, sr1 <s:uint>, l(0) <s:uint>, g0 <s:float>
2025-05-05 15:14:26 +02:00
Giovanni Mascellani
9fdaee1529 vkd3d-shader/dxil: Generate SSA values in sm6_parser_emit_binop(). 2025-05-05 15:10:15 +02:00
Giovanni Mascellani
31f8ed1d1e vkd3d-shader/dxil: Generate SSA values in sm6_parser_emit_atomicrmw(). 2025-05-05 15:10:15 +02:00
Giovanni Mascellani
fae03b2ba5 vkd3d-shader/dxil: Generate SSA values in instruction_dst_param_init_ssa_scalar(). 2025-05-05 15:10:15 +02:00
Giovanni Mascellani
bd73de7198 vkd3d-shader/dxil: Generate SSA values in instruction_dst_param_init_ssa_vector(). 2025-05-05 15:10:14 +02:00
Giovanni Mascellani
b8c6092a16 vkd3d-shader/dxil: Generate SSA values in sm6_parser_get_value_idx_by_ref(). 2025-05-05 15:08:29 +02:00
Giovanni Mascellani
9e7ad75944 vkd3d-shader/dxil: Move the VSIR register in the SM6 value outside of the union.
It will eventually disappear, but while it's replaced with other
union members it shouldn't interfere with them.
2025-05-05 15:02:58 +02:00
Giovanni Mascellani
648a60d4c8 vkd3d-shader/dxil: Introduce a uniform interface to synthesize a register from a SM6 value. 2025-05-05 15:02:57 +02:00
Giovanni Mascellani
8b58ce9e85 vkd3d-shader/dxil: Have sm6_parser_emit_reg_composite_construct() accept an array of registers.
Rather than an array of pointers to registers. This makes it nicer
to use with registers that are synthesized on the fly, a situation
that already exists and is likely to become more common in future
commits.
2025-05-05 15:01:36 +02:00
Shaun Ren
5b06fe83df vkd3d-shader/hlsl: Generate vsir instructions for stream output operations. 2025-05-05 14:54:07 +02:00
Shaun Ren
c8c1e270e0 vkd3d-shader/hlsl: Validate maximum output size in geometry shaders. 2025-05-05 14:43:53 +02:00
Shaun Ren
729a3ac089 vkd3d-shader/hlsl: Append output copies for stream output Append() invocations. 2025-05-05 14:30:16 +02:00
Shaun Ren
34b4b34f2c vkd3d-shader/hlsl: Use a block in append_output_copy*(). 2025-05-05 14:30:16 +02:00
Francisco Casas
e6db0ab614 tests: Add tests for DeviceMemoryBarrierWithGroupSync(). 2025-05-05 14:27:35 +02:00
Francisco Casas
b89f0bc730 vkd3d-shader/hlsl: Generate vsir for HLSL_IR_SYNC operations.
The following table shows how each intrinsic maps to d3d assembly and the
flags that appear in the tpf bytecode, in binary.

    GroupMemoryBarrier()                   sync_g               0010
    GroupMemoryBarrierWithGroupSync()      sync_g_t             0011
    DeviceMemoryBarrier()                  sync_uglobal         1000
    DeviceMemoryBarrierWithGroupSync()     sync_uglobal_t       1001
    AllMemoryBarrier()                     sync_uglobal_g       1010
    AllMemoryBarrierWithGroupSync()        sync_uglobal_g_t     1011
2025-05-05 14:17:47 +02:00
Francisco Casas
a975c56695 vkd3d-shader/hlsl: Mark stores dirty on interlocked operation in vectorize_stores(). 2025-05-05 14:15:23 +02:00
Francisco Casas
758a4bef09 vkd3d-shader/hlsl: Parse barriers.
And introduce hlsl_ir_sync to represent them.
2025-05-05 14:15:14 +02:00
Giovanni Mascellani
541060215e vkd3d-shader/dxil: Create vsir registers from DXIL handles when needed.
The idea is that sm6_value and related structures should not commit
to a specific vsir register representation yet, because at the time
they are created some information might be still unavailable. For
instance, it might be not yet known whether the program is using
native 16-bit types or minimum precision types. vsir registers
should only be synthesized during instruction emission.

Field "reg" in struct sm6_value will be handled in a later commit.
2025-04-30 16:58:31 +02:00
Elizabeth Figura
315247bf02 vkd3d-shader: Normalize TEXKILL to use a source register. 2025-04-30 16:51:44 +02:00
Giovanni Mascellani
50ca4a2101 vkd3d-shader/msl: Use the standard helper to print bitcasts. 2025-04-30 16:23:35 +02:00
Giovanni Mascellani
bb78c06193 vkd3d-shader/msl: Introduce msl_print_bitcast(). 2025-04-30 16:22:48 +02:00
Giovanni Mascellani
a1f48d2575 vkd3d-shader/msl: Introduce msl_print_src(). 2025-04-30 16:17:50 +02:00
Andrey Gusev
8882d324a6 vkd3d-shader/ir: Store the actual return value in shader_signature_map_patch_constant_index_ranges(). 2025-04-28 12:49:27 +02:00
Andrey Gusev
c69d2ab0ae vkd3d-shader/dxil: Store the actual return value in sm6_parser_signatures_init(). 2025-04-28 12:47:57 +02:00
Henri Verbeet
dfe3ad5551 demos: Make the demos work in the Windows build.
Commit 02fe9f5bdf introduced linking the
Windows build of the demos with d3d12 and dxgi, while also still linking
to libvkd3d-utils.la. That happens to more or less work on Wine; we get
vkd3d-utils' D3D12CreateDevice(), and Wine's
IDXGIFactory2_CreateSwapChainForHwnd(), but because Wine's
implementation of d3d12 swapchains uses vkd3d, we're able to use the
resulting swapchain buffers even though the instance of vkd3d used by
Wine may not be the same instance of vkd3d used by the demos. Perhaps
unsurprisingly, things don't go nearly as well on Windows.

We could of course stop linking the demos to vkd3d-utils on Windows, but
that's not that interesting; we're trying to show what vkd3d can do
here, not what d3d12 can do.
2025-04-28 12:16:10 +02:00
Henri Verbeet
883ffc5fd6 demos: Split demo_win32.h.
Much like we did for demo_xcb.h, demo_win32.h now just has the bits for
creating windows and handling events, while demo_d3d12.h has the d3d12
and dxgi bits.
2025-04-28 12:14:36 +02:00
Henri Verbeet
ceb2787d46 ci: Install mingw-w64-tools in the Linux image.
For the build-mingw-32 and build-mingw-64 jobs. These currently end up
picking up Linux pkg-config instead of MinGW pkg-config, which in turn
causes configure to pick up Linux OpenGL and XCB. We happen to get away
with that at the moment because none of the code using HAVE_OPENGL or
HAVE_XCB ends up getting built for Windows, but that's about to change.
Specifically, we'd like to build the vkd3d versions of the demos for
Windows.
2025-04-23 18:13:07 +02:00
Henri Verbeet
aa8161a7ad build: Do not add libvkd3d-shader.la to DEMOS_LDADD twice.
Commit e3f78706ec added libvkd3d-shader.la
to LDADD, but didn't remove it from DEMOS_LDADD.
2025-04-23 18:12:54 +02:00
Henri Verbeet
88bbc106c7 vkd3d-shader/spirv: We can parse up to SPIR-V 1.6.
The main reason to care at this point is that we actually emit SPIR-V 1.3
ourselves in some cases.
2025-04-23 18:12:39 +02:00
Conor McCarthy
4c8c31fa2e tests/hlsl: Add a shader model 5.1 test to srv-byteaddressbuffer.shader_test.
Some code paths for TPF handling are not tested if no 5.1 shaders are
compiled.
2025-04-23 18:11:42 +02:00
Conor McCarthy
c75b318805 vkd3d-shader/tpf: Emit the resource data type only for typed resource declarations. 2025-04-23 18:10:51 +02:00
Shaun Ren
5d29554fed tests/hlsl: Add geometry shader stream output syntax tests. 2025-04-23 18:03:59 +02:00
Shaun Ren
2a89b23ede vkd3d-shader/hlsl: Validate and record stream output objects.
Validation should only be done for stream outputs that are used.
2025-04-23 18:01:06 +02:00
Shaun Ren
f2f44b054d vkd3d-shader/hlsl: Allocate registers for stream output objects.
All stream output objects need to have a stream index allocated,
whether they are used or not.

We allocate stream outputs here, before other objects are allocated,
because the stream index is needed to create the appropriate output
semantic variables during append_output_copy(), which will be called
in a lowering pass for the Append() method.
2025-04-23 17:54:54 +02:00
Shaun Ren
d620ad4942 vkd3d-shader/hlsl: Introduce HLSL_REGSET_STREAM_OUTPUTS regset. 2025-04-23 17:54:54 +02:00
Shaun Ren
8059608af9 vkd3d-shader/hlsl: Parse the RestartStrip() method for stream outputs. 2025-04-23 17:54:54 +02:00
Shaun Ren
9525eb2f0c vkd3d-shader/hlsl: Parse the Append() method for stream outputs. 2025-04-23 17:54:54 +02:00
Shaun Ren
9b65cc8895 vkd3d-shader/hlsl: Support HLSL_CLASS_STREAM_OUTPUT in hlsl type helpers. 2025-04-23 17:54:54 +02:00
Giovanni Mascellani
6ca9395368 tests/d3d12: Skip testing NULL VBVs on NVIDIA on Windows.
It seems that the NVIDIA drivers leaves VBVs bindings untouched
when they are NULL (or the GPU buffer address is NULL), instead of
setting them to a null binding.

Differently from other cases of inconsistent behaviour between AMD
and NVIDIA, here I'm explicitly marking the NVIDIA behaviour as
broken, because the expected behaviour is spelled out explicitly
(at least for the D3D12 specification standards).
2025-04-21 14:43:59 +02:00
Giovanni Mascellani
bc637f2633 tests/d3d12: Do not validate the semantic of uint-clearing R11G11B10_FLOAT resources.
Implementations have no consistent behaviour.
2025-04-21 14:43:27 +02:00
Giovanni Mascellani
c1d04b84c7 tests/d3d12: Do not test out-of-bound UAV uint clears.
The behaviour is not uniform: AMD truncates, NVIDIA saturates.
2025-04-21 14:40:44 +02:00
Giovanni Mascellani
f890db872a tests/d3d12: Do not allow texture creation to fail when testing UAV uint clears.
If the format is supported texture creation should always succeed.
2025-04-21 14:40:31 +02:00
Giovanni Mascellani
f932af7f18 tests/d3d12: Check that B5G6R5_UNORM and B5G5R5A1_UNORM are supported before testing them.
They are not always available on NVIDIA GPUs.
2025-04-21 14:36:39 +02:00
Giovanni Mascellani
4324817c68 tests/d3d12: Set the descriptor heap when clearing UAVs. 2025-04-21 14:32:58 +02:00
Giovanni Mascellani
c764f71cf5 vkd3d-shader/ir: Validate that DEPTHOUTLE registers aren't used as sources. 2025-04-16 16:46:38 +02:00
Giovanni Mascellani
ee7895465c vkd3d-shader/ir: Validate that DEPTHOUTGE registers aren't used as sources. 2025-04-16 16:46:28 +02:00
Giovanni Mascellani
834017c198 vkd3d-shader/ir: Validate that DEPTHOUT registers aren't used as sources. 2025-04-16 16:46:05 +02:00
Giovanni Mascellani
a189a4cfb7 tests/hlsl: Do not test the implicit passthrough control point phase for SM6. 2025-04-16 16:43:45 +02:00
Giovanni Mascellani
dbd1938ce4 tests/hlsl: Fix the precision for a 16-bit arithmetic test. 2025-04-16 16:42:20 +02:00
Giovanni Mascellani
3186d66596 tests/hlsl: Do not test dst() on integer arguments with SM6.
That seems to hit a DXC bug we're not interested into.
2025-04-16 16:36:58 +02:00
Giovanni Mascellani
9db9f3bdaf tests/hlsl: Do not test 16-bit out-of-bound varyings. 2025-04-16 16:35:23 +02:00
Giovanni Mascellani
26656808e6 tests/hlsl: Remove a test in which a function reads an "out" argument.
The code doesn't make sense in the first place, even if it's
accepted by the compiler, so it makes sense that the behaviour
is undefined. And indeed the behaviour is different on AMD (4 is
returned), NVIDIA (QNaN is returned) and WARP (device is removed).
2025-04-16 16:30:19 +02:00
Giovanni Mascellani
df1aecb7bd tests/hlsl: Do not test 16-bit out-of-bound UAV writes. 2025-04-16 16:28:42 +02:00
Giovanni Mascellani
0ac661f571 tests/hlsl: Do not test 16-bit out-of-bound SRV buffer reads.
They do not behave consistently between AMD, NVIDIA and WARP, so
there is little point enforcing a specific behaviour.
2025-04-16 16:25:26 +02:00
Giovanni Mascellani
64bd2af015 tests/shader_runner_d3d9: Request the adapter specified on the command line. 2025-04-16 16:24:39 +02:00
Francisco Casas
9378d51b18 vkd3d-shader/hlsl: Remove the unnecessary "instr" field from the parser %union. 2025-04-16 16:22:42 +02:00
Francisco Casas
77941b131e vkd3d-shader/hlsl: Add switch_case destructors to the parser. 2025-04-16 16:21:51 +02:00
Francisco Casas
ff5f9cbcb6 vkd3d-shader/hlsl: Add parse_variable_def destructors to the parser. 2025-04-16 16:21:45 +02:00
Francisco Casas
f3ba7a84f4 vkd3d-shader/hlsl: Avoid leaking blocks on YYABORT.
Currently program errors might result on instructions that use
ctx->error_instr as src. In case we hit YYABORT while parsing another
part of the HLSL source, we have to make sure that the block that
contains the instruction is properly cleaned up, or we might hit the

    vkd3d:590273:err:hlsl_free_instr Failed assertion: list_empty(&node->uses)

assertion when hlsl_ctx_cleanup() is called after the YYABORT.

Consider the following shader:

    float4 main() : sv_target
    {
        // Statement A
        int p = foo;      // initializer argument is ERROR.
        // Statement B
        undeclared_fun(); // triggers YYABORT.
    }

Statement A will src the ctx->error_instr because of the undeclared
identifier and Statement B will trigger an YYABORT because of the
undeclared function.
2025-04-16 16:01:35 +02:00
Francisco Casas
128688a573 vkd3d-shader/hlsl: Avoid leaking declaration_statement blocks. 2025-04-16 16:00:18 +02:00
Francisco Casas
58706474ec vkd3d-shader/hlsl: Make struct_declaration_without_vars return void. 2025-04-16 15:58:40 +02:00
Giovanni Mascellani
922cb47a4b vkd3d-shader/ir: Validate descriptor counts in vsir programs. 2025-04-16 15:56:59 +02:00
Giovanni Mascellani
be94a37e23 vkd3d-shader/ir: Validate descriptor resource data types in vsir programs. 2025-04-16 15:52:46 +02:00
Giovanni Mascellani
01f47e00f2 vkd3d-shader/ir: Validate descriptor resource types in vsir programs. 2025-04-16 15:49:32 +02:00
Giovanni Mascellani
0da80c1f25 vkd3d-shader/ir: Validate descriptor types in vsir programs. 2025-04-16 15:46:20 +02:00
Giovanni Mascellani
869e6ef583 vkd3d-shader: Describe the resource data types of samplers as NONE.
It used to be UINT before, but it doesn't make any sense.
2025-04-16 15:42:31 +02:00
Giovanni Mascellani
f02ea94c42 vkd3d-shader/d3d-asm: Trace register names for I/O declarations. 2025-04-14 21:57:27 +02:00
Giovanni Mascellani
0417f4f162 vkd3d-shader/d3d-asm: Include the program descriptors when tracing vsir code. 2025-04-14 21:57:15 +02:00
Giovanni Mascellani
bac6949365 vkd3d-shader/d3d-asm: Expose the raw value if unknown in shader_dump_data_type(). 2025-04-14 21:55:26 +02:00
Giovanni Mascellani
fd16bba29d vkd3d-shader/d3d-asm: Expose the raw value if unknown in shader_dump_resource_type(). 2025-04-14 21:55:26 +02:00
Henri Verbeet
f4e10ea9d5 vkd3d-shader/d3d-asm: Include the I/O signatures when tracing vsir code. 2025-04-14 21:55:26 +02:00
Giovanni Mascellani
24e61cf74e vkd3d-shader: Represent resource data types as vkd3d_data_type in struct vkd3d_shader_descriptor_info1. 2025-04-14 21:55:26 +02:00
Giovanni Mascellani
4412a83655 tests: Create structured buffers with the appropriate stride.
The stride didn't match the structure size used in the shader.

This didn't seem to be a problem on AMD and WARP, but it was
on NVIDIA on Windows. Specifically, it seems that the buffer
is read using the shader structure size (so most tests pass),
but bounds are checked using the buffer stride, so a test
returned zero simply because an out-of-bounds read was detected.
2025-04-14 15:56:01 +02:00
Giovanni Mascellani
85e848289b tests/shader_runner_d3d11: Do not create CPU-readable multisample resolution textures.
Unless the D3D11_FEATURE_DATA_D3D11_OPTIONS2.MapOnDefaultTextures
feature is supported, textures with default usage cannot be read by the
CPU; and there isn't a need to either, since we're going through a
staging texture anyway.

This worked on AMD and WARP, but failed on NVIDIA on Windows.
2025-04-14 15:54:27 +02:00
Henri Verbeet
4e783e2d66 tests/shader_runner: Get rid of enum texture_data_type. 2025-04-14 15:48:24 +02:00
Francisco Casas
7b21059ee5 vkd3d-shader/hlsl: Support the .Length property for Textures.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57686
2025-04-14 15:47:16 +02:00
Francisco Casas
2dce34d7e0 tests/hlsl: Test the object .Length property. 2025-04-14 15:41:47 +02:00
Elizabeth Figura
0c18736370 vkd3d-shader/ir: Validate SSA write masks. 2025-04-14 15:32:15 +02:00
Elizabeth Figura
d91d552a5e vkd3d-shader/ir: Introduce a vsir_dst_param_init_null() helper. 2025-04-14 15:32:12 +02:00
Elizabeth Figura
1a1f1f1369 vkd3d-shader/hlsl: Set the right interpolation mode in the vsir signature. 2025-04-14 15:29:19 +02:00
Elizabeth Figura
7331c70e9e vkd3d-shader/hlsl: Set the sysval for more sm1 semantics.
To match the sysval we set when reading them.
2025-04-14 15:29:19 +02:00
Feifan He
ba7a9a0b29 vkd3d-shader/msl: Implement VKD3DSIH_LD.
Co-authored-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2025-04-14 15:27:02 +02:00
Feifan He
015a751ea0 tests/shader_runner_metal: Add texture support.
Co-authored-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2025-04-14 14:50:51 +02:00
Giovanni Mascellani
3493688a4d vkd3d-shader/msl: Access descriptors with a type-erased array.
Currently a descriptor set is represented with a structure
whose fields are the various descriptors that the shader is
going to use, each of them qualified with its type. This model
doesn't match very well what happens with D3D12 and with Vulkan
and descriptor indexing and mutable descriptors, where many
descriptor of different types can overlap, and only at shader
runtime it is decided which of them must be used.

Therefore with this patch a descriptor is represented as a
structure whose fields carry no intrinsic typing information,
but are reinterpreted according to the shader behavior on
each access. For the moment there is just one field, but more
will be added to account for fancier descriptor types and
to workaround Metal limitations.

When completed, this design will be similar in spirit to what
the Metal shader converter does, with little technical
differences.

This choice has a couple of drawbacks:

 1. shader debugging with Xcode is less comfortable, because
    the shader doesn't carry static descriptor typing
    information and Xcode is therefore less able to provide
    useful context;

 2. it requires tier 2 argument buffer support and macOS
    version >= 13, which includes guarantees on the runtime
    layout for descriptors.

Supporting descriptor indexing and mutable descriptors is
considered to be worthy of those drawbacks, though, is
effectively required by many applications and appears to be
the first goal we should aim for. If needed, in the future
we might also add support for older hardware, at least for
shaders that do not make use of advanced features.
2025-04-14 14:45:14 +02:00
Giovanni Mascellani
ed677a8f32 tests/shader_runner_metal: Do not use shared buffers.
They are not supported on non-Apple discrete GPUs. Instead make
them managed (if they are short lived) or private.
2025-04-14 14:38:39 +02:00
Feifan He
e5bb3a5233 tests/shader_runner_metal: Introduce a helper to encode the argument buffer.
Co-authored-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2025-04-14 14:38:39 +02:00
Giovanni Mascellani
eb9e254b8c tests/shader_runner_metal: Handle multisampled 2D texture arrays properly.
They're not supported by the shader runner anyway, but there's no
reason to make the code subtly wrong.
2025-04-14 14:38:38 +02:00
Giovanni Mascellani
cbce3a8631 tests/shader_runner: Always set descriptor heaps. 2025-04-09 16:42:16 +02:00
Giovanni Mascellani
bb8f1304ba tests/d3d12: Always set descriptor heaps.
It seems AMD and WARP are not particularly sensitive to that, but
NVIDIA drivers crash if descriptor heaps are not set.
2025-04-09 16:41:33 +02:00
Conor McCarthy
fdd21470b9 tests/hlsl: Test casts from double to 16-bit integer types. 2025-04-09 16:39:07 +02:00
Conor McCarthy
bb8b4f3827 tests/hlsl: Test casts to 16-bit uint. 2025-04-09 16:22:19 +02:00
Conor McCarthy
3c950e5977 tests/hlsl: Test casts to 16-bit int. 2025-04-09 16:20:58 +02:00
Conor McCarthy
88a85024e2 tests/hlsl: Test casts to 16-bit float. 2025-04-09 16:20:53 +02:00
Giovanni Mascellani
7fb288819a vkd3d-shader/msl: Set the prefix to "unknown" for unhandled shader types in msl_generator_init().
Like we do for GLSL; there's no reason to abort compilation here. Note
that this also avoids leaking "gen->buffer" and "gen->string_buffers" on
the error path.
2025-04-09 16:08:15 +02:00
Shaun Ren
0c139ef7a0 vkd3d-shader/hlsl: Add special allocation rules for patch constant data. 2025-04-09 16:02:12 +02:00
Shaun Ren
7ba84b7787 tests: Add signature reflection tests for register allocation rules in tessellation shaders. 2025-04-09 16:02:12 +02:00
Shaun Ren
d3b32fefa3 vkd3d-shader/tpf: Support SV_RenderTargetArrayIndex/SV_ViewportArrayIndex sysvals in tessellation shaders. 2025-04-09 16:02:12 +02:00
Shaun Ren
05f8dd8273 vkd3d-shader/hlsl: Prioritize smaller writemasks for all allocators in allocate_semantic_registers(). 2025-04-09 16:02:12 +02:00
Shaun Ren
ec2f18ab17 vkd3d-shader/hlsl: Free all allocators in allocate_semantic_registers(). 2025-04-09 16:02:12 +02:00
Shaun Ren
d1df10ac86 vkd3d-shader/hlsl: Use dcl_output_siv for patch constant function sysval outputs. 2025-04-09 16:02:12 +02:00
Henri Verbeet
70655012ab demos: Move the vkd3d parts of demo_xcb.h into a separate header.
So that they can be used for e.g. Wayland or macOS support. Or Windows,
if we're so inclined.
2025-04-08 20:38:26 +02:00
Henri Verbeet
b12e3d8eec demos: Get rid of some unused includes.
These were used for demo_load_shader(), but that was removed some time
ago in commit aa5d48eec4.
2025-04-08 20:38:26 +02:00
Victor Chiletto
89d3e667e0 tests/hlsl: Add tests for SRV structured buffers. 2025-04-08 19:31:40 +02:00
Victor Chiletto
cc9f4ac587 tests/hlsl: Attempt to deduce the data type of unspecified type texture data.
Try parsing first as integer, and if the parse stops at a decimal separator, parse as float.
2025-04-08 19:18:57 +02:00
Victor Chiletto
7b21183f45 tests/shader_runner_d3d12: Pass the structure byte stride for SRVs. 2025-04-08 19:18:56 +02:00
Anna (navi) Figueiredo Gomes
3e8b56c509 vkd3d-shader/fx: Don't cast between int and uint in state blocks. 2025-04-08 19:14:15 +02:00
Anna (navi) Figueiredo Gomes
8866a43b2d tests/hlsl: Add some fx_4_0 state tests. 2025-04-08 19:14:15 +02:00
Elizabeth Figura
f576ecc992 vkd3d-shader/hlsl: Introduce a compiler pass to vectorize stores. 2025-04-03 20:29:20 +02:00
Elizabeth Figura
1a999f74fc vkd3d-shader/hlsl: Introduce a compiler pass to vectorize expressions. 2025-04-03 20:29:20 +02:00
Giovanni Mascellani
7b4a29da81 tests: Mark a todo as resolved on MoltenVK 1.2.12.
Technically it is not, the Vulkan commands we're generating are
still not correct. But let's get rid of the failure message.
2025-04-03 20:28:31 +02:00
Giovanni Mascellani
653e4f47ac ci: Disable testing with DXC on macOS.
With this we can finally disallow failure for the macOS CI script,
which is more valuable than checking DXC. Eventually DXC tests
will have to be fixed, though.
2025-04-03 20:28:27 +02:00
Giovanni Mascellani
aab8ba02d8 tests: Mark a number of test failures as buggy on macOS before Sequoia.
It's hard to pinpoint exactly what's going wrong with these
tests. They seem to be related to atomics and GPU timestamps,
both categories that are known to have problems on MoltenVK in a
way or another; those failures clearly depend on a few factors
like the MoltenVK version, the macOS version and whether we're in
a virtual machine or not, but the exact dependency on those factors
is hard to describe (for example, in general the paravirtualized
device offered inside virtual machines has a lot more problems than
real devices, but I've seen tests, fixed all other conditions,
working on the paravirtualized device and not on the real device).

The only thing all tests in this batch have in common is that I've
never seen them fail on a Sequoia system, thus I've settled for
using just that as the bug_if() condition. Ultimately, wasting a
lot of time to get to the bottom of each single test failure is
pointless, and being able to mark the CI job as not allowed to
fail gives better regression protection than investigating each
of those. Also, I routinely run the tests on a Sequoia system, so
if these tests get broken this is going to be noticed anyway.
2025-04-03 20:26:26 +02:00
Nikolay Sivov
2540081988 vkd3d-shader/fx: Accept int(0) as well as uint(0) constant value for object-type states.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-04-02 19:34:25 +02:00
Nikolay Sivov
4ff14104b0 vkd3d-shader/fx: Set GeometryShader state type as an object type.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-04-02 19:34:25 +02:00
Elizabeth Figura
ea21dddec9 vkd3d-shader/hlsl: Allow compiling directly to GLSL. 2025-04-02 19:33:41 +02:00
Elizabeth Figura
33cd10581e vkd3d-shader/glsl: Invert gl_FragCoord w. 2025-04-02 19:32:39 +02:00
Francisco Casas
4b9c23272a vkd3d-shader/ir: Reset instruction pointers after shader_instruction_array_insert_at().
Every call to shader_instruction_array_insert_at() means a possible
reallocation of all vsir instructions in the program. This means that all
previous pointers are potentially no longer valid.

We are currently using these potentially invalid pointers in some cases,
usually in the form of "ins->location". This commit fixes these.

I moved all pointer changes to right after the call to
shader_instruction_array_insert_at() to make this more evident.
2025-04-02 19:25:12 +02:00
Giovanni Mascellani
875c5df519 vkd3d-shader/ir: Validate register id and index for CONSTBUFFER registers. 2025-04-02 19:24:10 +02:00
Giovanni Mascellani
c181f147ce vkd3d-shader/ir: Validate register id and index for SAMPLER registers. 2025-04-02 19:08:50 +02:00
Giovanni Mascellani
9b7256c0c8 vkd3d-shader/ir: Validate register id and index for UAV registers. 2025-04-02 19:08:00 +02:00
Giovanni Mascellani
10d8760134 vkd3d-shader/ir: Validate register id and index for RESOURCE registers. 2025-04-02 19:06:43 +02:00
Shaun Ren
3e44bd4e5b tests/hlsl: Add a test for copy-propagation of uniform texture object writes. 2025-04-02 18:51:10 +02:00
Shaun Ren
7aebed0eea vkd3d-shader/hlsl: Ensure that uniform objects are never written to in copy_propagation_transform_object_load(). 2025-04-02 18:49:52 +02:00
Shaun Ren
b1d8915440 vkd3d-shader/hlsl: Divert written uniform derefs to temps before copy-propagation passes.
The following pixel shader currently triggers an infinite loop during
copy propagation, which is fixed by this commit:

    sampler s;
    Texture2D t1, t2;

    float4 main() : sv_target
    {
        Texture2D t = t1;
        t1 = t2;
        t2 = t;
        return t1.Sample(s, float2(0, 0)) + t2.Sample(s, float2(0, 0));
    }

The infinite loop occurs because copy_propagation_transform_object_load()
replaces t1 in the resource_load(t1, ...) instruction
with t2, t1, t2, ... repeatedly.
2025-04-02 18:49:52 +02:00
Francisco Casas
3ead8d532b vkd3d-shader/hlsl: Allow non-constant deref propagation on SM1.
Note that we still have to preempt the propagation to SM1 pixel shader
uniforms. Otherwise this will turn the many constant derefs that appear
from the <index-val> copy generated in lower_index_loads() into a single
non-constant deref, causing it to allocate all the registers instead of
up until the last one used.
2025-04-02 18:27:16 +02:00
Francisco Casas
f65e6265e0 vkd3d-shader/ir: Normalise MOVA and d3dbc indirect addressing. 2025-04-02 18:27:16 +02:00
Francisco Casas
fd02d69dda vkd3d-shader/hlsl: Implement indirect addressing for d3dbc target profiles. 2025-04-02 18:26:03 +02:00
Francisco Casas
0e0ed72652 vkd3d-shader/d3dbc: Respect "idx_count" when writing registers.
Some SM1 src registers have idx_count = 0, in which case we have to
respect that instead of always reading reg->reg.idx[0].offset even when
it is invalid.
2025-04-02 18:06:48 +02:00
Francisco Casas
2327f87e37 tests/hlsl: Test SM1 vertex shader uniform allocation on indirect addressing.
Here, a vertex shader version of the previous test by Shaun is
introduced. Note that in this case the uniform allocates all 4 registers
instead of 3 because it is indirectly addressed.
2025-04-02 18:06:48 +02:00
Francisco Casas
b6ce1479fe tests/hlsl: Test vertex shader uniform indirect addressing.
Note that, for indexes with a decimal part, the behavior is different
depending on whether it is a temp load or a direct uniform load (which
can only happen on vertex shaders). The former rounds to the
closest-to-zero, while the latter rounds to the nearest even.
2025-04-02 18:06:18 +02:00
Elizabeth Figura
20b76f87bf vkd3d-shader/hlsl: Initialize the temp count for sm1. 2025-04-02 17:58:26 +02:00
Elizabeth Figura
7cb5a7bebc vkd3d-shader/hlsl: Leave the swizzle zero for VSIR_DIMENSION_NONE registers. 2025-04-02 17:58:26 +02:00
Elizabeth Figura
950f78041a vkd3d-shader/hlsl: Initialize the vsir dimension for sm1. 2025-04-02 17:58:26 +02:00
Elizabeth Figura
856f4b55f6 vkd3d-shader/hlsl: Set the correct index count for sm1 DEPTHOUT. 2025-04-02 17:58:26 +02:00
Elizabeth Figura
227e2cc0f5 vkd3d-shader/hlsl: Use vsir_*_from_hlsl_node() helpers in more places. 2025-04-02 17:58:18 +02:00
Henri Verbeet
110edf32d0 demos: Add basic DPI handling. 2025-03-19 14:10:24 +01:00
Nikolay Sivov
21e08955d3 vkd3d-shader/fx: Pad fx_2_0 object data blobs with zeroes.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-03-18 15:56:32 +01:00
Giovanni Mascellani
803bf59654 tests: Mark an early depth stencil test as buggy on MoltenVK.
On MoltenVK it seems that all draws are always executed,
independently of the early depth stencil test. The problem doesn't
seem to belong to vkd3d or MoltenVK, because the generated Metal
commands look correct. I tried looking at a GPU capture with Xcode,
which was not very conclusive because it doesn't state clearly
whether early fragment tests were passed or not. Sometimes it
says that a fragment shader execution had no thread execution
data, which I interpret as the early fragment tests having
prevented the fragment shader from running, but it's not really
consistent, and it's never clear which results are based on
software simulation and which on the hardware run.

However taking everything into account I think the most likely
explanation is some incorrect optimization at the Metal level.
2025-03-18 15:55:29 +01:00
Giovanni Mascellani
05f7f03dab tests: Mark a queue synchronization test as buggy on MoltenVK.
The graphics pipeline triggers an internal error in the Metal
pipeline compiler, with a completely generic error message. I have
no idea what the actual problem is.
2025-03-18 15:53:59 +01:00
Shaun Ren
8f19d02501 tests: Add a signature reflection test for geometry shader inputs. 2025-03-18 15:46:07 +01:00
Shaun Ren
62c00be873 vkd3d-shader/tpf: Emit geometry shader property declarations. 2025-03-18 15:46:07 +01:00
Shaun Ren
bd055fac1c vkd3d-shader/hlsl: Store geometry shader properties in struct vsir_program. 2025-03-18 15:46:02 +01:00
Shaun Ren
b1ace5763a vkd3d-shader/hlsl: Implement input semantics for geometry shaders. 2025-03-18 15:40:11 +01:00
Shaun Ren
8af3173955 vkd3d-shader/hlsl: Support input primitive arrays in geometry shaders. 2025-03-18 15:40:11 +01:00
Giovanni Mascellani
2377db33db vkd3d-shader: Represent descriptor information in the vsir program. 2025-03-18 15:38:01 +01:00
Giovanni Mascellani
4308fa3f68 vkd3d-shader/spirv: Do not steal the instruction array from the vsir program.
There is no need, and it only complicates tracking ownership.
2025-03-18 15:37:57 +01:00
Giovanni Mascellani
fc520e7b4c vkd3d-shader/spirv: Do not store duplicate references to the signatures.
They are already available through the program.
2025-03-18 15:34:16 +01:00
Giovanni Mascellani
5ce03258b5 vkd3d-shader/spirv: Immediately store a reference to the program in the SPIR-V generator.
So it doesn't have to be passed around uselessly.
2025-03-18 15:34:04 +01:00
Giovanni Mascellani
549659dab6 vkd3d-shader/spirv: Run the vsir passes before creating the SPIR-V generator.
This makes it more similar to the MSL and GLSL generators. It also looks
like a cleaner design, the backend is supposed to get access to the vsir
program after it has gone through the pipeline.
2025-03-18 15:33:27 +01:00
Francisco Casas
ea99d2c2cd vkd3d-shader/hlsl: Lower integer modulus for d3dbc target profiles. 2025-03-18 15:27:04 +01:00
Francisco Casas
828afe188c vkd3d-shader/hlsl: Don't lower integer MOD and DIV on const passes for d3dbc target profiles.
These bitwise operations are not available in these profiles.
2025-03-18 15:27:03 +01:00
Francisco Casas
e3923876c0 tests/hlsl: Test integer division with big integers.
Similarly to the modulus operator, d3dbc results with constant folding
are different from results when constant folding cannot be applied, and
different from tpf results.
2025-03-18 15:25:41 +01:00
Francisco Casas
080672478d tests/hlsl: Test integer modulus with big integers.
Note that in d3dbc target profiles it gives different results when this
operation is constant folded compared to when it is not.

This suggests that whatever pass lowers the modulus operation to d3dbc
operations doesn't do it before constant folding.

Also note that when constant folded, d3dbc results differ from tpf
results for negative operands, because of the loss of precision that
happens when NEG is constant folded.

So the same integer modulus expression can have 3 different results
depending on the context.
2025-03-18 15:21:43 +01:00
Francisco Casas
a3f80061b1 tests/hlsl: Test for loss of precision on integer negation in d3dbc target profiles. 2025-03-18 14:25:26 +01:00
Elizabeth Figura
bc382c6835 vkd3d-shader/hlsl: Reuse shader model 1-3 constants. 2025-03-18 14:21:02 +01:00
Giovanni Mascellani
e418bbcfac tests: Mark a test about resource aliasing as todo on MoltenVK.
As far as I know there is no way to implement this properly on
Vulkan, and all the other Vulkan implementations essentially work
by luck. In Vulkan the initial layout of a resource must always be
UNDEFINED or PREINITIALIZED and it must be transitioned away from
before any meaningful use of that image is done. Therefore it's
possible to alias two images and let the second one inherit the
content in the first one only if both already exist (and are in
the same layout) before the first writing is done. If, as in this
example, the second image is created after the first one has
already been written to, the obligatory transition away from
UNDEFINED or PREINITIALIZED will potentially wipe out the content.

Therefore I am marking this as todo, not as a bug. I might also be
that there is a bug in MoltenVK, and ultimately that's the reason
why we're reading invalid data, but technically the Vulkan
commands we generate are incorrect anyway.
2025-03-17 15:14:23 +01:00
Giovanni Mascellani
44072062ff tests: Transition texture state to inherit aliased data.
When textures[1] is read for the second time it is aliased to
textures[0]. But textures[0] was left in COPY_DEST state (since
its creation), and textures[1] is currently recreated in COPY_SOURCE
state, which AFAIU is invalid. So recreate textures[1] in COPY_DEST
state and then transition it before reading it.
2025-03-17 15:14:23 +01:00
Giovanni Mascellani
c3f01d7db9 tests: Mark two other tessellation tests as buggy on MoltenVK.
I haven't investigated the actual problem here, but the generated
Vulkan commands look correct (and work with basically all other
Vulkan implementations) and MoltenVK is known to have incomplete
tessellation support, so it's likely that the problem is there.
2025-03-17 15:14:23 +01:00
Giovanni Mascellani
8cf61c859d tests: Mark a few other timestamp query tests as buggy on MoltenVK.
Similarly to 5d4edba925, it seems
that sometimes MoltenVK returns 0 to timestamp queries. It
doesn't happen deterministically and it might depend on the
hardware (I have seen differences between the M2 I used some
time ago and the M3 Max I have now).
2025-03-17 15:14:23 +01:00
Giovanni Mascellani
101f070f12 ci: Define VKD3D_TEST_DEBUG when running the CI scripts.
Essentially to make d3d12.log more readable.
2025-03-17 15:14:23 +01:00
Henri Verbeet
0dff53ada7 build: Add @DL_LIBS@ to tests_vkd3d_shader_api_LDADD.
It uses dxcompiler_create(), which (potentially) uses dlopen().
2025-03-17 15:13:42 +01:00
Giovanni Mascellani
674614cc7a vkd3d-shader/ir: Disallow IMMCONSTBUFFER registers in destination parameters. 2025-03-17 15:12:13 +01:00
Giovanni Mascellani
0761d73e9c vkd3d-shader/ir: Disallow CONSTBUFFER registers in destination parameters. 2025-03-17 15:12:13 +01:00
Giovanni Mascellani
0c9c29fb34 vkd3d-shader/ir: Validate CONSTBUFFER registers. 2025-03-17 15:11:52 +01:00
Henri Verbeet
808931b108 vkd3d-shader/glsl: Implement VKD3DSIH_XOR. 2025-03-17 15:07:51 +01:00
Nikolay Sivov
ba79890398 vkd3d-shader/fx: Support dumping parameter and array selector assignments for fx_2_0.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-03-17 15:05:14 +01:00
Nikolay Sivov
ff7591171b vkd3d-shader/fx: Dump complex state value blobs for fx_2_0.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-03-17 14:54:26 +01:00
Nikolay Sivov
fb16ae2325 vkd3d-shader/fx: Add support for dumping fx_2_0 shader blobs.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-03-17 14:48:12 +01:00
Nikolay Sivov
36e1a0ceae vkd3d-shader/fx: Add support for parsing fx_2_0 sampler states.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-03-17 14:46:36 +01:00
Nikolay Sivov
3e86484091 vkd3d-shader/fx: Read fx_2_0 assignment data outside of its dumping helper.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-03-17 14:46:36 +01:00
Nikolay Sivov
fb5d53bf57 vkd3d-shader/fx: Add a helper to escape printed strings.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-03-17 14:46:18 +01:00
Giovanni Mascellani
fc4316f664 tests/shader_runner: Avoid creating devices for backends that won't execute.
My main motivation to this is avoiding generating a lot of useless
log lines from other executors when I'm interested in just one of
them, but I can imagine this also somewhat improving efficiency.
2025-03-17 14:01:22 +01:00
Giovanni Mascellani
0b273ea88c tests: Store the compiler string in the shader runner capabilities.
Just like the executor.
2025-03-17 13:50:19 +01:00
Shaun Ren
a4f58be00c vkd3d-shader/hlsl: Remove the unused hlsl_array_type_to_string() declaration.
Accidentally introduced in 870c68dd27.
2025-03-13 14:02:26 +01:00
Elizabeth Figura
c9a5f586b7 vkd3d-shader/hlsl: Zero-initialize "nonconst_i" and "ret_swizzle" in copy_propagation_replace_with_deref().
GCC without LTO is unable to determine that these are never used
uninitialized.
2025-03-13 13:59:05 +01:00
Francisco Casas
09b9f8ff9f vkd3d-shader/hlsl: Fix invalidation of the wrong components in copy-propagation.
Fixes: 1bba18aa75.
2025-03-12 22:14:25 +01:00
Francisco Casas
bff9068a7f tests: Add a hard test for copy-propagation invalidation.
This test is currently miscompiling on SM4 because
copy_propagation_invalidate_variable_from_deref_recurse() is not always
invalidating the right components.
2025-03-12 22:14:15 +01:00
Elizabeth Figura
a87b1efbd2 vkd3d-shader/hlsl: Don't invalidate OOB constant derefs. 2025-03-12 22:09:57 +01:00
Elizabeth Figura
193e40c271 vkd3d-shader/hlsl: Stop checking for failure from intrinsic_float_convert_arg(). 2025-03-12 22:02:39 +01:00
Elizabeth Figura
7b5b5dbb8d vkd3d-shader/hlsl: Do not abort when performing an invalid implicit cast. 2025-03-12 22:02:39 +01:00
Elizabeth Figura
2ee19c4d34 vkd3d-shader/hlsl: Do not abort when performing an invalid explicit cast. 2025-03-12 22:02:39 +01:00
Elizabeth Figura
25f476c7ad vkd3d-shader/hlsl: Return an error expression from add_cast() on allocation failure. 2025-03-12 22:02:39 +01:00
Elizabeth Figura
0642531c2a vkd3d-shader/hlsl: Introduce hlsl_block_add_swizzle(). 2025-03-12 22:02:31 +01:00
Elizabeth Figura
f8c53fae37 vkd3d-shader/hlsl: Introduce hlsl_block_add_resource_load(). 2025-03-12 22:02:21 +01:00
Henri Verbeet
b9ebf87114 vkd3d-shader/hlsl: Do not collect expressions across different operations in hlsl_normalize_binary_exprs(). 2025-03-12 21:34:17 +01:00
Henri Verbeet
b4296e1a2d tests/hlsl: Add another constant folding test. 2025-03-12 21:34:02 +01:00
Shaun Ren
dd1072a99b tests/hlsl: Add geometry shader syntax tests. 2025-03-12 21:21:35 +01:00
Shaun Ren
ae5261b98b vkd3d-shader/hlsl: Forbid output parameters in geometry shaders.
Outputs in geometry shaders must be written to streams.
2025-03-12 21:15:15 +01:00
Shaun Ren
4137ea5ab7 vkd3d-shader/hlsl: Validate stream output parameters in geometry shaders. 2025-03-12 21:13:59 +01:00
Shaun Ren
b650e7a503 vkd3d-shader/hlsl: Validate stream output object declarations.
Valid stream output objects must be single-element containing a
PointStream/LineStream/TriangleStream object.

Moreover, stream output objects cannot be declared globally.
2025-03-12 21:12:56 +01:00
Shaun Ren
870c68dd27 vkd3d-shader/hlsl: Validate and record input primitive types in geometry shaders. 2025-03-12 21:11:46 +01:00
Shaun Ren
57bb28e841 vkd3d-shader/hlsl: Parse primitive type modifiers in geometry shaders. 2025-03-12 20:42:59 +01:00
Shaun Ren
e880b11626 vkd3d-shader/hlsl: Parse the maxvertexcount attribute. 2025-03-12 20:42:15 +01:00
Francisco Casas
7be7e589a9 vkd3d-shader/hlsl: Lower TRUNC expressions for SM1.
Basically, separate lower_casts_to_int() into the lowering of the CAST
and the lowering of the TRUNC, so that TRUNCs that are not part of a
cast are lowered as well.
2025-03-12 18:26:23 +01:00
Shaun Ren
1b03676a36 tests/hlsl: Add dynamic addressing copy-propagation tests. 2025-03-12 18:22:01 +01:00
Shaun Ren
7ab7b2ab8b vkd3d-shader/hlsl: Implement copy-propagation of derefs with a non-constant index.
We implement a transformation that propagates loads with a single
non-constant index in its deref path. Consider a load of the form
var[[a0][a1]...[i]...[an]], where ak are integral constants, and i is
an arbitrary non-constant node. If, for all j, the following holds:

  var[[a0][a1]...[j]...[an]] = x[[c0*j + d0][c1*j + d1]...[cm*j + dm]],

where ck, dk are constants, then we can replace the load with
x[[c0*i + d0]...[cm*i + dm]]. This pass is implemented by
copy_propagation_replace_with_deref().
2025-03-12 18:16:59 +01:00
Shaun Ren
f484527cfb vkd3d-shader/hlsl: Rename init_deref() to hlsl_init_deref(). 2025-03-12 17:22:44 +01:00
Shaun Ren
2bc7fa568f vkd3d-shader/hlsl: Introduce component_index_from_deref_path_node(). 2025-03-12 17:19:56 +01:00
Shaun Ren
2368ff6637 vkd3d-shader/hlsl: Introduce simplify_exprs().
Also invoke simplify_exprs() after replace_deref_path_with_offset().
2025-03-12 17:18:52 +01:00
Shaun Ren
c6f18c9394 vkd3d-shader/hlsl: Support indirect addressing of uniforms in sm4_generate_vsir_reg_from_deref(). 2025-03-12 17:14:52 +01:00
Shaun Ren
f6c35144e4 vkd3d-shader/hlsl: Support patch arrays in hlsl_reg_from_deref(). 2025-03-12 17:10:32 +01:00
Shaun Ren
261b5120f6 vkd3d-shader/hlsl: Allow non-constant indices in register_deref_usage(). 2025-03-12 17:10:32 +01:00
Shaun Ren
1c2434f4d3 vkd3d-shader/hlsl: Allow uint1-typed deref path nodes.
When derefs with non-constant indices are copy-propagated, it is
possible to end up with uint1-typed path nodes.

Also, introduce hlsl_is_vec1().
2025-03-12 17:09:35 +01:00
Shaun Ren
766492d1cc vkd3d-shader/glsl: Implement support for indirect constant buffer addressing. 2025-03-12 17:06:47 +01:00
Shaun Ren
16b0afc192 vkd3d-shader/tpf: Write non-zero static offsets in relative addressing mode in sm4_write_register_index(). 2025-03-12 17:04:52 +01:00
Henri Verbeet
81dc67b1ef demos: Add copyright headers to the HLSL shaders. 2025-03-10 15:18:07 +01:00
Elizabeth Figura
8f28956108 vkd3d-shader/hlsl: Fix writing the sincos extra constants.
Fixes: 4ed16108f0
2025-03-10 15:17:19 +01:00
Elizabeth Figura
d075c3c274 vkd3d-shader/hlsl: Fix temp allocation for ps 1.x.
Iterate over the extern vars, not the parameters. The synthesized inputs and
output don't go in the function parameters.

Fixes: 8b57a612d7
2025-03-10 15:17:19 +01:00
Nikolay Sivov
553e37314a vkd3d-shader/fx: Print string object entries for fx_2_0.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-03-10 15:14:32 +01:00
Nikolay Sivov
3749171656 vkd3d-shader/fx: Output object initialiser IDs for fx_2_0.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-03-10 15:14:24 +01:00
Giovanni Mascellani
d34f5fbae2 tests/shader_runner: Allow selecting the compiler. 2025-03-10 15:12:45 +01:00
Giovanni Mascellani
5a898254b0 tests/shader_runner: Allow selecting the executor. 2025-03-10 15:12:33 +01:00
Petrichor Park
f05386e006 tests/shader_runner: Allow controlling which shader models to run via command line.
Adds new flags --sm-min and --sm-max. They each take a shader model
identifier, with the same syntax as in the test harness. If either is
present, then it will only run tests within the (inclusive) range.
Omitting one allows anything as the min/max.
2025-03-10 15:12:25 +01:00
Henri Verbeet
2f260a344e build: Get rid of some redundant instances of "checking" in AC_MSG_CHECKING messages.
AC_MSG_CHECKING already prints "checking" itself.
2025-03-10 15:03:23 +01:00
Elizabeth Figura
f4042ba752 vkd3d-shader/hlsl: Add a hlsl_block_add_resource_store() helper. 2025-03-10 14:56:11 +01:00
Elizabeth Figura
e7ff5da5b1 vkd3d-shader/hlsl: Add a hlsl_block_add_index() helper. 2025-03-10 14:56:11 +01:00
Elizabeth Figura
e5cabeafe5 vkd3d-shader/hlsl: Add a hlsl_block_add_loop() helper. 2025-03-10 14:56:11 +01:00
Elizabeth Figura
62196b2bf1 vkd3d-shader/hlsl: Add a hlsl_block_add_if() helper. 2025-03-10 14:56:11 +01:00
Elizabeth Figura
20aa37237d vkd3d-shader/hlsl: Add a hlsl_block_add_jump() helper. 2025-03-10 14:56:11 +01:00
Henri Verbeet
5d55a5894c vkd3d-shader/spirv: Handle "BitEnum" operands. 2025-03-10 14:47:03 +01:00
Henri Verbeet
00039ba629 vkd3d-shader/spirv: Handle "ValueEnum" operands. 2025-03-10 14:47:03 +01:00
Henri Verbeet
321154d25a vkd3d-shader/spirv: Handle "LiteralString" operands. 2025-03-10 14:47:03 +01:00
Henri Verbeet
0e092aef70 vkd3d-shader/spirv: Handle "LiteralInteger" operands. 2025-03-10 14:47:03 +01:00
Henri Verbeet
8afeb13035 vkd3d-shader/spirv: Handle "IdResultType" operands. 2025-03-10 14:47:03 +01:00
Henri Verbeet
b9e78f2e2e vkd3d-shader/spirv: Handle "IdResult" operands. 2025-03-10 14:47:03 +01:00
Henri Verbeet
e83f4f40f9 vkd3d-shader/spirv: Handle "IdRef" operands. 2025-03-10 14:47:03 +01:00
Henri Verbeet
bebc550f02 vkd3d-shader/spirv: Implement outputting opcode names. 2025-03-10 14:47:00 +01:00
Henri Verbeet
997f3f8266 vkd3d-shader/spirv: Implement outputting instruction offsets. 2025-03-10 14:45:06 +01:00
Giovanni Mascellani
8c785f1dc9 vkd3d-shader/spirv: Emit immediate words for unhandled instructions.
The assembler can parse these to reconstruct the original bytecode.
2025-03-10 14:45:06 +01:00
Nikolay Sivov
1417af2eab vkd3d-shader/fx: Add support for parsing numeric states in fx_2_0 passes.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-03-06 17:21:10 +01:00
Nikolay Sivov
fb76e5daa2 vkd3d-shader/fx: Add support for parsing fx_2_0 parameters.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-03-06 17:21:10 +01:00
Henri Verbeet
36b8186021 vkd3d-shader/fx: Handle parser failures in fx_parse(). 2025-03-06 17:19:28 +01:00
Henri Verbeet
a6fda3e65d vkd3d-shader/fx: Output error messages for invalid sizes. 2025-03-06 17:19:28 +01:00
Elizabeth Figura
18ca7affad vkd3d-shader/hlsl: Make min16uint into a first-class type.
And properly implement translation into some binary enumerations.
2025-03-06 17:15:15 +01:00
Elizabeth Figura
16be9181a0 vkd3d-shader/hlsl: Pass the correct type to base_type_get_semantic_equivalent(). 2025-03-06 17:15:15 +01:00
Elizabeth Figura
3cf4a4e95e vkd3d-shader/hlsl: Use common hlsl_type_is_integer() and hlsl_base_type_is_integer() helpers. 2025-03-06 17:15:15 +01:00
Elizabeth Figura
bd34ec1fb3 vkd3d-shader/hlsl: Emit the minimum-precision SFI0 flag. 2025-03-06 17:15:15 +01:00
Elizabeth Figura
6cdfe38319 vkd3d-shader/hlsl: Emit minimum-precision signatures. 2025-03-06 17:15:15 +01:00
Elizabeth Figura
c2ca6b6bdf vkd3d-shader/hlsl: Emit the minimum-precision global flag when minimum-precision semantics are used.
There are other things we need to check, but this is a start.
2025-03-06 17:15:15 +01:00
Elizabeth Figura
055625448b vkd3d-shader/hlsl: Add a hlsl_block_add_simple_load() helper. 2025-03-05 14:12:12 +01:00
Elizabeth Figura
d52df527ba vkd3d-shader/hlsl: Add a hlsl_block_add_load_index() helper. 2025-03-05 14:12:12 +01:00
Elizabeth Figura
7b486fe239 vkd3d-shader/hlsl: Return an error expr from hlsl_add_load_component() on allocation failure. 2025-03-05 14:12:12 +01:00
Elizabeth Figura
009f5765df vkd3d-shader/hlsl: Return void from hlsl_block_add_store_component(). 2025-03-05 14:12:12 +01:00
Elizabeth Figura
9e3ac35669 vkd3d-shader/hlsl: Pass the target block to hlsl_new_store_component(). 2025-03-05 14:12:12 +01:00
Henri Verbeet
5ab5a721a1 vkd3d-shader/spirv: Do not sign-extend *ptr in vkd3d_spirv_build_string().
"char" is (potentially) signed, so casting it to uint32_t will
sign-extend it. Because we use |= to assign it to "word", and don't
otherwise mask out the higher bits either, we effectively set subsequent
bytes in the same word to 0xff for input bytes > 0x7f. That potentially
includes the \0 terminator. For example, "é" (U+00e9) is "\xc3\xa9"
when encoded as UTF-8, and would get us 0xffffffc3 instead of
0x0000a9c3.
2025-03-05 14:10:58 +01:00
Nikolay Sivov
871c9c61a5 vkd3d-shader/fx: Fix const strings array types.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-03-05 14:09:58 +01:00
Nikolay Sivov
1c43b7b55c vkd3d-shader/fx: Add support for parsing fx_2_0 annotations.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-03-05 14:02:09 +01:00
Nikolay Sivov
db7c22d9d6 vkd3d-shader/fx: Parse technique and pass blocks for fx_2_0.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-03-05 14:01:53 +01:00
Anna (navi) Figueiredo Gomes
50254c284b vkd3d-shader: Parse angle bracket initializer in state blocks.
While fxc allows full expressions inside the angle brackets, we don't parse that
yet as it'd be quite a mess to properly do so with yacc, and I'm not aware of any
game doing so in their shaders.
2025-03-03 18:00:23 +01:00
Anna (navi) Figueiredo Gomes
9809bda0e5 tests/hlsl: Add angle bracket state block syntax test. 2025-03-03 18:00:23 +01:00
Nikolay Sivov
9f09ac6893 vkd3d-shader/fx: Fix condition when printing literal constant arguments.
To reproduce:

float4 v;

SamplerState s
{
    BorderColor = 0.1 + v*0.2;
};

Expression should use more than one literal constant,
as a scalar in operation that involves a vector.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-03-03 17:54:17 +01:00
Giovanni Mascellani
aa032f31bb vkd3d: Split Vulkan debug messages.
So that they do not get truncated if they're too long.
2025-03-03 17:53:17 +01:00
Elizabeth Figura
e76c596d56 vkd3d-shader/hlsl: Add a hlsl_block_add_simple_store() helper. 2025-03-03 17:48:03 +01:00
Elizabeth Figura
fc4f440245 vkd3d-shader/hlsl: Add a hlsl_block_add_store_index() helper. 2025-03-03 17:48:03 +01:00
Elizabeth Figura
eafc97bcb3 vkd3d-shader/hlsl: Pass the target block to hlsl_new_load_component(). 2025-03-03 17:48:03 +01:00
Elizabeth Figura
d053f3665d vkd3d-shader/hlsl: Pass a block to hlsl_new_void_expr(). 2025-03-03 17:48:03 +01:00
Elizabeth Figura
662d60ad6b vkd3d-shader/hlsl: Add a hlsl_block_add_expr() helper. 2025-03-03 17:48:03 +01:00
Francisco Casas
f24cc55c14 vkd3d-shader/hlsl: Remove lower_nonfloat_exprs().
The only purpose it has at this point is wrapping integer DIV in casts,
which can be moved to lower_division().
2025-03-03 17:47:42 +01:00
Francisco Casas
7cb1970952 vkd3d-shader/hlsl: Don't cast all expressions to float.
Instead, allow half, bool, int, and uint, expressions that map to the
same float op to reach sm1_generate_vsir_instr_expr().
2025-03-03 17:26:15 +01:00
Anna (navi) Figueiredo Gomes
0ce2b1359f tests/hlsl: Add lower sm1 saturate test. 2025-03-03 17:25:20 +01:00
Henri Verbeet
57518d5312 ci: Install libjson-perl. 2025-03-02 17:08:51 +01:00
Giovanni Mascellani
8297ea9aa6 vkd3d/device: Require VK_KHR_zero_initialize_workgroup_memory when appropriate.
That extension (and the corresponding feature) must be enabled when
the Initializer operand is used for workgroup variables.
2025-02-26 16:11:50 +01:00
Nikolay Sivov
e746a4c12f vkd3d-shader/fx: Improve state object nesting for the fx -> text output.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-02-24 16:19:07 +01:00
Nikolay Sivov
09226543fe vkd3d-shader/fx: Implement parsing complex value and index expressions.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-02-24 16:19:07 +01:00
Henri Verbeet
58aed8fd0d vkd3d-shader/fx: Use vkd3d_string_buffer_print_f32() in parse_fx_4_numeric_value().
Instead of "%f". vkd3d_string_buffer_print_f32() will use sufficient
precision to represent the stored value exactly, and will use '.' as
decimal separator regardless of the current locale.
2025-02-24 16:19:07 +01:00
Elizabeth Figura
2989373212 vkd3d-shader/hlsl: Add a hlsl_block_add_binary_expr() helper. 2025-02-24 16:19:07 +01:00
Elizabeth Figura
858b6a3e0b vkd3d-shader/hlsl: Add a hlsl_block_add_cast() helper. 2025-02-24 16:19:07 +01:00
Elizabeth Figura
2e09257d94 vkd3d-shader/hlsl: Add a hlsl_block_add_unary_expr() helper. 2025-02-24 16:19:07 +01:00
Elizabeth Figura
b7ea23303e vkd3d-shader/hlsl: Add a hlsl_block_add_float_constant() helper. 2025-02-24 16:19:07 +01:00
Elizabeth Figura
e830cdee71 vkd3d-shader/hlsl: Inline add_pow_expr().
The helper is used in one place.
2025-02-24 16:19:07 +01:00
Conor McCarthy
439652f023 tests: Replace test_vs_ps_relative_addressing() with a shader runner test.
Besides simply being more compact, this allows the test to cover more
shader types, perhaps most notably DXIL.
2025-02-24 16:19:01 +01:00
Henri Verbeet
1fd89abcc3 vkd3d-shader: Enable DXIL support in the default configuration. 2025-02-24 15:10:08 +01:00
Henri Verbeet
73c0356861 tests: Add a shader model 6 signature reflection test for different types. 2025-02-24 15:10:08 +01:00
Henri Verbeet
fe4143ad19 vkd3d-shader/dxil: Generate I/O signatures with 16-bit component types for native 16-bit shaders.
Which incidentally matches the I/O signatures from the DXBC container.
2025-02-24 15:10:08 +01:00
Henri Verbeet
f5d702b09a vkd3d-shader/dxbc: Validate component types in shader_parse_signature(). 2025-02-24 15:10:08 +01:00
Henri Verbeet
b8d740ebfc vkd3d-shader/dxbc: Output messages for invalid semantic name references in shader_parse_signature(). 2025-02-24 15:10:08 +01:00
Henri Verbeet
3bcdb85ddc vkd3d-shader/dxbc: Set the "elements_capacity" field as well in shader_parse_signature().
Leaving it as 0 mostly ends up doing the right thing in practice, but isn't
quite right.
2025-02-24 15:10:08 +01:00
Giovanni Mascellani
2feb3a3bba vkd3d: Take the root signature from shaders when creating graphics pipelines.
If the root signature wasn't explicitly specified.

This fixes a failure in The Touryst.
2025-02-20 16:00:55 +01:00
Giovanni Mascellani
42b65e80cf tests: Test embedding the root signature in shaders for graphics pipelines. 2025-02-20 15:59:22 +01:00
Henri Verbeet
0796af7b4b vkd3d: Avoid vkd3d_shader_parse_input_signature(). 2025-02-20 15:57:26 +01:00
Henri Verbeet
2e62e9ea7e vkd3d-shader: Handle arrayed elements in vkd3d_shader_signature_from_shader_signature(). 2025-02-20 15:57:26 +01:00
Henri Verbeet
ce5164e26e tests: Add a signature reflection test for arrayed inputs and outputs. 2025-02-20 15:57:26 +01:00
Henri Verbeet
4e28d1c658 vkd3d-shader/dxbc: Do not extract I/O signatures for DXIL shaders.
The DXIL parser doesn't need them.
2025-02-20 15:57:26 +01:00
Henri Verbeet
f4a3d17269 vkd3d-shader/dxil: Avoid using the I/O signatures from the DXBC container.
We currently generate our own I/O signatures inside the DXIL parser, but
use the element counts from the DXBC container signatures to allocate
the input_params/output_params/patch_constant_params arrays. That
happens to work for well-behaved inputs, but it's asking for trouble.
2025-02-20 15:57:26 +01:00
Henri Verbeet
970a1a2b35 vkd3d-shader/dxbc: Update the vkd3d_shader_parse_input_signature() documentation for dxbc-dxil shaders. 2025-02-20 15:57:26 +01:00
Elizabeth Figura
d5a2ff5c12 vkd3d-shader/hlsl: Add a hlsl_block_add_int_constant() helper. 2025-02-20 15:56:31 +01:00
Elizabeth Figura
992d20def3 vkd3d-shader/hlsl: Add a hlsl_block_add_uint_constant() helper. 2025-02-20 15:50:13 +01:00
Elizabeth Figura
79ad8c9354 vkd3d-shader/hlsl: Handle error instructions in hlsl_new_swizzle().
We already check for error instructions when parsing swizzles, but if allocation
fails at codegen time we would like to avoid asserting when subsequently
constructing a swizzle.
2025-02-20 15:49:40 +01:00
Elizabeth Figura
4072aa4a4b vkd3d-shader/hlsl: Remove the type equality assertions in hlsl_new_ternary_expr().
Similar to d1c2ae3f0e, this is a bit too strict
and may prevent e.g. simultaneous use of float and float1 at codegen time.

However, in this case the inciting factor is that in the case of allocation
failure at codegen time, we would like to allow one or more arguments to have
error type.
2025-02-20 15:48:25 +01:00
Elizabeth Figura
ba868ed4a6 vkd3d-shader/hlsl: Skip transformation passes on error.
The primary motivation here is to avoid needing to worry about instructions
potentially pointing to the preallocated error instruction in the case of
allocation failure.

This doesn't cover all passes, but none of the other passes make assumptions
about instruction sources.
2025-02-20 15:48:24 +01:00
Francisco Casas
153b7c8460 vkd3d-shader/hlsl: Run folding passes again after lower_nonconstant_array_loads.
This is because lower_nonconstant_array_loads() can potentially turn
nonconstant loads into constant loads, allowing copy-prop to turn these
loads into previous instructions, which might help other passes as well.

This patch lowers the number of required temps for the following ps_2_0
shader from 19 to 16:

    int i;
    float3x3 mats[4];

    float4 main() : sv_target
    {
        return mul(mats[i], float3(1, 2, 3)).xyzz;
    }
2025-02-20 15:44:09 +01:00
Francisco Casas
e60c89c532 tests: Test unused invalid samples with a static sampler. 2025-02-20 15:44:09 +01:00
Francisco Casas
321fda9c26 vkd3d-shader/hlsl: Only use the temp copy for variables that are written.
This can save a significant amount of temp registers because it allows to
avoid referencing the temp (and having to store it) when not needed.

For instance, this patch lowers the number of required temps for the
following ps_2_0 shader from 24 to 19:

    int i;
    float3x3 mats[4];

    float4 main() : sv_target
    {
        return mul(mats[i], float3(1, 2, 3)).xyzz;
    }

Also, it is needed for SM1 vertex shader relative addressing since
non-constant loads are required to be directly on the uniform ('c'
registers) instead of the temp, and non-constant loads cannot be
transformed by copy propagation.
2025-02-20 15:44:09 +01:00
Elizabeth Figura
8e6ddb0c1a vkd3d-shader/hlsl: Don't mark extern variables with an explicit first_write or last_read.
Fix the last few places that care.
2025-02-20 15:44:09 +01:00
Francisco Casas
1d74ff075e vkd3d-make/hlsl: Trace the number of registers allocated in allocate_temp_registers(). 2025-02-20 15:44:04 +01:00
Nikolay Sivov
f830ac1206 vkd3d-shader/preproc: Do not attempt to load empty included files.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-02-20 15:40:34 +01:00
Giovanni Mascellani
07b7975d09 vkd3d: Put all root descriptors in a single Vulkan descriptor set when using Vulkan heaps.
Since 4a94bfc2f6 we segregate
different D3D12 descriptor types in different Vulkan descriptor sets.
This change was introduced to reduce descriptor wasting when
allocating a new descriptor pool; that can be very useful when
using virtual heaps, which have to often cycle through many
descriptors, but it is expected to have limited impact for Vulkan
heaps, given that in that case most descriptors are allocated through
the descriptor heap rather than through the command allocator.

Instead, it has a rather detrimental effect with Vulkan heaps,
because it tends to use many more Vulkan descriptor sets than
necessary, often with just a handful of descriptors each. This
causes a regression on some Vulkan implementations that support
too few descriptor sets.

With this change we revert to a situation similar to before,
stuffing all the descriptors that do not live in a root
descriptor table in as few descriptor sets as possible (at most
one or two, depending on whether push descriptors are used).
2025-02-19 17:58:23 +01:00
Giovanni Mascellani
6415c6b0e0 vkd3d: Rename push_descriptor_set to root_descriptor_set.
Soon it won't be used necessarily for push descriptors anymore, but
it will still contain root descriptors.
2025-02-19 17:57:15 +01:00
Conor McCarthy
67d8cf744c tests/hlsl: Add a conditional 16-bit test. 2025-02-19 17:53:57 +01:00
Conor McCarthy
36f9510bb3 tests/hlsl: Add interstage interface 16-bit tests. 2025-02-19 17:52:05 +01:00
Conor McCarthy
6ee650f316 tests/hlsl: Add a typed SRV load 16-bit test. 2025-02-19 17:48:38 +01:00
Conor McCarthy
2b325d3b59 tests/hlsl: Add a TGSM 16-bit test. 2025-02-19 17:47:29 +01:00
Conor McCarthy
94b8747da4 tests/hlsl: Add a sampler 16-bit test. 2025-02-19 17:46:05 +01:00
Conor McCarthy
e355cdbae0 tests/hlsl: Add typed buffer SRV 16-bit tests. 2025-02-19 17:44:59 +01:00
Giovanni Mascellani
a7337bc999 vkd3d: Require extension VK_KHR_maintenance2.
We're already implicitly using it for image layouts in which
either depth or stencil is writeable and the other is not.
Correspondingly, add the _KHR suffix in those cases, so the
extension usage is more evident.

According to the Vulkan Hardware Database, only four reports
without this extension were filed since 2023, and all of them
for configurations we likely don't target.
2025-02-19 17:41:30 +01:00
Francisco Casas
604fe3ccee tests/test-driver: Merge the same consecutive tags togeter. 2025-02-19 17:36:19 +01:00
Francisco Casas
681b839419 tests/test-driver: Group together tags in the same line and shader model. 2025-02-19 17:36:19 +01:00
Francisco Casas
72b603780c tests/test-driver: Print the shader model for the detailed output of the hlsl backend. 2025-02-19 17:36:19 +01:00
Francisco Casas
3aecbc5ac1 vkd3d-shader/hlsl: Also dump preprocessed shaders.
This could be useful since there are many shaders that contain `#include`
directives or use parameter-defined macros and we can't reproduce bugs
from the source alone.
2025-02-19 17:34:24 +01:00
Giovanni Mascellani
665c29f0be vkd3d-shader/tpf: Allow I/O index ranges to not intersect a signature element for a given register.
The current TPF validator enforces that for each register involved
in a DCL_INDEX_RANGE instruction there must be a signature element
for that register and the DCL_INDEX_RANGE write mask. This is an
excessively strong request, and causes some shaders from The Falconeer
to be invalidly rejected.

The excessively strong check was needed to avoid triggering a bug
in the I/O normaliser. Since that bug is now solved, the check
can be relaxed.
2025-02-19 17:30:25 +01:00
Giovanni Mascellani
4b84fb486b vkd3d-shader/ir: Handle index ranges that do not touch a signature element for each register.
A good part of the I/O normaliser job is to merge together signature
elements that are spanned by DCL_INDEX_RANGE instructions. The
current algorithm assumes that each index range touches exactly
one signature element for each index spanned by the range. The
assumption is used in shader_signature_merge() in the form of
expecting that, if the index range is N registers long, then,
once you find the first signature element of an index range, the
other elements that will have to be merged with it are exactly the
following N-1 according to the order given by
signature_element_register_compare() or
signature_element_mask_compare(), depending on the signature type.

This doesn't necessarily happen. For example, The Falconeer has a
few hull shaders in which this happens:

    hs_fork_phase
    dcl_hs_fork_phase_instance_count 13
    dcl_input vForkInstanceId
    dcl_output o4.z
    dcl_output o5.z
    dcl_output o6.z
    dcl_output o7.z
    dcl_output o12.z
    dcl_output o13.z
    dcl_output o14.z
    dcl_output o15.z
    dcl_output o16.z
    dcl_output o17.z
    dcl_output o18.z
    dcl_output o19.z
    dcl_output o20.z
    dcl_temps 1
    dcl_index_range o4.z 17
    iadd r0.x, vForkInstanceId.x, l(4)
    ult r0.y, vForkInstanceId.x, l(4)
    movc r0.x, r0.y, vForkInstanceId.x, r0.x
    mov o[r0.x + 4].z, l(0)
    ret

Here the index range "skips" o8.z through o11.z, because those
registers only use mask .xy. The current algorithm fails on such
a shader.

Even depending on the signature element order doesn't look ideal.
I don't have a full counterexample for that, but it looks fragile,
especially given that the register allocation algorithm in FXC is
notoriously full of unexpected corner cases.

We solve both problems by slightly changing the architecture of
the normaliser: first we move computing the masks for the merge
signature element from signature_element_range_expand_mask(),
which is executed while merging signature, to
io_normaliser_add_index_range(), which is executed before merging
signatures. Then, while we are merging signatures, we can decide
for each single signature element whether it has to be retained
or not, and how it should be patched. The algorithm becomes
independent of the order, because each signature element can be
processed individually.
2025-02-19 17:30:00 +01:00
Giovanni Mascellani
b5350f9387 vkd3d-shader/ir: Use a structure to record range data in the I/O normaliser.
In order to make it able to have other fields.
2025-02-19 17:01:54 +01:00
Giovanni Mascellani
ec7bac7ba7 vkd3d-shader/ir: Report errors in the I/O normaliser instead of asserting.
The assumptions the I/O normaliser makes on its input program are
rather intricated. In theory the VSIR validator checks should be
strong enough, but the validator isn't run by default anyway.
Whether the TPF parser validation is strong enough is not
completely clear to me, and considering that the I/O normaliser
could end up being used on different programs as well it's
probably better to revalidate locally just in case.
2025-02-19 17:01:54 +01:00
Giovanni Mascellani
8887501042 tests: Test I/O index ranges not intersecting a signature element for a given register.
Since this test depend on the specific code generated by the
native d3dcompiler we add the possibility to specify a "raw"
shader using a hex format. When the shader assembler is finally
available they should be replaced with assembly code.
2025-02-19 17:01:17 +01:00
Giovanni Mascellani
84a59fe4c0 tests: Enable tessellation shaders in the Vulkan shader runner. 2025-02-19 16:22:04 +01:00
Henri Verbeet
985d317e0e Release 1.15. 2025-02-19 12:00:00 +01:00
Henri Verbeet
872a96e599 vkd3d-shader/ir: Remove vForkInstanceId and vJoinInstanceId declarations in vsir_program_flatten_hull_shader_phases().
Commit 4717775abb removed the code turning
the corresponding DCL_INPUT instructions into NOPs, presumably because
vsir_program_remove_io_decls() now already removes them. That function
only removes the instructions though, not the declarations as such; we
now need to remove these from the "io_dcls" bitmap instead.
2025-02-19 10:44:18 +01:00
Henri Verbeet
e0df4cdc6d include: Add missing VKD3D_FORCE_32_BIT_ENUM enum elements. 2025-02-19 10:43:39 +01:00
Henri Verbeet
86462db9ed include: Add vkd3d_shader_scan_hull_shader_tessellation_info to the list of chained compilation structures. 2025-02-18 17:48:47 +01:00
Henri Verbeet
751f8b313c vkd3d-compiler: Introduce "dxbc-fx" as a source type.
Commit 949708450b introduced support for
effect binaries embedded in DXBC containers, but only when using
auto-detection to determine the source type. That's undesirable;
although auto-detection is convenient for interactive use, it's not
necessarily suitable for use in e.g. scripts. It also meant this wasn't
listed through --print-source-types.
2025-02-18 17:47:22 +01:00
Henri Verbeet
a169ae05e8 vkd3d-compiler: Store the source type as a struct source_type_info pointer. 2025-02-18 17:47:22 +01:00
Henri Verbeet
1cf6e8a85d vkd3d-compiler: Store the target type as a struct target_type_info pointer. 2025-02-18 17:47:22 +01:00
Conor McCarthy
c3555a34dc tests/hlsl: Add structured buffer UAV 16-bit tests. 2025-02-12 20:03:50 +01:00
Conor McCarthy
504bdcc8bb tests/hlsl: Add a raw buffer UAV 16-bit test. 2025-02-12 20:00:33 +01:00
Conor McCarthy
163801507c tests/hlsl: Add typed buffer UAV 16-bit tests. 2025-02-12 19:59:19 +01:00
Conor McCarthy
7ee6101291 tests/hlsl: Add GetDimensions() 16-bit tests. 2025-02-12 19:56:21 +01:00
Conor McCarthy
498e86fb86 tests/hlsl: Add constant buffer 16-bit tests. 2025-02-12 19:49:28 +01:00
Henri Verbeet
940c67f521 vkd3d: Avoid freeing the input signature twice on error paths in d3d12_pipeline_state_init_graphics().
This used to be safe enough before commit
b5ac6ac636, although that was never guaranteed
by the API.
2025-02-12 19:44:10 +01:00
Conor McCarthy
1b7340a6ed tests/hlsl: Add a numeric types 16-bit test. 2025-02-10 13:19:16 +01:00
Conor McCarthy
49a683f260 tests/hlsl: Add arithmetic float16 tests. 2025-02-10 13:19:16 +01:00
Conor McCarthy
becb749792 tests/hlsl: Add arithmetic int16 tests. 2025-02-10 13:19:16 +01:00
Conor McCarthy
2a0d49bb58 tests/hlsl: Add more arithmetic uint16 tests. 2025-02-10 13:19:16 +01:00
Elizabeth Figura
fe52e69662 vkd3d-shader/hlsl: Use a block in hlsl_normalize_binary_exprs(). 2025-02-05 13:53:53 +01:00
Elizabeth Figura
d7cd33fd88 vkd3d-shader/hlsl: Use a block in prepend_input_var_copy(). 2025-02-05 13:53:53 +01:00
Elizabeth Figura
b7d7deb983 vkd3d-shader/hlsl: Pass the block to add_zero_mipmap_level(). 2025-02-05 13:18:42 +01:00
Elizabeth Figura
602103dcf0 vkd3d-shader/hlsl: Handle error instructions in add_switch(). 2025-02-05 13:18:42 +01:00
Elizabeth Figura
fb290f3847 vkd3d-shader/hlsl: Add an add_switch() helper. 2025-02-05 13:18:42 +01:00
Shaun Ren
2f77d56b77 tests: Test signature reflection for patch inputs in hull/domain shaders. 2025-02-03 16:36:21 +01:00
Shaun Ren
ec6b4ed4ff vkd3d-shader/hlsl: Generate vsir registers from patch variable derefs. 2025-02-03 16:36:16 +01:00
Shaun Ren
3fb241d4d6 tests/shader_runner: Support the negation of tag matches. 2025-02-03 16:15:11 +01:00
Shaun Ren
2a1e3b100b vkd3d-shader/hlsl: Allocate semantic registers for patch variables. 2025-02-03 16:15:11 +01:00
Shaun Ren
2ddbc69f1a vkd3d-shader/hlsl: Declare semantics for patch variables in vsir. 2025-02-03 16:15:03 +01:00
Shaun Ren
f127f0849e vkd3d-shader/hlsl: Generate vsir signature entries for patch variables. 2025-02-03 16:04:21 +01:00
Shaun Ren
aa29d0a2e5 vkd3d-shader/tpf: Improve readability of compat mapping in sm4_sysval_semantic_from_semantic_name(). 2025-02-03 16:04:21 +01:00
Shaun Ren
29abe73918 vkd3d-shader/hlsl: Implement input semantic variable copies for patch variables.
The semantic variables from a patch parameter are split as usual, with
the difference being that the semantic variable being added is a patch
variable itself, with the type being the split variable type, and its
number of control points being equal to the original patch variable's
number of control points. It is then stored in the original patch
variable as follows:

  for (i = 0; i < n; ++i)
      patch[i][f] := <inputpatch-sem-var>[i]

where n is the number of control points of "patch", and f is the field
index in patch corresponding to "<inputpatch-sem-var>".

We use special prefixes, "inputpatch-" or "outputpatch-", when adding
the semantic patch variables, in order to distinguish them from
non-patch semantic variables of the same name.
2025-02-03 16:04:11 +01:00
Shaun Ren
f5d216835a vkd3d-shader/hlsl: Add an "is_patch_constant_func" field to struct hlsl_ctx.
In anticipation of the need for is_patch_constant_func in
sm4_generate_vsir_reg_from_deref(), in order to generate vsir
registers from InputPatch/OutputPatch dereferences.
2025-02-03 16:00:38 +01:00
Shaun Ren
0c8414c13f tests/hlsl: Test OutputPatch usage in patch constant functions. 2025-02-03 15:59:07 +01:00
Francisco Casas
0f7bb922ba tests/shader_runner: Pass the correct buffer size to swprintf() in dxc_compiler_compile_shader().
swprintf() expects the length of the buffer in WCHARs instead of bytes,
so ARRAY_SIZE() is used instead of sizeof().

This caused almost all tests to terminate abruptly with the following
message, in my machine:

*** buffer overflow detected ***: terminated
2025-02-03 15:58:19 +01:00
Elizabeth Figura
f1412e422c vkd3d-shader/hlsl: Handle error instructions in add_shader_compilation(). 2025-01-29 17:58:00 +01:00
Elizabeth Figura
fbd17266cf vkd3d-shader/hlsl: Do not abort on variable redefinition.
There is no harm in defining two variables with the same name.
2025-01-29 17:58:00 +01:00
Elizabeth Figura
e40d4a0e12 vkd3d-shader/hlsl: Factor out the error message into hlsl_add_var(). 2025-01-29 17:58:00 +01:00
Elizabeth Figura
2863d86bcc vkd3d-shader/hlsl: Do not define a separate scope for function parameters.
Remove the no longer needed code to detect redefinition in this case.
2025-01-29 17:58:00 +01:00
Elizabeth Figura
75ef230fbe tests: Add some stress tests for scope and variable definition. 2025-01-29 17:58:00 +01:00
Shaun Ren
7d1e4a40b1 tests/hlsl: Test hull shader control point function output parameters. 2025-01-29 17:53:26 +01:00
Shaun Ren
73183d33c5 tests/hlsl: Test passthrough hull shader control point function. 2025-01-29 17:52:49 +01:00
Shaun Ren
8a5559ab17 tests/hlsl: Test the syntax of InputPatch/OutputPatch variables. 2025-01-29 17:51:18 +01:00
Shaun Ren
f064a4022a vkd3d-shader/hlsl: Validate and record InputPatch/OutputPatch types. 2025-01-29 17:45:46 +01:00
Shaun Ren
f4d5e05d96 vkd3d-shader/hlsl: Parse InputPatch and OutputPatch objects. 2025-01-29 17:41:51 +01:00
Shaun Ren
32c081ba8c tests/hlsl: Test invalid const variables with no initializer. 2025-01-29 17:36:58 +01:00
Shaun Ren
a77dca528a vkd3d-shader/hlsl: Forbid declaring const variables with no initializer. 2025-01-29 17:36:58 +01:00
Elizabeth Figura
25c6d16b45 vkd3d-shader/hlsl: Use the casted value in exp(). 2025-01-28 13:14:50 +01:00
Conor McCarthy
033a0d29c5 tests/hlsl: Add some arithmetic uint16 shader tests. 2025-01-28 13:13:44 +01:00
Conor McCarthy
a5d4cbddac tests/hlsl: Pass a profile string instead of a shader type to dxc_compiler_compile_shader(). 2025-01-28 12:07:43 +01:00
Elizabeth Figura
40c225095f vkd3d-utils: Fix matrix packing precedence in D3DCompile2VKD3D().
D3DCOMPILE_PACK_MATRIX_ROW_MAJOR takes precedence over
D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR.
2025-01-27 15:00:26 +01:00
Conor McCarthy
f63254d905 vkd3d-shader/dxil: Handle SV_RenderTargetArrayIndex. 2025-01-27 14:52:28 +01:00
Conor McCarthy
a557ad0aea tests/hlsl: Add a test for SV_RenderTargetArrayIndex. 2025-01-27 14:52:28 +01:00
Elizabeth Figura
d049ea640f vkd3d-shader/hlsl: Implement broadcasts in constant folding.
Normally lower_broadcasts() takes care of this, but loop unrolling executes before other constant passes.
2025-01-27 14:48:03 +01:00
Elizabeth Figura
9065a1ee23 tests: Add another unrolling test. 2025-01-27 14:47:12 +01:00
Giovanni Mascellani
5bfcd81182 ci: Explicitly install SPIRV-Tools in the macOS CI environment. 2025-01-22 14:56:43 +01:00
Giovanni Mascellani
d36864500f vkd3d-common: Write a thread id in the log on macOS too. 2025-01-22 14:54:52 +01:00
Giovanni Mascellani
343022cdc1 vkd3d-shader/spirv: Interpret the write mask as a destination swizzle for double comparison operations.
This fixes a failure on a shader in Wild hearts.
2025-01-22 14:51:16 +01:00
Francisco Casas
4d18fb39b6 vkd3d-shader/hlsl: Don't forbid first base type cast on var assignments. 2025-01-22 14:46:02 +01:00
Francisco Casas
0a15ab702f vkd3d-shader/hlsl: Don't count cast to param type on IN as part of OUT var's lhs.
If the parameter is HLSL_STORAGE_IN, we add a cast from the arg to the
param type so that it can enter the function, however this cast should
not be considered part of the lhs on the implicit assignment that happens
if the var is also HLSL_STORAGE_OUT.
2025-01-22 14:39:20 +01:00
Francisco Casas
b55fe1950e vkd3d-shader/hlsl: Support non-size-changing lhs casts. 2025-01-22 14:38:10 +01:00
Francisco Casas
c2e224c5fb vkd3d-shader/hlsl: Delay lowering complex casts until after parse time.
While so far it has been posible to do this at parse time, this must
happen after knowing if the complex cast is on the lhs or not.

The modified tests show that before this patch we are currently
miscompiling when this happens, because a complex lhs cast is transformed
into a load, and add_assigment() just stores to the generated "cast"
temp.
2025-01-22 14:34:19 +01:00
Francisco Casas
dc37d90190 tests/hlsl: Add more function cast tests. 2025-01-22 14:29:54 +01:00
Francisco Casas
60f75cc542 tests/hlsl: Test partial assignments due to lhs casts. 2025-01-22 14:27:57 +01:00
Francisco Casas
51db232368 tests/hlsl: Add lhs cast tests. 2025-01-22 14:23:29 +01:00
Anna (navi) Figueiredo Gomes
c7b209124b vkd3d-shader/hlsl: Consider conversions across all parameters in function_compare().
For example, given two arguments, half3 and float, and two functions,
func(float, float) and func(float3, float3), fxc/d3dcompiler prefers to
widen both arguments to float3.
2025-01-22 14:18:54 +01:00
Anna (navi) Figueiredo Gomes
de57afd672 tests/hlsl: Add mixed argument size tests. 2025-01-22 14:17:17 +01:00
Elizabeth Figura
004a381d9c tests: Adjust abs.shader_test to pass with 1.x.
Pixel shader 1.x constants must be between -1 and 1, or they will be clamped,
even constants defined in the shader.

Also mark 1.x-specific features if any.
2025-01-22 13:43:38 +01:00
Elizabeth Figura
e805fe3e36 tests: Adjust array-size-expr.shader_test to pass with 1.x.
Pixel shader 1.x constants must be between -1 and 1, or they will be clamped,
even constants defined in the shader.

Also mark 1.x-specific features if any.
2025-01-22 13:43:38 +01:00
Elizabeth Figura
e5ec52d63b tests: Adjust array-parameters.shader_test to pass with 1.x.
Pixel shader 1.x constants must be between -1 and 1, or they will be clamped,
even constants defined in the shader.

Also mark 1.x-specific features if any.
2025-01-22 13:43:38 +01:00
Elizabeth Figura
e40b191943 tests: Adjust arithmetic-int.shader_test to pass with 1.x.
Pixel shader 1.x constants must be between -1 and 1, or they will be clamped,
even constants defined in the shader.

Also mark 1.x-specific features if any.
2025-01-22 13:43:38 +01:00
Elizabeth Figura
fb75c0530a tests: Adjust arithmetic-float-uniform.shader_test to pass with 1.x.
Pixel shader 1.x constants must be between -1 and 1, or they will be clamped,
even constants defined in the shader.

Also mark 1.x-specific features if any.
2025-01-22 13:43:38 +01:00
Elizabeth Figura
8b4f0f348a tests: Adjust arithmetic-float.shader_test to pass with 1.x.
Pixel shader 1.x constants must be between -1 and 1, or they will be clamped,
even constants defined in the shader.

Also mark 1.x-specific features if any.
2025-01-22 13:43:38 +01:00
Elizabeth Figura
5f55f5adc7 tests: Adjust angle-unit.shader_test to pass with 1.x.
Pixel shader 1.x constants must be between -1 and 1, or they will be clamped,
even constants defined in the shader.

Also mark 1.x-specific features if any.
2025-01-22 13:43:38 +01:00
Giovanni Mascellani
5b2d62e59a vkd3d: Explicitly call the appropriate waiting function in the fence worker.
Avoid using an indirect call that makes the code less clear for no
real advantage.
2025-01-21 14:09:29 +01:00
Shaun Ren
f3f2880261 vkd3d-shader/d3d-asm: Print vocp registers with subscript. 2025-01-21 14:05:21 +01:00
Shaun Ren
f0070cd595 tests: Test invalid out const parameters. 2025-01-21 14:03:44 +01:00
Shaun Ren
a9d7c65eb8 vkd3d-shader/hlsl: Forbid declaring parameters as both out and const.
Note that inout const parameters are allowed.
2025-01-21 14:03:44 +01:00
Giovanni Mascellani
22d0841412 vkd3d: Support signalling a fence once all outstanding work is submitted to Vulkan.
When the client acquires the Vulkan queue it has to ensure that
it is not submitting work before other work it depends on already
submitted through the Direct3D 12 API but currently in the internal
vkd3d queue. Currently we suggest to enqueue signalling a fence and
than wait for it before acquiring the Vulkan queue, which is
correct but excessive: it will wait not just for the work currently
in the queue to be submitted, but for it to be executed too,
introducing useless dependencies.

By adding a way to enqueue signalling a fence on the CPU side we
allow the client to wait for the currently outstanding work to
be submitted to Vulkan, but nothing more.
2025-01-21 14:02:22 +01:00
Giovanni Mascellani
bdb8291f6c vkd3d: Release queued fences when stopping the fence worker. 2025-01-21 13:45:33 +01:00
Giovanni Mascellani
ed7a846e2e vkd3d: Only call d3d12_fence_garbage_collect_vk_semaphores_locked() when using binary semaphores.
The function is specific to binary semaphores, and will unconditionally
access the "u.binary" field of struct vkd3d_signaled_semaphore.
2025-01-21 13:45:27 +01:00
Shaun Ren
4fbfb44681 vkd3d-shader/spirv: Emit the tessellator domain for domain shaders.
Commit 1ed8d907b3 inadvertently dropped
emitting the tessellator domain for domain shaders. Although Vulkan
environments allow us to write the tessellator domain from the hull
shader, the domain shader, or both, that's not generally true for OpenGL
environments.
2025-01-20 15:50:04 +01:00
Shaun Ren
802d7317cb vkd3d-shader/hlsl: Implement the InterlockedXor() intrinsic. 2025-01-20 15:42:45 +01:00
Shaun Ren
cbd504e888 vkd3d-shader/hlsl: Implement the InterlockedOr() intrinsic. 2025-01-20 15:42:45 +01:00
Shaun Ren
5b9634a7b7 vkd3d-shader/hlsl: Implement the InterlockedMin() intrinsic. 2025-01-20 15:42:43 +01:00
Shaun Ren
63fbe161f2 vkd3d-shader/hlsl: Implement the InterlockedMax() intrinsic. 2025-01-20 15:42:07 +01:00
Shaun Ren
b447fdce51 vkd3d-shader/hlsl: Implement the InterlockedExchange() intrinsic. 2025-01-20 15:41:07 +01:00
Shaun Ren
3fb47373a1 vkd3d-shader/hlsl: Implement the InterlockedCompareStore() intrinsic. 2025-01-20 15:41:07 +01:00
Shaun Ren
22ab08f4d8 vkd3d-shader/hlsl: Implement the InterlockedCompareExchange() intrinsic. 2025-01-20 15:41:07 +01:00
Shaun Ren
3b19a4aaf3 vkd3d-shader/hlsl: Implement the InterlockedAnd() intrinsic. 2025-01-20 15:41:07 +01:00
Shaun Ren
660a71ef22 vkd3d-shader/hlsl: Implement the InterlockedAdd() intrinsic. 2025-01-20 15:40:34 +01:00
Shaun Ren
5f943e9110 tests/hlsl: Add tests for valid destination types of atomic operations. 2025-01-20 15:30:54 +01:00
Shaun Ren
b3c13b443f tests/hlsl: Add tests to check the void return type of atomic ops. 2025-01-20 15:26:10 +01:00
Shaun Ren
728cf1dcfe tests/hlsl: Add tests to check the types of the value arguments of atomic ops. 2025-01-20 15:26:10 +01:00
Shaun Ren
c8b87f9bd9 tests/hlsl: Add a test for UAV InterlockedCompareExchange(). 2025-01-20 15:26:10 +01:00
Shaun Ren
24653b88f3 tests/shader_runner_gl: Bind buffer UAVs for compute shaders. 2025-01-20 15:25:56 +01:00
Shaun Ren
9fab6e4383 tests/shader_runner_gl: Add "opengl" tag. 2025-01-20 15:23:09 +01:00
Shaun Ren
31c3d46925 tests/shader_runner_vulkan: Check if create_shader_stage() fails in create_compute_pipeline(). 2025-01-20 14:59:12 +01:00
Conor McCarthy
10edcec030 vkd3d: Do not require the ALLOW_DEPTH_STENCIL flag for depth/stencil formats in GetCopyableFootprints(). 2025-01-20 14:37:13 +01:00
Conor McCarthy
e99906f05d vkd3d: Return correctly aligned depth/stencil sizes from GetCopyableFootprints(). 2025-01-20 13:59:46 +01:00
Conor McCarthy
1a4dedbc8d vkd3d: Return the correct depth/stencil plane format from GetCopyableFootprints(). 2025-01-20 13:45:16 +01:00
Giovanni Mascellani
17adde7f73 vkd3d: Describe DXGI_UNKNOWN as having one plane.
We're explicitly replacing zero with one in the only place where the
plane count being zero or one makes a difference. It also make sense:
UNKNOWN is used for buffers, which for all intents and purposes have one
plane.
2025-01-20 13:43:36 +01:00
Nikolay Sivov
a082daeb56 vkd3d-shader/hlsl: Implement the isinf() intrinsic.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-01-16 19:25:02 +01:00
Henri Verbeet
ce4f2728ba vkd3d-shader/msl: Get rid of a stray vkd3d_string_buffer_printf() in the VEC4 UINT immediate constant handling.
Uncovered by the ininf() test in the next commit. This is why we insist
on test coverage; unfortunately this one slipped through in
fd1beedc07.
2025-01-16 19:18:08 +01:00
Francisco Casas
cf19b4da49 vkd3d-shader/hlsl: Specialize lowering SM1 casts to int for vertex shaders.
Vertex shaders do not have CMP, so we use SLT and MAD.

For example, this vertex shader:

    uniform float4 f;

    void main(inout float4 pos : position, out float4 t1 : TEXCOORD1)
    {
        t1 = (int4)f;
    }

results in:

    vs_2_0
    dcl_position v0
    slt r0, c0, -c0
    frc r1, c0
    add r2, -r1, c0
    slt r1, -r1, r1
    mad oT1, r0, r1, r2
    mov oPos, v0

while we have the lower_cmp() pass, each time it is applied many
instructions are generated, so this patch introduces a specialized
version of the cast-to-int lowering for efficiency.
2025-01-16 18:48:35 +01:00
Francisco Casas
2d91bd9200 vkd3d-shader/hlsl: Properly lower casts to int for negative numbers.
While it looks complicated, it is what fxc/d3dcompiler does.

A shader as simple as:

    float4 f;

    float4 main() : sv_target
    {
        return (int4)f;
    }

results in the following instructions:

    ps_2_0
    def c1, 0, 1, 0, 0
    frc r0, c0
    cmp r1, -r0, c1.x, c1.y
    add r0, -r0, c0
    mov r2, c0
    cmp r1, r2, c1.x, r1
    add r0, r0, r1
    mov oC0, r0
2025-01-16 18:46:49 +01:00
Francisco Casas
4f7c117296 tests: Test casting negative floats to int.
Turns out we are not doing this correctly in SM1, because the rounding
should be to the number that is closer to zero and lower_casts_to_int()
doesn't do that.

A vertex shader test is added since in SM1 they must rely on the SLT
operation instead of the CMP operation.
2025-01-16 18:43:12 +01:00
Francisco Casas
efd7f2e014 vkd3d-shader/hlsl: Don't lower separate samples with texel offsets. 2025-01-14 17:59:50 +01:00
Francisco Casas
0a5955372a vkd3d-shader/hlsl: Lower separate SampleGrad() for SM1. 2025-01-14 17:59:50 +01:00
Francisco Casas
00b79cd781 tests: Test SampleGrad() on ps_3_0.
fxc compiles this method even without the backcompat option.

Furthermore, it even does it on ps_2_0 despite the fact that it maps to
a texldd instruction, which is not available on plain ps_2_0, nor ps_2_b,
only on ps_2_a and ps_3_0 according to documentation.

It is worth mentioning that the additional offset parameter is not
supported when lowering.
2025-01-14 17:59:50 +01:00
Giovanni Mascellani
c7e173a1ff vkd3d: Log the requested feature levels for D3D12_FEATURE_FEATURE_LEVELS. 2025-01-13 16:41:53 +01:00
Henri Verbeet
fb4b150f27 demos: Use the assembler to embed HLSL sources. 2025-01-13 16:39:35 +01:00
Henri Verbeet
4227858cfe vkd3d-shader/hlsl: Move RDEF generation to hlsl_codegen.c. 2025-01-10 20:03:14 +01:00
Francisco Casas
9b3b47b1b8 vkd3d-shader: Avoid left shifting signed integers. (ubsan)
Otherwise ubsan reports these errors on the bitwise.shader_test:

    libs/vkd3d-shader/hlsl_constant_ops.c:970:50: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
    libs/vkd3d-shader/hlsl_constant_ops.c:970:50: runtime error: left shift of negative value -12
2025-01-10 19:51:55 +01:00
Francisco Casas
8056058aa1 vkd3d-shader: Avoid passing NULL to memset(). (ubsan)
Otherwise ubsan reports errors such as:

    libs/vkd3d-shader/spirv.c:7266:5: runtime error: null pointer passed as argument 1, which is declared to never be null
2025-01-10 19:51:55 +01:00
Francisco Casas
7b23cd4d3c vkd3d-shader: Avoid passing NULL to qsort(). (ubsan)
Otherwise ubsan reports runtime errors such as:

    libs/vkd3d-shader/ir.c:4731:5: runtime error: null pointer passed as argument 1, which is declared to never be null
2025-01-10 19:51:55 +01:00
Francisco Casas
eaf4d0bfbf vkd3d-shader: Avoid passing NULL to memcpy(). (ubsan)
Otherwise when passing "-fsanitize=undefined" to the compiler, ubsan
reports such as:

   libs/vkd3d-shader/ir.c:3794:5: runtime error: null pointer passed as argument 1, which is declared to never be null
2025-01-10 19:51:43 +01:00
Elizabeth Figura
29bac62ba2 vkd3d-shader/hlsl: Move the "dimx" and "dimy" fields to the type-specific union. 2025-01-10 19:38:13 +01:00
Elizabeth Figura
392398794f vkd3d-shader/d3dbc: Do not access the type dimensions for non-numeric types. 2025-01-10 19:24:21 +01:00
Elizabeth Figura
1ff1a51e4b vkd3d-shader/hlsl: Avoid some uses of the default case when switching over hlsl_base_type.
Since we have -Wswitch, this forces the developer to update all relevant
switches when an enum case is added.

Places where the default is just a FIXME are left alone.
2025-01-10 19:24:10 +01:00
Shaun Ren
646087d54c vkd3d-shader/hlsl: Collect together terms with constant coefficients.
We apply distributivity to applicable expressions, specifically with
the following rewrite rules:

  (x OPL a) OPR (x OPL b) -> x OPL (a OPR b)
  (y OPR (x OPL a)) OPR (x OPL b) -> y OPR (x OPL (a OPR b))
  ((x OPL a) OPR y) OPR (x OPL b) -> (x OPL (a OPR b)) OPR y
  (x OPL a) OPR ((x OPL b) OPR y) -> (x OPL (a OPR b)) OPR y
  (x OPL a) OPR (y OPR (x OPL b)) -> (x OPL (a OPR b)) OPR y

where a, b are constants.
2025-01-10 19:17:43 +01:00
Henri Verbeet
b60995b106 tests/shader_runner: Do not use skip() for shader model requirements.
Like we did before commit 067e6deee4.
These skips aren't all that interesting; it's entirely intentional that
e.g. a 2.0-3.0 run wouldn't run 4.0 shaders.
2024-12-19 21:17:05 +01:00
Henri Verbeet
45d9a097e6 vkd3d-shader/hlsl: Move sm4_free_extern_resources() to hlsl_codegen.c. 2024-12-19 21:09:32 +01:00
Henri Verbeet
b143754360 vkd3d-shader/hlsl: Move sm4_get_extern_resources() to hlsl_codegen.c. 2024-12-19 21:09:32 +01:00
Henri Verbeet
0236c480e3 vkd3d-shader/hlsl: Make sm4_get_interpolation_mode() static. 2024-12-19 21:09:32 +01:00
Giovanni Mascellani
4f7eb890ef vkd3d-shader/ir: Validate OUTCONTROLPOINT source parameters. 2024-12-19 21:06:13 +01:00
Giovanni Mascellani
495e10e93b vkd3d-shader/ir: Validate INCONTROLPOINT source parameters. 2024-12-19 21:06:13 +01:00
Giovanni Mascellani
513609ef0e vkd3d-shader/ir: Validate INPUT source parameters. 2024-12-19 21:06:13 +01:00
Giovanni Mascellani
23d4bd1dae vkd3d-shader/ir: Validate PATCHCONST source parameters using a uniform helper. 2024-12-19 21:06:13 +01:00
Giovanni Mascellani
67420aa8b6 vkd3d-shader/ir: Validate OUTPUT source parameters using a uniform helper. 2024-12-19 21:06:13 +01:00
Giovanni Mascellani
7de7025750 vkd3d-shader/ir: Disallow array signature elements for normalisation levels < SM6. 2024-12-19 21:06:13 +01:00
Giovanni Mascellani
922af42aca tests/hlsl: Add some clip/cull distance tests. 2024-12-19 20:54:56 +01:00
Anna (navi) Figueiredo Gomes
d5ed4df254 tests/shader_runner: Add a "mesa<23.3" tag. 2024-12-19 20:34:55 +01:00
Henri Verbeet
31ea11fb0e tests/shader_runner: Ignore the "backcompat" option for shader model 5.1+. 2024-12-19 12:24:02 +01:00
Elizabeth Figura
d164752efc vkd3d-shader/d3dbc: Introduce d3dbc_parse_register(). 2024-12-18 17:30:16 +01:00
Elizabeth Figura
3c53293028 vkd3d-shader/ir: Separate VKD3DSPR_OUTPUT and VKD3DSPR_TEXCRDOUT.
This simplifies the IR.
2024-12-18 17:30:16 +01:00
Elizabeth Figura
8132239ed2 vkd3d-shader/ir: Separate VKD3DSPR_ADDR and VKD3DSPR_TEXTURE.
This simplifies the IR.
2024-12-18 17:30:16 +01:00
Elizabeth Figura
0df5dea653 vkd3d-shader/d3d-asm: Define register names in a table. 2024-12-18 17:30:16 +01:00
Elizabeth Figura
65f3f56f63 vkd3d-shader/d3dbc: Normalize to a single VKD3DSPR_CONST register set when reading.
We don't need VKD3DSPR_CONST2 et al in the IR, even for disassembly.
2024-12-18 17:30:16 +01:00
Elizabeth Figura
118617916a vkd3d-shader: Explicitly translate between d3dbc and vsir register types. 2024-12-18 17:30:16 +01:00
Elizabeth Figura
dd450c526f tests/d3d12: Make the dtof test a bit more interesting. 2024-12-18 17:30:16 +01:00
Elizabeth Figura
efe686105d vkd3d-shader/spirv: Correctly implement DTOU. 2024-12-18 17:30:16 +01:00
Elizabeth Figura
4130ce5bb9 vkd3d-shader/spirv: Correctly implement DTOI. 2024-12-18 17:30:16 +01:00
Elizabeth Figura
f416713608 vkd3d-shader/spirv: Correctly implement DTOF. 2024-12-18 17:30:16 +01:00
Francisco Casas
825784322d vkd3d-shader/ir: Properly lower texldp. 2024-12-18 17:30:15 +01:00
Francisco Casas
02fc26507b tests/hlsl: Test tex2Dproj(). 2024-12-18 17:29:10 +01:00
Francisco Casas
7cc802afd7 vkd3d-shader/ir: Properly lower texldb. 2024-12-18 17:27:43 +01:00
Francisco Casas
59df26af79 vkd3d-shader/hlsl: Lower sample lods for SM1.
For SM1 the lod bias should be in src0.w.
2024-12-18 17:27:43 +01:00
Anna (navi) Figueiredo Gomes
f09ac4959e vkd3d-shader/hlsl: Implement the GatherCmp() methods. 2024-12-18 17:27:43 +01:00
Anna (navi) Figueiredo Gomes
fd8bcc188f tests/hlsl: Add GatherCmp() tests. 2024-12-18 17:27:43 +01:00
Conor McCarthy
8d479d2ea6 vkd3d-shader/dxil: Implement DX intrinsic EvalCentroid. 2024-12-18 17:27:43 +01:00
Conor McCarthy
1bb3b13c0a vkd3d-shader/dxil: Implement DX intrinsic EvalSampleIndex. 2024-12-18 17:27:43 +01:00
Giovanni Mascellani
ed552e4519 tests/hlsl: Add tests for the EvaluateAttribute*() intrinsics.
Based on earlier tests by Conor McCarthy.
2024-12-18 17:27:31 +01:00
Giovanni Mascellani
a68fd1b0de vkd3d-shader/ir: Simplify shader_register_normalise_arrayed_addressing().
The two branches do essentially the same thing, but in different
ways and each one omitting different details. In particular there
is no need to discriminate on whether the register is a relative
address, we can just copy the NULL pointer.
2024-12-17 16:44:00 +01:00
Giovanni Mascellani
3db458697e vkd3d-shader/ir: Remove a redundant assignment.
The hull shader control point normalisation pass already ensures
that output registers in the control point phase have two
indices (the control point index and the register index).
2024-12-17 16:44:00 +01:00
Henri Verbeet
e8cc288426 vkd3d-shader/hlsl: Move CTAB generation to hlsl_codegen.c. 2024-12-17 16:42:53 +01:00
Henri Verbeet
c681673993 vkd3d-shader/d3dbc: Separate writing the comment bytecode from write_sm1_uniforms().
Consistent with how D3DXFindShaderComment() allows looking up comments
by tag. This also makes it a little easier to move CTAB generation out
of d3dbc.c.
2024-12-17 16:42:53 +01:00
Giovanni Mascellani
00538c377e vkd3d-shader/ir: Validate OUTCONTROLPOINT destination parameters. 2024-12-17 16:39:32 +01:00
Giovanni Mascellani
3dc7f322cc vkd3d-shader/ir: Validate INCONTROLPOINT destination parameters. 2024-12-17 16:39:32 +01:00
Giovanni Mascellani
7d87b4e869 vkd3d-shader/ir: Validate OUTPUT destination parameters. 2024-12-17 16:39:32 +01:00
Giovanni Mascellani
b194e5dc4e vkd3d-shader/ir: Validate PATCHCONST destination parameters using a uniform helper. 2024-12-17 16:39:32 +01:00
Giovanni Mascellani
38a5c905db vkd3d-shader/ir: Validate INPUT destination parameters using a uniform helper. 2024-12-17 16:39:32 +01:00
Giovanni Mascellani
8d4b790eb2 vkd3d-shader/ir: Represent information about I/O registers with a table.
It makes the code quite longer, but also easier to read and extend
with further properties.

A (desirable) side effect of this commit is that it is checked
whether I/O register types are legal depending on the shader type
and phase, while before that was assumed.

This commit introduces enum vsir_io_reg_type and enum vsir_phase
which shadow enum vkd3d_shader_register_type and enum
vkd3d_shader_opcode, with the goal of making the data tables
smaller.
2024-12-17 16:39:32 +01:00
Elizabeth Figura
27c7776947 tests: Use fail(sm<5) instead of [require] for uav-atomics. 2024-12-17 16:37:41 +01:00
Elizabeth Figura
8fcbbfb8b1 tests/shader_runner: Test versions where the compilation result changes.
Adjust the algorithm for deciding for which profiles to test compilation.

We first ensure that if the compilation result changes (most often as the result
of a feature introduced in a specific version), we test the versions immediately
on either side of the change, to validate that vkd3d-shader is emulating the
same version behaviour.

We then ensure that we are testing at least one version from each set of sm1,
sm4, and sm6.
2024-12-17 16:35:09 +01:00
Elizabeth Figura
067e6deee4 tests/shader_runner: Test HLSL compilation in a separate pass.
Mainly in order to not waste time compile-testing the same version
more than once [as we do with e.g. the d3d11 and d3d12 runners, or
d3d12, GL, and Vulkan].
2024-12-17 16:24:00 +01:00
Elizabeth Figura
e91c07e1de tests/shader_runner: Record HLSL todo/fail state for each shader model.
When a shader fails to compile for a range of versions, we want to validate that
we are correctly implementing that behaviour. E.g. if a feature requires shader
model 5.0, we should validate that it compiles correctly with 5.0 (which we do),
but also that it *fails* to compile with 4.1 (which we do not).

The obvious and simple solution is to simply run compile tests for each version.
There are, however, at least 12 versions of HLSL up to and including 6.0, at
least 10 of which are known to introduce new features. Shader compilation takes
about 10-15% of the time that draw and dispatch does, both for native and
(currently) vkd3d. Testing every version for every shader would add a
noticeable amount of time to the tests.

In practice, the interesting versions to test for most shaders are:

* At least one from each range 1-3, 4-5, and 6. It's common enough for the
  semantics of the HLSL to differ between bytecode formats, or for features to
  be added or removed across those boundaries.

* If the shader requires a given feature, we want to test both sides of the cusp
  to ensure we're requiring the same version for the feature.

In practice this is 3 or 4 versions, which is measurably less than the 12 we'd
otherwise be running.

In order to achieve this goal of testing only the 3 or 4 interesting versions
for a shader, we need to know what version is actually required for a feature.
This is encoded in the shader itself using e.g. [pixel shader fail(sm<5)].

This patch therefore implements the first step towards this goal, namely,
determining which versions succeed and fail, so we can figure out which ones are
interesting.

We could require the test writer to specify which versions are interesting ahead
of time (e.g. "for version in 2.0 4.1 5.0 6.0") but this is both redundant (and
there are a *lot* of tests that need some feature gate) and easy for a test
writer to get wrong by missing interesting versions.
2024-12-17 16:18:21 +01:00
Elizabeth Figura
de615609dc vkd3d-shader/d3dbc: Use struct vkd3d_shader_instruction instead of struct sm1_instruction. 2024-12-16 17:11:57 +01:00
Elizabeth Figura
77ac13e6b9 vkd3d-shader/d3dbc: Use struct vkd3d_shader_src_param instead of struct sm1_src_register. 2024-12-16 17:11:57 +01:00
Elizabeth Figura
1e43088662 vkd3d-shader/d3dbc: Use struct vkd3d_shader_dst_param instead of struct sm1_dst_register. 2024-12-16 17:11:57 +01:00
Henri Verbeet
c4f69f4d3d vkd3d-shader/hlsl: Prefer overload candidates without component count widening. 2024-12-16 17:09:40 +01:00
Henri Verbeet
64bb4150f0 vkd3d-shader/hlsl: Prefer overload candidates without component type narrowing. 2024-12-16 17:09:40 +01:00
Henri Verbeet
32d432ab5e vkd3d-shader/hlsl: Prefer overload candidates with matching component types. 2024-12-16 17:09:40 +01:00
Henri Verbeet
6b8878377f vkd3d-shader/hlsl: Prefer overload candidates with matching component type classes. 2024-12-16 17:09:40 +01:00
Henri Verbeet
63fce3062e vkd3d-shader/hlsl: Prefer overload candidates without component count narrowing. 2024-12-16 17:09:40 +01:00
Henri Verbeet
cdf6100fe5 tests: Add yet more overload resolution tests. 2024-12-16 17:09:40 +01:00
Elizabeth Figura
5827197246 tests/shader_runner: Don't bother distinguishing directive substrings.
Consider ']' a terminator for any string.
2024-12-12 17:28:45 +01:00
Elizabeth Figura
830bdd0037 tests/shader_runner: Use a separate variable for shader type. 2024-12-12 17:26:49 +01:00
Elizabeth Figura
edb36c078f tests/shader_runner: Use is_todo instead of separate shader states. 2024-12-12 17:26:37 +01:00
Giovanni Mascellani
dd0ed989a1 vkd3d-shader/d3dbc: Normalise I/O register write masks when not disassembling.
Sometimes SM1-3 shaders contain write masks that exceed the
signature element masks. That happens because SM1-3 shaders do not
have a concept of signature and signature masks, and OTOH aren't
always able to express any given write mask.

In VSIR we don't want to deal with I/O register masks exceeding the
corresponding signature element mask or usage mask, because, for
instance, for higher shader models it can complicate dealing with
DCL_INDEX_RANGE. In order to have uniform rules for all shader
models we normalise masks coming from SM1-3 shaders.

We don't do that normalisation when disassembling, in order to
preserve the expected output.
2024-12-12 17:21:49 +01:00
Giovanni Mascellani
64126a00c3 vkd3d-shader/ir: Give more meaningful names to I/O normalisation levels.
The previous names "not normalised" and "fully normalised" have meanings
which are likely to change with time. OTOH including a description of the
normalisation level in the enumerant seems excessive. Relating
normalisation levels to shader model versions might be a reasonable
compromise.
2024-12-12 17:21:49 +01:00
Elizabeth Figura
09095403ac vkd3d-shader/hlsl: Store swizzles in vsir format.
The previous format matched sm1 and sm4, but if we're going to be feeding
everything through vsir, we want vsir's format.
2024-12-12 17:20:23 +01:00
Elizabeth Figura
474a0ac4e2 vkd3d-shader/hlsl: Use swizzle helpers in more places. 2024-12-12 17:11:53 +01:00
Elizabeth Figura
a905a78a96 vkd3d-shader/hlsl: Use a structure for matrix swizzles. 2024-12-12 17:11:27 +01:00
Elizabeth Figura
70e2148fcb vkd3d-shader/hlsl: Document matrix swizzles. 2024-12-12 16:56:52 +01:00
Victor Chiletto
ed6061dfae vkd3d-shader/hlsl: Drop the _ir_ infix from enum hlsl_loop_unroll_type. 2024-12-12 16:54:07 +01:00
Victor Chiletto
a1d995e740 vkd3d-shader/hlsl: Unroll loops with conditional jumps. 2024-12-12 16:54:04 +01:00
Victor Chiletto
351d58a95b vkd3d-shader/hlsl: Partially defer continue resolution.
We need 'for' iter blocks to be separate for loop unrolling.
2024-12-12 16:41:34 +01:00
Victor Chiletto
5d8448a44e vkd3d-shader/hlsl: Remove loop_unrolling_find_unrollable_loop().
Since loop unrolling doesn't clone the entire program anymore, we can
express it as a hlsl_transform_ir() transform.
2024-12-12 16:41:34 +01:00
Victor Chiletto
de3a365fea vkd3d-shader/hlsl: Do not clone the entire program for loop unrolling. 2024-12-12 16:41:34 +01:00
Victor Chiletto
0a8c4a6fa2 vkd3d-shader/hlsl: Run copy propagation incrementally during loop unrolling. 2024-12-12 16:41:34 +01:00
Victor Chiletto
6c3a60cc54 vkd3d-shader/hlsl: Constant fold casts to boolean. 2024-12-12 16:41:34 +01:00
Victor Chiletto
7bee33f948 vkd3d-shader/hlsl: Allow copy propagation to be stopped early. 2024-12-12 16:41:34 +01:00
Victor Chiletto
3cb9e8dc3b vkd3d-shader/hlsl: Explicitly track the copy propagation state stack. 2024-12-12 16:41:18 +01:00
Elizabeth Figura
77843aa837 vkd3d-shader/ir: Always initialise "*control_point_count" in vsir_signature_from_register_type().
Avoid a spurious -Wmaybe-uninitialized warning.
2024-12-11 15:33:06 +01:00
Shaun Ren
2c9cf7c78b vkd3d-shader/hlsl: Implement normalization of binary expressions.
We normalize binary expressions by attempting to group constants
together, in order to facilitate further simplification of the
expressions.

For any binary operator OP, non-constants x, y, and constants a, b, we
apply the following rewrite rules:

  a OP x -> x OP a, if OP is commutative.

  (x OP a) OP b -> x OP (a OP b), if OP is associative.

  (x OP a) OP y -> (x OP y) OP a, if OP is associative and commutative.

  x OP (y OP a) -> (x OP y) OP a, if OP is associative.

Note that we consider floating point operations to be
non-associative.
2024-12-11 15:32:22 +01:00
Francisco Casas
65b67e84a8 vkd3d-shader/tpf: Remove hlsl_ctx from tpf_compiler.
This completes the hlsl->vsir->tpf translation.
2024-12-10 15:52:52 +01:00
Francisco Casas
f22729461e vkd3d-shader/hlsl: Store hull and domain shader properties in vsir_program.
The alternative to adding the vsir_program->tess_output_primitive and
vsir_program->tess_partitioning fields would be to emit the vsir
DCL_TESSELLATOR_OUTPUT_PRIMITIVE and DCL_TESSELLATOR_PARTITIONING
instructions, like DXIL does, but I think that the preference is to store
these kind of data directly in the vsir_program.
2024-12-10 15:52:52 +01:00
Francisco Casas
347e7a396d vkd3d-shader/hlsl: Generate CTAB outside sm1_generate_vsir().
For consistency with the sm4_generate_rdef() and sm4_generate_vsir()
functions.
2024-12-10 15:52:52 +01:00
Francisco Casas
ca9bb2e089 vkd3d-shader/hlsl: Generate RDEF outside tpf_compile(). 2024-12-10 15:52:52 +01:00
Francisco Casas
ecddc39b31 vkd3d-shader/hlsl: Store SM4 constant buffer declarations in vsir program. 2024-12-10 15:52:52 +01:00
Francisco Casas
aa3a716249 vkd3d-shader/hlsl: Allow lowering separate sampler arrays on deref offset 0. 2024-12-10 15:52:52 +01:00
Francisco Casas
2c9269ac3a vkd3d-shader/hlsl: Allocate samplers by decreasing bind count in SM1. 2024-12-10 15:52:50 +01:00
Francisco Casas
455846a305 vkd3d-shader/hlsl: Support combined samplers from texture arrays. 2024-12-10 15:51:43 +01:00
Francisco Casas
3a6bf3be24 vkd3d-shader/hlsl: Lower separated samplers for SM1.
The combined sampler is created as a SAMPLER instead of a TEXTURE
because that fits all our current infrastructure. The only problem is
that in the CTAB it must appear as a Texture, so the new field
hlsl_type.is_combined_sampler is added.

Co-authored-by: Elizabeth Figura <zfigura@codeweavers.com>
2024-12-10 15:51:43 +01:00
Francisco Casas
58d318719c tests: Test sampler array allocation. 2024-12-10 15:51:34 +01:00
Francisco Casas
a0a555878f tests: Add additional sampler allocation tests for SM1. 2024-12-10 14:02:00 +01:00
Giovanni Mascellani
c1df64b3a6 vkd3d-shader/ir: Check that signature elements do not conflict with each other. 2024-12-09 16:11:34 +01:00
Giovanni Mascellani
b6a00579a2 vkd3d-shader/ir: Validate the signature element register index, for some sysvals. 2024-12-09 16:11:34 +01:00
Giovanni Mascellani
59a3a8e2d6 vkd3d-shader/ir: Validate the signature element stream index. 2024-12-09 16:11:34 +01:00
Giovanni Mascellani
db5a3197b7 vkd3d-shader/ir: Validate the register index and count for signature elements. 2024-12-09 16:11:34 +01:00
Giovanni Mascellani
267c70fa55 vkd3d-shader/ir: Check that signature element masks are left-aligned with in a DCL_INDEX_RANGE. 2024-12-09 16:10:47 +01:00
Giovanni Mascellani
703da18955 vkd3d-shader/ir: Check that the DCL_INDEX_RANGE effective mask stabilizes after one iteration. 2024-12-09 16:10:47 +01:00
Henri Verbeet
bbeecfc835 vkd3d: Drop smaller pools in d3d12_command_allocator_reset_descriptor_pool_array().
Effectively consolidating them.
2024-12-09 16:10:22 +01:00
Francisco Casas
d2feb33b47 vkd3d-shader/hlsl: Store SM4 texture declarations in the vsir program. 2024-12-09 16:09:16 +01:00
Francisco Casas
1d290bf5db vkd3d-shader/hlsl: Store SM4 sampler declarations in the vsir program.
Looking at the implementation of shader_sm4_read_dcl_sampler(), vsir
stores the resource index range both in

    vkd3d_shader_instruction.declaration.sampler.range

and in the

    vkd3d_shader_instruction.declaration.sampler.src.reg.idx[1-2]

indexes, so we do the same.

It is also worth noting that for shader models lower than 5.1, vsir
has a normalization on the ins->declaration src register indexes.
Refer to the following comment:

    /* SM5.1 places a symbol identifier in idx[0] and moves
     * other values up one slot. Normalize to SM5.1. */

on shader_sm4_read_param().

This normalization is also added to the generated vsir instructions.
2024-12-09 16:09:16 +01:00
Francisco Casas
37a61bf41a vkd3d-shader/hlsl: Store the global flags in the vsir program. 2024-12-09 16:09:16 +01:00
Francisco Casas
d3108de72a vkd3d-shader/hlsl: Store ROV feature requirement in the vsir_program. 2024-12-09 16:09:16 +01:00
Francisco Casas
d9c4a257c2 vkd3d-shader/dxbc: Parse the SFI0 ROV requirement. 2024-12-09 16:09:16 +01:00
Henri Verbeet
b484288a82 vkd3d-shader/spirv: Parse SPIR-V instructions. 2024-12-09 16:09:16 +01:00
Giovanni Mascellani
ac2901d2cb vkd3d-shader/spirv: Parse the SPIR-V instruction schema. 2024-12-09 16:09:16 +01:00
Giovanni Mascellani
9b4f5dab77 vkd3d-shader/spirv: Parse the SPIR-V id bound. 2024-12-09 16:09:16 +01:00
Giovanni Mascellani
3f548ccf9c vkd3d-shader/spirv: Parse the SPIR-V generator magic number. 2024-12-09 16:09:16 +01:00
Giovanni Mascellani
e218dae281 vkd3d-shader/spirv: Parse the SPIR-V version number. 2024-12-09 16:08:33 +01:00
Giovanni Mascellani
6cac18e395 vkd3d-shader/spirv: Parse the SPIR-V magic number. 2024-12-09 15:41:24 +01:00
Giovanni Mascellani
49fba97b0a vkd3d-shader/spirv: Introduce a SPIR-V parser. 2024-12-09 14:22:24 +01:00
Conor McCarthy
f3fac95bb6 tests/hlsl: Add int64 wave op tests. 2024-12-09 14:21:49 +01:00
Conor McCarthy
50306a8b08 tests/hlsl: Add uint64 wave op tests. 2024-12-09 14:20:28 +01:00
Conor McCarthy
f0f8bb3f36 tests/hlsl: Add float64 wave op tests. 2024-12-09 14:17:05 +01:00
Feifan He
9d4bcc951d vkd3d-shader/msl: Implement VKD3DSIH_USHR. 2024-12-05 21:26:03 +01:00
Feifan He
138e7caa03 vkd3d-shader/msl: Implement VKD3DSIH_ISHR. 2024-12-05 21:26:03 +01:00
Feifan He
5d6ed0fa30 vkd3d-shader/msl: Implement VKD3DSIH_ISHL. 2024-12-05 21:26:03 +01:00
Feifan He
a425c242a4 vkd3d-shader/msl: Implement VKD3DSIH_MAD. 2024-12-05 21:26:03 +01:00
Feifan He
8e0de82c74 vkd3d-shader/msl: Implement support for VKD3DSPDM_SATURATE modifiers. 2024-12-05 21:26:03 +01:00
Feifan He
ebf5828542 vkd3d-shader/msl: Implement VKD3DSIH_ELSE. 2024-12-05 21:25:35 +01:00
Feifan He
bbe10dcf17 vkd3d-shader/msl: Implement VKD3DSIH_NOT. 2024-12-05 21:13:29 +01:00
Giovanni Mascellani
74fa51d57c vkd3d-shader/ir: Check that DCL_INDEX_RANGE ranges do not overlap with unrelated signature elements. 2024-12-05 21:06:31 +01:00
Giovanni Mascellani
aae0a74d60 vkd3d-shader/ir: Validate the DCL_INDEX_RANGE instruction. 2024-12-05 21:06:31 +01:00
Giovanni Mascellani
38c53dca08 vkd3d-shader/ir: Introduce a helper function to determine the signature for a register type. 2024-12-05 21:05:50 +01:00
Giovanni Mascellani
b5e1c45827 vkd3d-shader/ir: Validate the register type for registers used as relative addresses. 2024-12-05 21:00:43 +01:00
Giovanni Mascellani
abf7a91834 vkd3d-shader/ir: Validate the array index when it is statically known. 2024-12-05 21:00:43 +01:00
Giovanni Mascellani
239c88e8d3 vkd3d: Do not use more than a few million descriptors in Vulkan heap set layouts.
Currently, when using Vulkan heaps, we create descriptor set
layouts with as many descriptors as allowed by the Vulkan
implementation limits. For some implementations this can mean
hundreds of millions of descriptors or more, which is wasteful,
given that even on the best resource binding tier Direct3D 12
applications should not expect to have more than a million usable
descriptors.

Recently this began being a problem, because since Mesa 24.2.7
the Intel driver advertises more than 200 million descriptors,
but pipeline compilation takes linear RAM in the number of
descriptors declared in the pipeline layout. This means that
compiling even a simple shader requires 10-20 GB of RAM.

In order to avoid using too much memory, with this commit we clamp
the number of descriptors declared in the set layouts to how many
we actually need to guarantee tier 3 resource binding support.
2024-12-05 21:00:03 +01:00
Conor McCarthy
a43f6a6600 vkd3d: Create descriptor pools of geometrically increasing size.
Creating a pool of 16k descriptors is wasteful if an allocator only uses
a fraction of them, so start at 1k and double for each subsequent
allocation until 16k is reached.
2024-12-05 20:54:45 +01:00
Conor McCarthy
e729ceeb1a vkd3d: Create separate descriptor pools for each vkd3d descriptor type.
Now that our Vulkan descriptor sets contain only a single vkd3d
descriptor type, we're able to create descriptor pools containing only a
single vkd3d descriptor type as well. This avoids wasting unallocated
descriptors of one type when we run out of descriptors of another type.
2024-12-05 20:54:45 +01:00
Henri Verbeet
a97c7c1fda vkd3d: Introduce d3d12_descriptor_set_layout_init(). 2024-12-05 20:54:45 +01:00
Conor McCarthy
19c6df1adb vkd3d: Introduce vkd3d_vk_descriptor_pool_array_destroy_pools(). 2024-12-05 20:54:45 +01:00
Conor McCarthy
8dc9fe725a vkd3d: Introduce vkd3d_vk_descriptor_pool_array_pop(). 2024-12-05 20:54:45 +01:00
Conor McCarthy
9d46a1863b vkd3d: Introduce vkd3d_vk_descriptor_pool_array_push(). 2024-12-05 20:54:45 +01:00
Conor McCarthy
7c0ce25bb7 vkd3d: Introduce vkd3d_vk_descriptor_pool_array_push_array(). 2024-12-05 20:54:45 +01:00
Conor McCarthy
3c620e88a0 vkd3d: Introduce struct vkd3d_vk_descriptor_pool_array. 2024-12-05 20:54:45 +01:00
Conor McCarthy
4a94bfc2f6 vkd3d: Store only a single vkd3d descriptor type in each Vulkan descriptor set.
We currently create statically sized descriptor pools, shared among
different descriptor types. Once we're unable to allocate a descriptor
set from a pool, we create a new pool. The unfortunate but predictable
consequence is that when we run out of descriptors of one type, we waste
any unallocated descriptors of the other types.

Dynamically adjusting the pool sizes could mitigate the issue, but it
seems non-trivial to handle all the edge cases, particularly in
situations where the descriptor count ratios change significantly
between frames. Instead, by storing only a single vkd3d descriptor type
in each Vulkan descriptor set we're able to create separate descriptor
pools for each vkd3d descriptor type, which also avoids the issue.

The main drawback of using separate descriptor sets for each descriptor
type is that we can no longer pack all bounded descriptor ranges into a
single descriptor set, potentially leaving fewer descriptor sets
available for unbounded ranges. That seems worth it, but we may end up
having to switch to a more complicated strategy if this ends up being a
problem on Vulkan implementations with a very limited number of
available descriptor sets.
2024-12-05 20:54:45 +01:00
Elizabeth Figura
01117c716d vkd3d-shader/hlsl: Remove unused expr ops.
These correspond to specific SM1 opcodes which we don't use (and which the native compiler never uses either).
2024-12-04 14:38:32 +01:00
Elizabeth Figura
a3c74fd429 tests: Add a reflection test for shader model 4.0. 2024-12-04 14:37:33 +01:00
Giovanni Mascellani
82963035e9 vkd3d-shader/ir: Validate the control point index when it is statically known. 2024-12-04 14:36:36 +01:00
Feifan He
a06e664730 vkd3d-shader/msl: Implement VKD3DSIH_RSQ. 2024-12-04 14:26:20 +01:00
Feifan He
bc67f2eb75 vkd3d-shader/msl: Implement VKD3DSIH_MIN. 2024-12-04 14:26:20 +01:00
Feifan He
ab2cb43e15 vkd3d-shader/msl: Implement VKD3DSIH_MAX. 2024-12-04 14:26:20 +01:00
Feifan He
64ea033c81 vkd3d-shader/msl: Implement VKD3DSIH_LOG. 2024-12-04 14:26:20 +01:00
Feifan He
b1e6dbe83f vkd3d-shader/msl: Handle SV_IS_FRONT_FACE inputs. 2024-12-04 14:26:20 +01:00
Feifan He
568296c88f vkd3d-shader/msl: Implement VKD3DSIH_ROUND_NE. 2024-12-04 14:26:20 +01:00
Feifan He
610a11ddf8 vkd3d-shader/msl: Implement VKD3DSIH_IF and VKD3DSIH_ENDIF. 2024-12-04 14:26:20 +01:00
Feifan He
28068c9d4c vkd3d-shader/msl: Implement VKD3DSIH_ROUND_NI. 2024-12-04 14:26:20 +01:00
Elizabeth Figura
36fda8e28c vkd3d-shader: Correct the disassembly for POSITIONT. 2024-12-03 14:49:02 +01:00
Elizabeth Figura
3d6f836801 vkd3d-shader: Fix the disassembly names of IFC and BREAKC. 2024-12-03 14:49:02 +01:00
Elizabeth Figura
7a7dc4bf0e vkd3d-shader/d3dbc: Mark some more instructions as version-limited. 2024-12-03 14:47:00 +01:00
Elizabeth Figura
e2961a2e3c vkd3d-shader/d3dbc: Omit unnecessary instruction maximum versions. 2024-12-03 14:47:00 +01:00
Feifan He
a81a9fb7bc vkd3d-shader/msl: Implement VKD3DSIH_LTO. 2024-12-03 14:44:32 +01:00
Feifan He
24753747a1 vkd3d-shader/msl: Implement VKD3DSIH_EXP. 2024-12-03 14:44:32 +01:00
Feifan He
ac897781ba vkd3d-shader/msl: Implement VKD3DSIH_IEQ. 2024-12-03 14:44:32 +01:00
Feifan He
67dd1d2b0c vkd3d-shader/msl: Handle the VKD3DSIM_LINEAR interpolation modifier on inputs. 2024-12-03 14:42:49 +01:00
Feifan He
8ae6a04561 vkd3d-shader/msl: Implement VKD3DSIH_SQRT. 2024-12-03 14:42:27 +01:00
Feifan He
77ed788a60 vkd3d-shader/msl: Implement VKD3DSIH_DP2. 2024-12-03 14:42:27 +01:00
Feifan He
6f7ee57e29 vkd3d-shader/msl: Implement VKD3DSIH_DP4. 2024-12-03 14:42:27 +01:00
Feifan He
046e9b5286 vkd3d-shader/msl: Implement VKD3DSIH_DP3. 2024-12-03 14:42:19 +01:00
Henri Verbeet
74365417ac vkd3d-shader/hlsl: Output the candidates for ambiguous function calls. 2024-12-03 14:38:33 +01:00
Henri Verbeet
4ca4dc0b2a vkd3d-shader/hlsl: Introduce hlsl_dump_ir_function_decl(). 2024-12-03 14:38:33 +01:00
Henri Verbeet
0b726e4408 vkd3d-shader/hlsl: Introduce hlsl_dump_type(). 2024-12-03 14:38:33 +01:00
Henri Verbeet
d0e4331640 vkd3d-shader/hlsl: Use hlsl_error() instead of hlsl_fixme() for ambiguous function calls.
This changes the return code, and some tests start passing as a result.
2024-12-03 14:38:33 +01:00
Giovanni Mascellani
1c93d706d7 vkd3d-shader/ir: Merge removing I/O declarations in the general instruction lowering pass. 2024-12-03 14:36:13 +01:00
Giovanni Mascellani
4717775abb vkd3d-shader/ir: Remove I/O declarations before flattening hull shader phases. 2024-12-03 14:19:50 +01:00
Giovanni Mascellani
4ef946287c vkd3d-shader/ir: Remove I/O declarations before normalising hull shader control point I/O. 2024-12-03 14:19:50 +01:00
Giovanni Mascellani
66382f0d68 vkd3d-shader/ir: Remove I/O declarations before I/O normalisation. 2024-12-03 14:19:50 +01:00
Giovanni Mascellani
18e422dfe4 vkd3d-shader/ir: Encode I/O declarations in vsir_program.
Most I/O registers are already described by the shader signatures.
The registers that are not do not have any property other then
being used by the program or not, so they can be collectively
described with a bitmap.
2024-12-03 14:19:24 +01:00
Giovanni Mascellani
a92b602b33 vkd3d-shader/spirv: Merge emitting input and output registers.
The register storage class is now represented in
vkd3d_register_builtins, so the spirv_compiler_emit_io_register()
doesn't need to know it from the caller.
2024-12-03 13:48:39 +01:00
Elizabeth Figura
8bc9e15618 vkd3d-shader/hlsl: Translate invalid implicit-size arrays to an error type.
Instead of returning nonsense (such as, currently, a type with zero size).
In practice this improves error reporting for shaders such as the following:

void func(float x[])
{
    float y[] = {x};
}

Currently this outputs a nonsense

test.hlsl:1:19: E5002: Implicit size arrays not allowed in function parameters.
test.hlsl:3:7: E5002: Implicit size arrays need to be initialized.

With this patch the second warning is removed.
2024-12-03 12:39:27 +01:00
Elizabeth Figura
e060b47330 vkd3d-shader/hlsl: Return an error expression when a function is used as a variable. 2024-12-03 12:39:27 +01:00
Elizabeth Figura
c553c45f00 vkd3d-shader/hlsl: Move the numeric type check to add_constructor(). 2024-12-03 12:39:27 +01:00
Elizabeth Figura
97eac342d3 vkd3d-shader/hlsl: Do not abort parsing when invalid modifiers are used. 2024-12-03 12:39:27 +01:00
Elizabeth Figura
9c70348b39 vkd3d-shader/hlsl: Do not abort when modifying a const expression. 2024-12-03 12:39:27 +01:00
Giovanni Mascellani
3264378fa0 tests: Print the file name instead of the test name in test logs.
Some test programs, particularly the shader runner, are built from
many different files nowadays, and a line number is relatively
cumbersome to use if you don't know which file that line comes from.
2024-12-03 12:38:26 +01:00
Giovanni Mascellani
73be28a252 tests: Use plain skip() when skipping a test in the shader runner.
The context already gives the location in the .shader_test file.
2024-12-03 12:38:26 +01:00
Henri Verbeet
39cbef9e01 tests: Get rid of some redundant "glsl" todo's.
These are redundant either because we already have a broader tag like
"sm<6", or because the tests are never executed with the GLSL runner in
the first place.
2024-12-02 17:13:17 +01:00
Elizabeth Figura
d56601c8d0 vkd3d-shader/ir: Implement exponential fog. 2024-12-02 17:12:20 +01:00
Elizabeth Figura
1fbbc82f3a vkd3d-shader/ir: Allow controlling the fog source through a parameter. 2024-12-02 17:12:16 +01:00
Elizabeth Figura
fc98cb482f vkd3d-shader/ir: Add a couple of traces for signature remapping. 2024-12-02 17:12:13 +01:00
Elizabeth Figura
f86d1e72a4 vkd3d-shader/ir: Allow controlling fog through parameters.
Fog requires several parameters to even implement the most basic of
functionality correctly, so this commit is relatively large.
2024-12-02 17:12:06 +01:00
Elizabeth Figura
a1de406de4 vkd3d-shader/spirv: Handle SSA registers in spirv_compiler_get_register_info().
Instead of in spirv_compiler_emit_load_reg(). This allows arbitrary swizzles to
work and reduces the amount of duplicated code.
2024-12-02 17:08:43 +01:00
Feifan He
7d2819249b vkd3d-shader/msl: Implement support for the VKD3DSPR_DEPTHOUT register. 2024-11-30 14:25:10 +01:00
Feifan He
b7203b0bbe tests/shader_runner_metal: Implement clears. 2024-11-30 14:14:26 +01:00
Feifan He
004a6d3055 tests/shader_runner_metal: Implement depth texture and state. 2024-11-30 14:12:21 +01:00
Nikolay Sivov
949708450b vkd3d-compiler: Support fx_4_0 sources embedded in DXBC containers.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-11-30 14:03:50 +01:00
Feifan He
9619582d1b vkd3d-shader/msl: Implement VKD3DSIH_ROUND_Z. 2024-11-27 14:00:51 +01:00
Feifan He
778382cd94 vkd3d-shader/msl: Implement VKD3DSIH_ROUND_PI. 2024-11-27 14:00:51 +01:00
Feifan He
a7ae6404de vkd3d-shader/msl: Implement VKD3DSIH_FTOU. 2024-11-27 14:00:51 +01:00
Feifan He
9fd7f4f1ec vkd3d-shader/msl: Implement VKD3DSIH_UTOF. 2024-11-27 14:00:51 +01:00
Feifan He
ffbade9ed1 vkd3d-shader/msl: Implement VKD3DSIH_FTOI. 2024-11-27 14:00:50 +01:00
Feifan He
16409569fd vkd3d-shader/msl: Implement VKD3DSIH_ITOF. 2024-11-27 14:00:50 +01:00
Giovanni Mascellani
9e0c02a0ea vkd3d-shader/ir: Evaluate OUTCONTROLPOINT usage in the patch constant phase directly.
Instead of using DCL_INPUT.

The main goal here is to eventually get rid of the I/O
declaration instructions. A positive side effect is that we don't
add a useless barrier to shaders which have a DCL_INPUT instruction
in the patch constant phase but don't actually read OUTCONTROLPOINT
registers.
2024-11-27 13:59:39 +01:00
Giovanni Mascellani
1cfe23569c vkd3d-shader/ir: Synthesize the default control point phase in the HS control point I/O normaliser.
This makes it available to all backends, without requiring an
ad-hoc solution for each of them. It also gets rid of an
undocumented flag we're currently passing to
DCL_CONTROL_POINT_PHASE.
2024-11-27 13:57:09 +01:00
Francisco Casas
198c3dc7b9 vkd3d-shader/hlsl: Remove hlsl_ir_vsir_instruction_ref, again. 2024-11-27 13:03:15 +01:00
Francisco Casas
d6d6f37578 vkd3d-shader/hlsl: Migrate SM4 control flow instructions to the vsir program.
Translate the instructions that contain hlsl_blocks. Also move
other control flow instructions such as HS_CONTROL_POINT_PHASE and
RET to the vsir_program so that we can directly iterate over it now.
2024-11-27 13:02:53 +01:00
Francisco Casas
81fa4d45b9 vkd3d-shader/tpf: Apply extra bits to all conditional ops. 2024-11-27 12:54:27 +01:00
Francisco Casas
28ad600b43 vkd3d-shader/hlsl: Store SM4 jumps in the vsir program. 2024-11-27 12:54:15 +01:00
Giovanni Mascellani
2c3a7b0dd9 vkd3d-shader/ir: Validate the register type for DCL_OUTPUT_SIV instructions. 2024-11-25 20:51:29 +01:00
Giovanni Mascellani
3832e38ce0 vkd3d-shader/ir: Validate the register type for DCL_OUTPUT instructions. 2024-11-25 20:51:25 +01:00
Giovanni Mascellani
e7770eaaf6 vkd3d-shader/ir: Validate the register type for DCL_INPUT_PS_SGV instructions. 2024-11-25 20:48:39 +01:00
Giovanni Mascellani
1d9862261f vkd3d-shader/ir: Validate the register type for DCL_INPUT_PS_SIV instructions. 2024-11-25 20:48:39 +01:00
Giovanni Mascellani
09ede1e7f2 vkd3d-shader/ir: Validate the register type for DCL_INPUT_PS instructions. 2024-11-25 20:48:39 +01:00
Giovanni Mascellani
31f6b18c84 vkd3d-shader/ir: Validate the register type for DCL_INPUT_SGV instructions. 2024-11-25 20:48:39 +01:00
Giovanni Mascellani
fadaa69b92 vkd3d-shader/ir: Validate the register type for DCL_INPUT_SIV instructions. 2024-11-25 20:48:39 +01:00
Giovanni Mascellani
b007b1dd79 vkd3d-shader/ir: Validate the register type for DCL_INPUT instructions. 2024-11-25 20:48:39 +01:00
Giovanni Mascellani
a8c5f9e667 vkd3d-shader/dxil: Emit register SAMPLEMASK for output sysval SV_Coverage. 2024-11-25 20:47:24 +01:00
Giovanni Mascellani
c22812e20b vkd3d-shader/ir: Validate index count for OUTSTENCILREF registers. 2024-11-25 20:45:44 +01:00
Giovanni Mascellani
e367dc0783 vkd3d-shader/ir: Validate index count for WAVELANEINDEX registers. 2024-11-25 20:45:44 +01:00
Giovanni Mascellani
5b04a7973b vkd3d-shader/ir: Validate index count for WAVELANECOUNT registers. 2024-11-25 20:45:44 +01:00
Giovanni Mascellani
820a545950 vkd3d-shader/ir: Validate index count for GSINSTID registers. 2024-11-25 20:45:44 +01:00
Giovanni Mascellani
07b31761fb vkd3d-shader/ir: Validate index count for SAMPLEMASK registers. 2024-11-25 20:45:44 +01:00
Giovanni Mascellani
9f3bbad6bc vkd3d-shader/ir: Validate index count for COVERAGE registers. 2024-11-25 20:45:44 +01:00
Feifan He
71ce43313f vkd3d-shader/msl: Implement VKD3DSIH_MOVC. 2024-11-25 20:43:13 +01:00
Feifan He
32a507ace6 vkd3d-shader/msl: Implement VKD3DSIH_FRC. 2024-11-25 20:43:13 +01:00
Feifan He
154847c696 vkd3d-shader/msl: Implement VKD3DSIH_GEO. 2024-11-25 20:43:13 +01:00
Feifan He
38d7f8415d vkd3d-shader/msl: Implement support for VKD3DSPSM_NEG modifiers. 2024-11-25 20:43:13 +01:00
Feifan He
64ea19b7f7 vkd3d-shader/msl: Implement VKD3DSIH_DIV. 2024-11-25 20:43:13 +01:00
Feifan He
b7605f1c34 vkd3d-shader/msl: Implement VKD3DSIH_OR. 2024-11-25 20:43:13 +01:00
Feifan He
f2a32589ea vkd3d-shader/msl: Implement VKD3DSIH_INE. 2024-11-25 20:43:13 +01:00
Feifan He
a2d56c8bfc vkd3d-shader/msl: Implement VKD3DSIH_MUL. 2024-11-25 20:43:13 +01:00
Francisco Casas
4f549155c5 vkd3d-shader/hlsl: Store SM4 HLSL_RESOURCE_RESINFOs in the vsir program. 2024-11-24 00:01:03 +01:00
Francisco Casas
c89f503604 vkd3d-shader/hlsl: Store SM4 HLSL_RESOURCE_SAMPLE_INFOs in the vsir program. 2024-11-24 00:00:46 +01:00
Francisco Casas
4382af6e1b vkd3d-shader/hlsl: Store SM4 HLSL_RESOURCE_GATHERs in the vsir program. 2024-11-23 23:55:07 +01:00
Francisco Casas
42ce821603 vkd3d-shader/hlsl: Store SM4 HLSL_RESOURCE_SAMPLEs in the vsir program. 2024-11-23 23:52:24 +01:00
Francisco Casas
52b81f42eb vkd3d-shader/hlsl: Store SM4 HLSL_RESOURCE_LOADs in the vsir program. 2024-11-23 23:49:57 +01:00
Feifan He
fd1beedc07 vkd3d-shader/msl: Implement support for VSIR_DIMENSION_VEC4 immediate constants. 2024-11-23 23:43:42 +01:00
Feifan He
68d7470fc2 vkd3d-shader/msl: Implement VKD3DSIH_NEU. 2024-11-23 23:43:42 +01:00
Feifan He
65b0e13a1a vkd3d-shader/msl: Implement VKD3DSIH_AND. 2024-11-23 23:43:42 +01:00
Feifan He
4add058cd8 vkd3d-shader/msl: Implement support for VKD3DSPSM_ABS modifiers. 2024-11-23 23:43:42 +01:00
Feifan He
5bb7dcaba3 vkd3d-shader/msl: Implement support for VKD3DSPR_IMMCONST registers. 2024-11-23 23:43:42 +01:00
Feifan He
05b9331d0d vkd3d-shader/msl: Implement VKD3DSIH_ADD. 2024-11-23 23:43:42 +01:00
Nikolay Sivov
b314a9eb84 vkd3d-shader/fx: Remove newlines from the parser error messages.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-11-23 23:24:05 +01:00
Nikolay Sivov
3784919213 vkd3d-shader/fx: Implement parsing inline shader blobs.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-11-23 23:21:39 +01:00
Giovanni Mascellani
0f362ab720 vkd3d-shader/ir: Check that tessellation system value registers are consecutive. 2024-11-23 23:19:57 +01:00
Giovanni Mascellani
5894e79064 vkd3d-shader/ir: Check that all tessellation system values appear in the patch constant signature. 2024-11-23 23:19:57 +01:00
Giovanni Mascellani
0245d22c83 vkd3d-shader/ir: Validate index count for LOCALTHREADINDEX registers. 2024-11-23 23:15:40 +01:00
Giovanni Mascellani
050840f493 vkd3d-shader/ir: Validate index count for LOCALTHREADID registers. 2024-11-23 23:15:39 +01:00
Giovanni Mascellani
595fe9a7aa vkd3d-shader/ir: Validate index count for THREADGROUPID registers. 2024-11-23 23:15:39 +01:00
Giovanni Mascellani
fd9da5db2d vkd3d-shader/ir: Validate index count for THREADID registers. 2024-11-23 23:15:39 +01:00
Giovanni Mascellani
26251d02a9 vkd3d-shader/ir: Validate index count for TESSCOORD registers. 2024-11-23 23:15:39 +01:00
Giovanni Mascellani
f2659c14a2 vkd3d-shader/ir: Validate index count for JOININSTID registers. 2024-11-23 23:15:39 +01:00
Giovanni Mascellani
808b28b425 vkd3d-shader/ir: Validate index count for FORKINSTID registers. 2024-11-23 23:15:39 +01:00
Giovanni Mascellani
860bb59c89 vkd3d-shader/ir: Validate index count for OUTPOINTID registers. 2024-11-23 23:15:39 +01:00
Giovanni Mascellani
0c3c4e0563 vkd3d-shader/ir: Validate index count for PRIMID registers. 2024-11-23 23:15:39 +01:00
Francisco Casas
64bc0515e0 vkd3d-shader/hlsl: Add special allocation rules for FFACE and SAMPLE. 2024-11-23 23:13:13 +01:00
Francisco Casas
2c15015ec2 tests: Test allocation rules for FFACE and SAMPLE.
These seem to have their own interpolation mode.
2024-11-23 23:10:56 +01:00
Francisco Casas
ad5377f995 vkd3d-shader/hlsl: Add special allocation rules for PRIMID, RTINDEX, and VPINDEX.
These system values are bound to the same allocation rules as other
semantics: they can share registers with other semantics with the same
interpolation mode and they prefer forming shorter writemasks. However,
for some reason, these don't allow further semantics to share the same
register once allocated, except among themselves.
2024-11-23 23:10:46 +01:00
Francisco Casas
2c0773c9ad tests: Test signature reflection for PRIMID, RTINDEX and VPINDEX. 2024-11-23 22:57:23 +01:00
Giovanni Mascellani
e383834049 vkd3d-shader/ir: Check that tessellation system values only appear in the patch constant signature. 2024-11-21 19:28:46 +01:00
Giovanni Mascellani
018f3e8094 vkd3d-shader/ir: Validate tessellation system values for the given tessellator domain. 2024-11-21 19:28:46 +01:00
Giovanni Mascellani
1ed8d907b3 vkd3d-shader/ir: Keep track of the tessellator domain in struct vsir_program. 2024-11-21 19:28:46 +01:00
Giovanni Mascellani
49ec9add38 vkd3d-shader/ir: Check that semantic indices for tessellation system values are not duplicated. 2024-11-21 19:28:46 +01:00
Giovanni Mascellani
8d8de1db10 vkd3d-shader/ir: Validate the semantic index for tessellation system values. 2024-11-21 19:28:46 +01:00
Anna (navi) Figueiredo Gomes
9f3bbab2f0 vkd3d-shader/hlsl: Implement cast from bool to int for SM1. 2024-11-21 19:28:46 +01:00
Nikolay Sivov
1a6409cd5b vkd3d-shader/hlsl: Add parser support for stream-output object types.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-11-21 19:28:46 +01:00
Francisco Casas
13dfccc1c6 vkd3d-shader/hlsl: Store SM4 resource stores in the vsir program. 2024-11-21 19:28:46 +01:00
Francisco Casas
5b4af411f5 vkd3d-shader/hlsl: Store SM4 loads in the vsir program. 2024-11-21 19:28:46 +01:00
Francisco Casas
874ca85a95 vkd3d-shader/hlsl: Store SM4 stores in the vsir program. 2024-11-21 19:28:46 +01:00
Francisco Casas
5dedcff665 vkd3d-shader/tpf: Remove HLSL_IR_SWIZZLE handling. 2024-11-21 19:28:46 +01:00
Shaun Ren
843fc980b5 tests/shader_runner_gl: Implement tessellation support. 2024-11-21 19:27:51 +01:00
Shaun Ren
12ac1dd46b tests/shader_runner_vulkan: Enable patch list topology support. 2024-11-21 15:11:02 +01:00
Shaun Ren
e20b63c55e vkd3d-shader: Implement scanning hull shader tessellation information. 2024-11-21 15:03:02 +01:00
Shaun Ren
1f4d17a4a2 vkd3d-shader/dxil: Allow zero domain input control point count. 2024-11-21 14:56:23 +01:00
Victor Chiletto
3669763835 tests: Add more function overloading tests. 2024-11-21 14:52:17 +01:00
Henri Verbeet
5c00766eff Release 1.14. 2024-11-21 12:35:55 +01:00
Henri Verbeet
1f09f4fb3a include: Document the binary effect transformations supported by vkd3d_shader_compile(). 2024-11-21 12:32:17 +01:00
Giovanni Mascellani
05c87b02f6 vkd3d-shader/ir: Return an error when the FLAT_INTERPOLATION parameter is invalid. 2024-11-20 14:53:58 +01:00
Giovanni Mascellani
36510cd0be vkd3d-shader/ir: Move applying flat interpolation to a dedicated pass.
I/O normalisation is already a rather complicated pass that does a
lot of things, so it's better to keep anything not strictly
related to it somewhere else.
2024-11-20 14:53:47 +01:00
Feifan He
1efc0ac740 tests/shader_runner_metal: Implement draws. 2024-11-20 14:40:10 +01:00
Feifan He
14991f2e17 tests/shader_runner_metal: Create Metal constant buffers. 2024-11-20 14:40:10 +01:00
Feifan He
176e35b6cc tests/shader_runner_metal: Implement render target readback. 2024-11-20 14:40:10 +01:00
Feifan He
f0a864c8a2 tests/shader_runner_metal: Create Metal vertex buffers. 2024-11-20 14:40:10 +01:00
Feifan He
6d6cd8021e tests/shader_runner_metal: Create Metal render targets. 2024-11-20 14:40:10 +01:00
Feifan He
5a679a1af3 tests/shader_runner_metal: Create vertex descriptors. 2024-11-20 14:40:10 +01:00
Henri Verbeet
df86a2842a vkd3d-shader/msl: Implement VKD3DSIH_DCL_OUTPUT. 2024-11-20 14:40:10 +01:00
Feifan He
9e3b8ec98a vkd3d-shader/msl: Output the generated shader code. 2024-11-20 14:40:10 +01:00
Henri Verbeet
2669ae16ea vkd3d-shader/msl: Implement VKD3DSIH_DCL_OUTPUT_SIV. 2024-11-20 14:40:10 +01:00
Henri Verbeet
e6acf3090d vkd3d-shader/msl: Implement VKD3DSIH_DCL_INPUT. 2024-11-20 14:40:10 +01:00
Feifan He
40cccaccea tests/shader_runner_metal: Implement graphics shader compilation. 2024-11-20 14:40:10 +01:00
Feifan He
7a1d36ba05 vkd3d-shader/msl: Use pointers for constant buffer descriptors.
[[id]] attributes can not be applied to union references.
2024-11-20 14:40:10 +01:00
Feifan He
b29f1e6cdc vkd3d-shader/msl: Add the missing output register index in msl_generate_entrypoint_epilogue(). 2024-11-20 14:40:10 +01:00
Henri Verbeet
c246c8db79 tests/shader_runner_metal: Get rid of some stray semicolons. 2024-11-20 14:40:10 +01:00
Elizabeth Figura
0dc07f5cce vkd3d-shader: Silence a spurious -Wmaybe-uninitialized in vsir_program_insert_alpha_test(). 2024-11-14 14:12:13 +01:00
Elizabeth Figura
683e11aece vkd3d-shader/hlsl: Silence a spurious -Wmaybe-uninitialized in sm4_generate_vsir_instr_dcl_semantic(). 2024-11-14 14:12:13 +01:00
Giovanni Mascellani
72394d9ae3 vkd3d: Use WARN rather than ERR in vkd3d_instance_init().
ERR is used to indicate internal inconsistencies in vkd3d. Here that's
not the case, we simply have to forward the error condition to the
caller.

This fixes failures on the CI with llvmpipe, because the build we use is
compiled without support for VK_KHR_surface and related extensions.
2024-11-14 14:09:04 +01:00
Giovanni Mascellani
c010fb63a1 ci: Update Mesa to version 24.2.4.
This fixes a number of CI failures with llvmpipe.
2024-11-13 16:23:45 +01:00
Giovanni Mascellani
4c9821e5d5 tests: Mark a conditional rendering test as buggy on llvmpipe.
Similarly to RADV, this is a kind of perverted situation: in
principle Vulkan doesn't allow vkCmdResolveImage() to be
executed conditionally (i.e., it is unaffected by conditional
execution), which means that vkd3d cannot implement conditional
rendering for ResolveSubresource(), hence the todo. However,
like RADV, llvmpipe apparently violates the specification and
still executes the image resolution command conditionally. So
that's a llvmpipe bug, even if one that helps us doing the right
thing.
2024-11-13 16:19:06 +01:00
Henri Verbeet
92fa68cb07 tests/shader_runner: Slightly simplify dxc handling. 2024-11-13 16:18:36 +01:00
Conor McCarthy
2996ad6bd2 vkd3d-shader/dxil: Implement DX intrinsic SampleIndex. 2024-11-13 16:18:13 +01:00
Nikolay Sivov
21681489ed vkd3d-shader/fx: Implement parsing states objects.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-11-13 16:15:09 +01:00
Conor McCarthy
3d53d90d4b vkd3d-shader/ir: Add a secondary sort by sysval for signature element register merges.
Fixes output signature normalisation failures in Silent Hill 2 caused by
failure of shader_signature_find_element_for_reg().

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57359
2024-11-13 13:32:32 +01:00
Giovanni Mascellani
7412e66064 vkd3d-shader/spirv: Get rid of the "offset_component_count" field of struct vkd3d_spirv_resource_type.
The number of components needed for texel offsets is the number of
components needed to address a single image/layer of an array. I.e.,
"coordinate_component_count - 1" for array textures, and
"coordinate_component_count" for non-array textures.

This change will also fix sampling of cube textures with explicit
gradients. Because texel offsets are unsupported for cube textures,
"offset_component_count" is currently 0 for cube textures. However, the
SAMPLE_GRAD handler also uses "offset_component_count" to determine the
number of components needed for the explicit gradients, and SAMPLE_GRAD
is supposed to work with cube textures.

This commit fixes the compilation of shaders in Star Wars Jedi:
Survivor.
2024-11-12 19:12:47 +01:00
Giovanni Mascellani
c34dc81753 tests: Remove some todo markings on MoltenVK in interface-packing.shader_test.
I have to admit I'm not even sure of why most of those got marked
as todo in the first place. Running again now tests on commit
dff7c0e7b8 doesn't show all those
failures.
2024-11-11 15:55:11 +01:00
Giovanni Mascellani
a89ceb6590 tests/shader_runner_vulkan: Avoid using ok() for shader compilation failues in create_graphics_pipeline().
Using ok() may result in todo's succeeding when create_shader_stage()
succeeds, but vkCreateGraphicsPipelines() fails. There's not much point
in using ok() here in the first place though, because ultimately the
draw operation is going to fail when shader compilation failed.
2024-11-11 15:54:21 +01:00
Giovanni Mascellani
94900131a8 tests: Mark a couple of tests in register-reservations-numeric.shader_test as todo with MSL. 2024-11-11 15:25:02 +01:00
Henri Verbeet
756b98f093 vkd3d-shader/glsl: Implement VKD3DSIH_LD2DMS. 2024-11-06 22:57:12 +01:00
Henri Verbeet
ca42adbf6b vkd3d-shader/glsl: Handle SV_SAMPLE_INDEX inputs. 2024-11-06 22:56:02 +01:00
Henri Verbeet
3dbaf11f8c vkd3d-shader/glsl: Implement support for static texel offsets in shader_glsl_sample(). 2024-11-06 22:55:36 +01:00
Henri Verbeet
6ae4da02c9 vkd3d-shader/glsl: Implement VKD3DSIH_GATHER4_PO. 2024-11-06 22:53:55 +01:00
Henri Verbeet
466d849c72 vkd3d-shader/glsl: Implement support for VKD3D_SHADER_COMPONENT_INT outputs. 2024-11-06 22:53:31 +01:00
Francisco Casas
5df836c513 vkd3d-shader/hlsl: Store SM4 MOD in the vsir program. 2024-11-06 22:49:12 +01:00
Francisco Casas
30bc6965a2 vkd3d-shader/hlsl: Store SM4 DOT in the vsir program. 2024-11-06 22:48:13 +01:00
Francisco Casas
e8b373e3ff vkd3d-shader/hlsl: Store SM4 DIV in the vsir program. 2024-11-06 22:47:42 +01:00
Francisco Casas
24f4308982 vkd3d-shader/hlsl: Store SM4 MUL in the vsir program. 2024-11-06 22:45:46 +01:00
Francisco Casas
e4d36bd855 vkd3d-shader/hlsl: Store SM4 SAT in the vsir program. 2024-11-06 22:45:23 +01:00
Francisco Casas
2e3f4a01bf vkd3d-shader/hlsl: Store SM4 RCP in the vsir program. 2024-11-06 22:40:50 +01:00
Francisco Casas
3c4889add3 vkd3d-shader/hlsl: Store SM4 SIN and COS in the vsir program. 2024-11-06 22:38:04 +01:00
Francisco Casas
befba8e813 vkd3d-shader/hlsl: Store SM4 casts in the vsir program. 2024-11-06 22:27:49 +01:00
Giovanni Mascellani
026624a266 tests: Work around a Metal bug in switch.shader_test.
The Metal bug was reported to Apple as FB15617433. Since we don't
care specifically about that bug, I'm just tweaking the test so that
it doesn't hit that bad path any more.
2024-11-06 22:15:09 +01:00
Giovanni Mascellani
7450c4a368 tests: Mark some tests in wave-reconvergence.shader_test as buggy on MoltenVK. 2024-11-06 22:15:09 +01:00
Giovanni Mascellani
ba5c3b576e tests: Use the appropriate RTV format in f32tof16.shader_test. 2024-11-06 22:15:09 +01:00
Giovanni Mascellani
5639b54c1b tests: Mark fog.shader_test as todo with MSL. 2024-11-06 22:15:09 +01:00
Nikolay Sivov
9af17d4a9d vkd3d-shader/fx: Implement parsing the remaining fx_5_0 object types.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-11-06 22:14:03 +01:00
Nikolay Sivov
e5ba79b4f1 vkd3d-shader/hlsl: Implement the ByteAddressBuffer.Load*() methods.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-11-06 22:09:23 +01:00
Nikolay Sivov
1a28e7d9c6 vkd3d-shader/hlsl: Add parser support for the ByteAddressBuffer type.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-11-06 21:56:27 +01:00
Nikolay Sivov
8438aacc3b vkd3d-shader/spriv: Only lookup resource symbols for UAVs in the ld_raw/ld_structured handler.
We don't need them for SRVs. Worse, if we're using a combined
resource/sampler pair for the SRV, a separate resource symbol may not
even exist.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-11-06 21:47:08 +01:00
Conor McCarthy
76fd1388d8 vkd3d: Check the IASetVertexBuffers() view count against the device limits.
For example, current MoltenVK only supports 31 vertex buffers.
2024-11-06 21:43:32 +01:00
Elizabeth Figura
fb8660c196 vkd3d-shader/ir: Add an is_pre_rasterization_shader() helper. 2024-11-05 20:00:27 +01:00
Elizabeth Figura
4290d85397 vkd3d-shader/hlsl: Write all writemask components for PSIZE and FOG outputs.
Matching fxc/d3dcompiler.
2024-11-05 19:58:49 +01:00
Elizabeth Figura
a10ee075ff vkd3d-shader/ir: Force fog and point size to 1 component when normalizing I/O. 2024-11-05 19:57:41 +01:00
Elizabeth Figura
5a513ffcec vkd3d-shader/hlsl: Enforce FOG component count for sm1 VS output. 2024-11-05 19:53:24 +01:00
Elizabeth Figura
f50b20ddd6 vkd3d-shader/hlsl: Enforce PSIZE component count for sm1 VS output. 2024-11-05 19:53:24 +01:00
Elizabeth Figura
aa1ce9e295 tests: Add some tests for FOG and PSIZE writemask restrictions. 2024-11-05 19:53:24 +01:00
Francisco Casas
90a07ada8e vkd3d-shader/tpf: Use SCALAR swizzle dimension for RASTERIZER registers.
While we currently output instructions like this:

    sampleinfo_uint r0.x, rasterizer.xxxx

    > SAMPLE_INFO (111)
    0  0000100[len:4]  0000000000001[1]  00001101111[opcode:111]
    └─ 0  000[d3i:0]  000[d2i:0]  000[d1i:0]  01[idxs:1]  00000000[type:0]  0000[0]  0001[wmask:1]  00[swtype:0]  10[dim:2]
       └─ 00000000000000000000000000000000[0|0.0]
    └─ 0  000[d3i:0]  000[d2i:0]  000[d1i:0]  00[idxs:0]  00001110[type:14]  00000000[sw:0]  01[swtype:1]  10[dim:2]

FXC/d3dcompiler outputs instructions like this:

    sampleinfo o0.x, rasterizer.x

    > SAMPLE_INFO (111)
    0  0000100[len:4]  0000000000000[0]  00001101111[opcode:111]
    └─ 0  000[d3i:0]  000[d2i:0]  000[d1i:0]  01[idxs:1]  00000010[type:2]  0000[0]  0001[wmask:1]  00[swtype:0]  10[dim:2]
       └─ 00000000000000000000000000000000[0|0.0]
    └─ 0  000[d3i:0]  000[d2i:0]  000[d1i:0]  00[idxs:0]  00001110[type:14]  000000[0]  00[swcomp:0]  10[swtype:2]  10[dim:2]

Note the difference in swtype of the rasterizer src register.
2024-11-05 19:50:55 +01:00
Francisco Casas
950c381728 vkd3d-shader/hlsl: Store RASTERIZER_SAMPLE_COUNT in the vsir program.
Also, the profile check for GetRenderTargetSampleCount() is moved to
parse time.
2024-11-05 19:48:31 +01:00
Francisco Casas
ab60f4e082 vkd3d-shader/hlsl: Store simple SM4 expressions in the vsir program. 2024-11-05 19:35:52 +01:00
Francisco Casas
b4608e99e3 vkd3d-shader/tpf: Remove HLSL IR ABS handling. 2024-11-05 19:20:21 +01:00
Francisco Casas
6eda775047 vkd3d-shader/hlsl: Run sm4_generate_vsir_block() recursively.
This allows us to remove the HLSL IR version of an instruction when
the vsir version is properly implemented.
2024-11-05 19:20:21 +01:00
Shaun Ren
64c4a3a442 vkd3d-shader/hlsl: Store SM4 semantic declarations in the vsir program. 2024-11-05 19:19:22 +01:00
Nikolay Sivov
5ea946aa90 vkd3d-shader/hlsl: Accept multiple colon-separated attributes.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-11-05 18:23:31 +01:00
Giovanni Mascellani
794f4c30f4 ci: Error out on Objective-C warnings.
Except for the known uninteresting ones.
2024-11-04 17:02:32 +01:00
Francisco Casas
68311ef010 vkd3d-shader/hlsl: Store SM4 ABS instructions in the vsir program. 2024-11-04 17:00:54 +01:00
Francisco Casas
404644bad3 vkd3d-shader/hlsl: Introduce vsir_src_from_hlsl_node().
This allows constants to be inlined for sm4.
2024-11-04 16:36:28 +01:00
Francisco Casas
6f52bb6b1a vkd3d-shader/hlsl: Store SM4 swizzles in the vsir program. 2024-11-04 16:08:38 +01:00
Francisco Casas
2083d505c7 vkd3d-shader/tpf: Use instr.extra_bits for IF. 2024-11-04 15:37:46 +01:00
Henri Verbeet
e6c84862a8 vkd3d-shader/ir: Search for SV_TARGET0 vsir_program_insert_alpha_test().
As opposed to any SV_TARGET with register index 0. We care about the
semantic index here, not the register index.
2024-11-04 15:32:05 +01:00
Henri Verbeet
1b0248f31b vkd3d-shader/ir: Specifically search for SV_POSITION0 in vsir_program_insert_clip_planes(). 2024-11-04 15:30:44 +01:00
Conor McCarthy
51c37735a9 tests: Use state RESOLVE_SOURCE for readback from multisampled textures. 2024-11-04 15:30:11 +01:00
Elizabeth Figura
3681b83fb4 vkd3d-shader/fx: Fix checking for a GS with stream output. 2024-11-04 15:29:39 +01:00
Elizabeth Figura
7e4ab9c7c0 vkd3d-shader: Write zeroes for uninitialized outputs in vsir_program_remap_output_signature(). 2024-11-04 15:26:55 +01:00
Elizabeth Figura
e781abc3fb vkd3d-shader: Write uninitialized components of COLOR0 as 1. 2024-11-04 15:21:09 +01:00
Elizabeth Figura
cc9fcee676 vkd3d-shader: Reduce masks to only read components in vsir_program_remap_output_signature(). 2024-11-04 15:11:54 +01:00
Elizabeth Figura
61bda1c054 vkd3d-shader: Always ensure a RET at the end of a program. 2024-11-04 15:06:02 +01:00
Elizabeth Figura
568776bbf6 tests: Add a test for uninitialized varyings. 2024-11-04 15:06:02 +01:00
Feifan He
b0646cb427 tests/shader_runner: Introduce a Metal shader runner. 2024-10-31 16:47:26 +01:00
Henri Verbeet
da75582a14 tests/shader_runner: Check whether copy/dispatch/draw succeeded in parse_test_directive(). 2024-10-31 16:46:59 +01:00
Henri Verbeet
b5f1979475 tests/shader_runner: Print "(none)" for an empty caps list in trace_shader_caps().
Like we do in trace_format_cap().
2024-10-31 16:46:59 +01:00
Nikolay Sivov
ad2208b726 vkd3d-shader/fx: Implement parsing shader resources types.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-10-29 14:52:39 +01:00
Nikolay Sivov
1a8e9ff94e vkd3d-shader/fx: Implement parsing shader objects.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-10-29 14:41:55 +01:00
Elizabeth Figura
96c13aeb97 tests: Silence a bogus -Wmaybe-uninitialized. 2024-10-28 18:01:06 +01:00
Elizabeth Figura
3511b54040 vkd3d-shader/hlsl: Use early return in allocate_register().
Partly to avoid a spurious maybe-uninitialized warning, and partly because it's a more idiomatic structure.
2024-10-28 18:01:06 +01:00
Elizabeth Figura
08253504dc vkd3d-shader: Make an assert into an explicit check.
For some reason gcc without LTO thinks that component_count can overflow the
array here.
2024-10-28 18:01:06 +01:00
Elizabeth Figura
5883e01032 vkd3d-shader/fx: Remove an unnecessary hlsl_is_numeric_type().
Constants can only be numeric.
2024-10-28 18:01:06 +01:00
Elizabeth Figura
a595b96f62 vkd3d: Initialize vk_extensions in vk_init_device_caps().
Without LTO, gcc doesn't know that hresult_from_vk_result() will always return a
failure HRESULT for a failure VkResult, and so thinks that we might exit from
vkd3d_check_device_extensions() with a success HRESULT but without initializing
vk_extensions.
2024-10-28 18:01:06 +01:00
Henri Verbeet
5188883142 tests/shader_runner: Set "properties2.sType" in get_physical_device_info() in the Vulkan runner.
Found by the Vulkan validation layers.
2024-10-28 17:59:18 +01:00
Henri Verbeet
aeae8322da tests: Add a test for actual multisample loads.
The existing test loads from a single sample texture.
2024-10-28 17:58:05 +01:00
Henri Verbeet
072b45b972 tests/shader_runner_d3d12: Introduce a helper to get the default resource state for a resource. 2024-10-28 17:58:05 +01:00
Henri Verbeet
cc340b2838 tests/shader_runner: Handle render target sizes other than 640x480. 2024-10-28 17:58:05 +01:00
Henri Verbeet
9690ffff61 vkd3d-shader/spirv: Handle oPts in spirv_compiler_get_register_name(). 2024-10-28 17:54:43 +01:00
Henri Verbeet
fa6d03a4cb vkd3d-shader/d3d-asm: Implement support for VKD3DSPR_PARAMETER registers. 2024-10-28 17:54:20 +01:00
Nikolay Sivov
89e5912fd2 vkd3d-shader/hlsl: Implement RWByteAddressBuffer.Store*() methods.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-10-28 17:51:04 +01:00
Nikolay Sivov
6637948ae1 tests: Add some more tests for RWByteAddressBuffer store methods.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-10-28 17:46:17 +01:00
Nikolay Sivov
cf27065b7d vkd3d-shader/hlsl: Add parser support for the RWByteAddressBuffer type.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-10-28 17:44:28 +01:00
Nikolay Sivov
4195a2f18a vkd3d-shader/hlsl: Use a more compact way to store object method configurations.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-10-28 17:41:46 +01:00
Giovanni Mascellani
f7bc30bad2 tests: Mark tessellation-patch-vars.shader_test as todo on MoltenVK. 2024-10-28 17:39:23 +01:00
Giovanni Mascellani
624eccbab1 ci: Update the DXC version used on the CI to 1.8.2407.
Unfortuantely different versions of DXC accept or fail differently
in some cases. We don't care too much about validating the DXC
behavior itself, but it's useful that all the CI jobs use the
same version so that we don't have to complicate the shader runner
language.

The macOS version is currently bound to be pretty recent because
otherwise libdxil.dylib is not provided. So I'm updating the
Linux and Windows version as well.

I don't expect it should be particularly hard for other maintainers
to keep up with the DXC updates, since it just amounts to
downloading a ZIP file and extracting two libraries.
2024-10-28 17:36:17 +01:00
Giovanni Mascellani
fd33d51b1b tests: Mark tessellation.shader_test as todo on MoltenVK.
Tessellation shaders are currently not supported there.
2024-10-28 17:35:18 +01:00
Giovanni Mascellani
e83387d8b7 tests: Mark geometry.shader_test as todo on MoltenVK.
Geometry shaders are currently not supported there.
2024-10-28 17:33:35 +01:00
Giovanni Mascellani
d6efdeea61 tests: Dispatch just four invocations when testing for wave reconvergence.
I don't know why I put a 4 both in the numthreads() attribute and as
a dispatch parameter, but only care about only one thread group.
2024-10-28 17:31:24 +01:00
Giovanni Mascellani
5667da7b80 tests: Use the appropriate RTV format in bitwise.shader_test. 2024-10-28 17:31:24 +01:00
Elizabeth Figura
212333bfa6 tests: Add a test for sm1 inter-stage interface matching. 2024-10-28 17:29:25 +01:00
Elizabeth Figura
e452519dcb tests/shader_runner: Build a varying map in the Vulkan runner.
This adds todos to two tests. The tests in question have mismatching masks
and previously failed Vulkan validation anyway.
2024-10-28 17:29:25 +01:00
Elizabeth Figura
d12a9738a0 tests/shader_runner: Compile HLSL for all stages before compiling SPIRV. 2024-10-28 17:29:25 +01:00
Elizabeth Figura
d287e0d8a6 tests/shader_runner: Split HLSL and SPIRV compilation in the Vulkan shader runner. 2024-10-28 17:29:23 +01:00
Elizabeth Figura
b3eee0a323 tests/shader_runner: Centralize the compile_hlsl() helper in shader_runner.c. 2024-10-28 17:23:10 +01:00
Elizabeth Figura
591ae5e18e tests/shader_runner: Store the dxc_compiler in the shader_runner. 2024-10-28 17:23:10 +01:00
Elizabeth Figura
b492ebc374 tests/shader_runner: Store shader sources as an array. 2024-10-28 17:23:06 +01:00
Elizabeth Figura
ccdac48923 tests/shader_runner: Get rid of the "dxbc_ptr" parameter to create_shader_stage(). 2024-10-28 17:13:35 +01:00
Elizabeth Figura
d39e840c14 tests/shader_runner: Store shader caps using an array. 2024-10-28 16:20:27 +01:00
Elizabeth Figura
390a330b8e vkd3d-shader/hlsl: Avoid leaking the block in the subscript rule. 2024-10-28 15:40:41 +01:00
Elizabeth Figura
bb74180659 vkd3d-shader/hlsl: Return an error expression when an invalid subscript is used. 2024-10-28 15:40:41 +01:00
Elizabeth Figura
7905c47765 vkd3d-shader/hlsl: Handle error expressions in array sizes. 2024-10-28 15:40:41 +01:00
Elizabeth Figura
8b98e483ac vkd3d-shader/hlsl: Handle error expressions in return statements. 2024-10-28 15:40:41 +01:00
Elizabeth Figura
94cf432035 vkd3d-shader/hlsl: Handle error expressions in conditions. 2024-10-28 15:40:41 +01:00
Giovanni Mascellani
ae1d62f6a0 tests: Consider LOD miscalculation a todo rather than a driver bug. 2024-10-28 15:32:03 +01:00
Nikolay Sivov
5eff8bf918 vkd3d-shader/hlsl: Handle SV_GroupIndex.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-10-24 20:54:04 +02:00
Henri Verbeet
d48f7409fe tests/shader_runner: Print the test context in fatal_error().
In particular, this gets us line numbers.
2024-10-24 20:53:45 +02:00
Henri Verbeet
5e9edf25d0 vkd3d-shader/glsl: Implement VKD3DSIH_GATHER4. 2024-10-24 20:52:37 +02:00
Henri Verbeet
d477a00734 vkd3d-shader/glsl: Implement VKD3DSIH_SAMPLE_GRAD. 2024-10-24 20:52:37 +02:00
Henri Verbeet
d58282c6d1 vkd3d-shader/glsl: Implement VKD3DSIH_SAMPLE_LOD. 2024-10-24 20:52:37 +02:00
Henri Verbeet
85697d76be vkd3d-shader/glsl: Implement VKD3DSIH_UMAX and VKD3DSIH_UMIN. 2024-10-24 20:52:37 +02:00
Henri Verbeet
6a119b6946 vkd3d-shader/glsl: Implement VKD3DSGF_FORCE_EARLY_DEPTH_STENCIL. 2024-10-24 20:52:37 +02:00
Francisco Casas
9d82915629 vkd3d-shader/hlsl: Make allocation functions static again. 2024-10-24 20:50:59 +02:00
Francisco Casas
23be6ed0dd vkd3d-shader/hlsl: Store temp declarations in the vsir program.
Move the temp allocation back to hlsl_codegen.c.

Note that the DCL_TEMPS instructions wouldn't be necessary if we had the
capacity to store the temp_count for both the main program and the patch
constant program (or more generally speaking, a temp_count for all
phases).

The plan is to eventually also move the HS_CONTROL_POINT and
HS_FORK_PHASE markers to the vsir_program, making it able to contain
both functions.
2024-10-24 20:50:59 +02:00
Francisco Casas
158bf794e6 vkd3d-shader/hlsl: Introduce hlsl_ir_vsir_instruction_ref, again.
This node type will be deleted (again) once the hlsl->vsir->tpf
translation is complete. It serves the purpose of allowing to keep
both real hlsl_ir_nodes and vsir_instructions in the hlsl_block,
until all the former can be translated into the latter.
2024-10-24 20:50:59 +02:00
Francisco Casas
cf7fade580 vkd3d-shader/hlsl: Store the thread group size in the vsir program. 2024-10-24 20:48:20 +02:00
Giovanni Mascellani
91701f8303 vkd3d-shader: Warn instead of erroring out when failing to dump a shader.
It's a debug operation and shouldn't be considered fatal, even
for development workflows.
2024-10-23 16:14:33 +02:00
Giovanni Mascellani
6a03369f84 vkd3d-shader: Do not dump the target shader if compilation failed.
Otherwise we'd use unitialized data.
2024-10-23 16:14:33 +02:00
Giovanni Mascellani
a1f712d100 vkd3d: Incorporate mutable descriptors in the push descriptor disabling logic.
The computation is also written in the code now instead of in
the comments.
2024-10-23 16:12:50 +02:00
Giovanni Mascellani
bc2b137df9 vkd3d: Only put the mutable descriptor set once in the pipeline layout.
Currently the mutable descriptor set is repeated many times in the
pipeline layout in order to cover the indices for all the
descriptor types that would be present if mutable descriptors were
not used. This is useless and wasteful, but was necessary before
the descriptor sets backing the SRV-UAV-CBV heap were moved at the
end of the allocation table because descriptor set indices are
currently a compile-time constant in many places.

Now this is not needed any more and we can just avoid putting
many copies of the mutable descriptor set in the pipeline layout,
making it easier to meet Vulkan implementation limits.
2024-10-23 16:12:06 +02:00
Giovanni Mascellani
96b324c156 vkd3d: Move descriptor sets backing the SRV-UAV-CBV heap at the end.
So that when mutable descriptors are in use we can avoid putting
the other descriptor sets backing the SRV-UAV-CBV descriptor heap
in the pipeline layout altogether.
2024-10-23 16:07:54 +02:00
Giovanni Mascellani
8d030718ae vkd3d: Introduce an enumerant for the mutable descriptor set.
So we avoid hardcoding that it is number zero. There are two
goals here: first making the code easier to understand and
second allow reshuffling the descriptor set allocation in a
later commit.
2024-10-23 16:07:36 +02:00
Elizabeth Figura
32e6a1bb4d vkd3d-shader: Validate the parsed shader in vsir_parse(). 2024-10-23 16:02:09 +02:00
Elizabeth Figura
3a3f95e1e7 vkd3d-shader: Factor out a vsir_parse() helper. 2024-10-23 16:02:09 +02:00
Conor McCarthy
4889c71857 vkd3d: Zero the pipeline state UAV counter view array when the state is invalidated. (Valgrind)
Otherwise a comparison with uninitialised data occurs in
d3d12_command_list_update_descriptor_table() if virtual heaps are used.
2024-10-22 20:42:06 +02:00
Henri Verbeet
1113d24a70 vkd3d-shader/ir: Store the global flags in struct vsir_program. 2024-10-22 20:40:31 +02:00
Henri Verbeet
21e9029177 vkd3d-shader/glsl: Implement VKD3DSIH_SAMPLE_C_LZ. 2024-10-22 20:39:31 +02:00
Henri Verbeet
5958e527e5 vkd3d-shader/glsl: Implement VKD3DSIH_SAMPLE_C. 2024-10-22 20:39:31 +02:00
Henri Verbeet
19c493722e vkd3d-shader/glsl: Implement VKD3DSIH_SAMPLE_B. 2024-10-22 20:39:31 +02:00
Henri Verbeet
e408f1d984 vkd3d-shader/glsl: Implement support for the VKD3DSPR_THREADID register. 2024-10-22 20:39:31 +02:00
Henri Verbeet
f76dd80cba vkd3d-shader/glsl: Implement VKD3DSIH_LD_UAV_TYPED. 2024-10-22 20:39:31 +02:00
Giovanni Mascellani
8d8e0fd55a tests: Test mismatching RTV and pixel shader output types. 2024-10-22 20:38:18 +02:00
Giovanni Mascellani
7fbed358c9 ci: Build DXC for release.
Otherwise a lot of assertions trigger, even for legitimate uses.
2024-10-22 20:32:51 +02:00
Giovanni Mascellani
dff7c0e7b8 tests: Mark interface packing pipeline creation as todo on MoltenVK.
Most Vulkan drivers are happy to compile a pipeline with interstage
interface mismatches, even if the pipeline will be broken. Metal,
and therefore MoltenVK, instead doesn't and errors out immediately.
2024-10-22 20:32:51 +02:00
Giovanni Mascellani
b411086398 tests: Use the appropriate RTV format in minimum-precision.shader_test. 2024-10-22 20:29:25 +02:00
Giovanni Mascellani
987dbe31e3 tests: Use appropriate RTV formats in max-min.shader_test. 2024-10-22 20:29:25 +02:00
Giovanni Mascellani
bc830fa06b tests: Compute the correct value for condition conjunctions.
Currently the value of the last conjunct is returned.
2024-10-22 20:29:25 +02:00
Nikolay Sivov
cf3e251a9f vkd3d-shader/hlsl: Implement the f32tof16() intrinsic.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-10-22 20:28:33 +02:00
Shaun Ren
f54797bae5 vkd3d-shader/hlsl: Support discard for SM1. 2024-10-22 20:27:34 +02:00
Francisco Casas
2a8c1b2823 vkd3d-shader/hlsl: Sort signature elements by register id. 2024-10-22 20:25:40 +02:00
Francisco Casas
51d05c1844 vkd3d-shader/hlsl: Optimize interstage signatures. 2024-10-22 20:15:15 +02:00
Francisco Casas
88dd082160 vkd3d-shader/hlsl: Allow prioritizing smaller writemasks when allocating signature elements.
For now this doesn't have effect yet, until semantic allocation is
optimized.
2024-10-22 20:06:15 +02:00
Francisco Casas
d562b03c43 vkd3d-shader/hlsl: Allow to force alignment on some semantic vars.
This is required to properly optimize signatures, because these
semantics must be alligned while being packed:
- Array elements.
- The first fields of structs.
- Major vectors of a matrix.

For now this has no effect since semantics are allocated with reg_size
4, but will have effect when optimizing interstage signatures.
2024-10-22 20:04:41 +02:00
Francisco Casas
7fd6c29ee8 vkd3d-shader/hlsl: Allow accounting for interpolation mode when allocating semantics.
For now this has no effect since semantics are allocated with reg_size
4, but will have effect when optimizing interstage signatures.
2024-10-22 20:03:39 +02:00
Francisco Casas
b65f5fb069 vkd3d-shader/hlsl: Also pass field storage modifiers to output signature elements.
The generated pixel shader input signature must be consistent with the
generated vertex shader output signature for the same data type.

Since the interpolation mode affects allocation order, the allocator
needs to know the modifiers for both input and output signature elements.
2024-10-22 19:29:11 +02:00
Francisco Casas
7180a96741 vkd3d-shader/hlsl: Use a register_allocator to allocate semantic registers. 2024-10-22 19:23:33 +02:00
Francisco Casas
9ce7b7806f vkd3d-shader/hlsl: Add mode field to register_allocator allocations. 2024-10-22 19:23:22 +02:00
Francisco Casas
d9b631182e tests: Add signature reflection test with structs. 2024-10-22 19:15:42 +02:00
Nikolay Sivov
fb2b974466 vkd3d-shader/hlsl: Handle snorm/unorm types as resource formats.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-10-22 19:14:51 +02:00
Elizabeth Figura
6fd1a1ce7e tests: Test point sprite. 2024-10-22 19:14:05 +02:00
Elizabeth Figura
a492d64fef vkd3d-shader/ir: Allow controlling point sprite through a parameter. 2024-10-22 19:14:02 +02:00
Nikolay Sivov
8a3fe9cd1e vkd3d-shader/fx: Implement parsing groups and techniques.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-10-21 18:23:33 +02:00
Giovanni Mascellani
ae772d40cf vkd3d: Disable push descriptors when that's helpful to stay within 8 descriptor sets. 2024-10-21 18:22:15 +02:00
Giovanni Mascellani
3bf114f3c3 vkd3d/device: Trace which descriptor heap implementation is being used.
The descriptor heap implementation is a rather central behavior element
in vkd3d, so it's useful to have all the relevant information logged
in a single place.
2024-10-21 18:22:15 +02:00
Giovanni Mascellani
ed4d45355a vkd3d-shader/ir: Represent the normalisation level with an enumeration. 2024-10-21 18:21:39 +02:00
Giovanni Mascellani
9f3b21cc78 tests: Mark latching the predicated value as todo on llvmpipe.
Vulkan doesn't mandate whether the predicated value should be latched
when beginning the predicated section or re-read at each operation.
2024-10-21 18:20:38 +02:00
Giovanni Mascellani
1301014b28 tests: Mark creating an 8x MSAA render target as buggy on llvmpipe. 2024-10-21 18:20:38 +02:00
Giovanni Mascellani
3c86094371 tests: Mark a sampling test as buggy on llvmpipe.
Vulkan doesn't mandate whether sampling exactly in the middle between
two levels should resolve to one or the other, while D3D specifies
that it should result into sampling the higher level. llvmpipe
happens to choose the lower one instead, at least in some cases.
2024-10-21 18:20:38 +02:00
Shaun Ren
773e1bbeae tests: Test signature reflection for domain shaders. 2024-10-21 18:19:33 +02:00
Shaun Ren
abed6d9cb7 vkd3d-shader/tpf: Implement semantics for domain shaders. 2024-10-21 18:18:25 +02:00
Shaun Ren
0273ff007b vkd3d-shader/tpf: Write domain shader declarations. 2024-10-21 18:18:00 +02:00
Shaun Ren
26efba30b4 vkd3d-shader/tpf: Use vpc input registers for domain shaders. 2024-10-21 18:17:06 +02:00
Shaun Ren
2b897296a1 vkd3d-shader/tpf: Write the input signature of domain shaders as PCSG. 2024-10-21 18:16:50 +02:00
Shaun Ren
768b19d410 vkd3d-shader/ir: Validate control point counts correctly.
Allow zero input control points for domain shaders, and zero output
control points for hull shaders.
2024-10-21 18:10:13 +02:00
Shaun Ren
976fe27836 vkd3d-utils: Return correct use masks during reflection. 2024-10-21 18:09:39 +02:00
Shaun Ren
7408ab145a vkd3d-utils: Implement version reflection. 2024-10-21 18:09:06 +02:00
Giovanni Mascellani
a3b8aaf679 vkd3d: Allow overriding the device capabilities. 2024-10-21 18:06:06 +02:00
Giovanni Mascellani
03ad04c890 vkd3d-shader/ir: Validate OUTCONTROLPOINT registers. 2024-10-17 17:34:55 +02:00
Giovanni Mascellani
1e86f00247 vkd3d-shader/ir: Validate INCONTROLPOINT registers. 2024-10-17 17:34:55 +02:00
Giovanni Mascellani
a4ab53ab7b vkd3d-shader/ir: Validate PATCHCONST registers. 2024-10-17 17:34:55 +02:00
Giovanni Mascellani
62d5bc91f5 vkd3d-shader/ir: Validate OUTPUT registers. 2024-10-17 17:34:55 +02:00
Giovanni Mascellani
349fdd0843 vkd3d-shader/ir: Validate INPUT registers. 2024-10-17 17:34:55 +02:00
Giovanni Mascellani
d9508558a9 vkd3d-shader: Keep track of whether programs have normalised hull shader control point I/O. 2024-10-17 17:34:55 +02:00
Giovanni Mascellani
eba8fd4720 vkd3d-shader: Keep track of whether programs have normalised I/O. 2024-10-17 17:34:55 +02:00
Nikolay Sivov
7ae1284c16 vkd3d-compiler: Add missing 'fx' source type to the CLI output.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-10-17 17:32:54 +02:00
Nikolay Sivov
071130b944 vkd3d-shader/fx: Add support for tracing annotations.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-10-17 17:32:54 +02:00
Giovanni Mascellani
ca309e439a ci: Test DXIL shaders on macOS.
This unfortunately introduces a lot of failures, because it turns
out there is still work to do there. But at least we can
estimate how bad we're doing.
2024-10-17 17:31:22 +02:00
Giovanni Mascellani
19c699870b ci: Build the DirectX shader compiler for macOS. 2024-10-17 17:31:22 +02:00
Giovanni Mascellani
7c3f424a97 ci: Stop building widl for the macOS image. 2024-10-17 17:31:22 +02:00
Giovanni Mascellani
2b84e30e26 ci: Use widl from the mingw-w64 brew package on macOS. 2024-10-17 17:31:22 +02:00
Giovanni Mascellani
51cdb74061 ci: Remove the tart username and password environment variables.
They're not really needed, the runner already handles login
properly.
2024-10-17 17:31:22 +02:00
Elizabeth Figura
eeb7bbe3c5 vkd3d-shader/hlsl: Handle error expressions in ternary expressions. 2024-10-17 17:28:52 +02:00
Elizabeth Figura
d95962068a vkd3d-shader/hlsl: Handle error expressions in initializers. 2024-10-17 17:28:52 +02:00
Elizabeth Figura
dfe79cb6a9 vkd3d-shader/hlsl: Factor the component count check into initialize_var(). 2024-10-17 17:28:52 +02:00
Elizabeth Figura
d8892a4ca2 vkd3d-shader/hlsl: Store the initializer location in struct parse_initializer. 2024-10-17 17:28:52 +02:00
Elizabeth Figura
44ea7b5e12 vkd3d-shader/hlsl: Factor out an initialize_var() helper. 2024-10-17 17:28:52 +02:00
Giovanni Mascellani
e411fcb60e tests: Test discontiguous signature masks with SM<4 shaders. 2024-10-17 17:28:52 +02:00
Giovanni Mascellani
0e43dea42d vkd3d-shader/ir: Check that signature masks are contiguous. 2024-10-17 17:28:52 +02:00
Giovanni Mascellani
083b87c712 vkd3d-shader/d3dbc: Make signature masks contiguous.
The goal is to make a requirement for VSIR that signature element
masks are always contiguous. The SPIR-V backend already implicitly
makes that assumption, since it just consider the LSB and popcount
of the mask.

For example, consider this HLSL pixel shader:

    float4 main(float4 color : COLOR) : SV_Target
    {
        return float4(color.x, 10.0f, 11.0f, color.w);
    }

Currently the parser describes the input signature element
corresponding to semantic COLOR as having mask .xw, which is
sensible. However, the SPIR-V parser will interpret that as
a mask starting at x and with popcount 2, and assuming it is
contiguous it will implicitly act as if it were .xy. This is
not correct, because the wrong component will be loaded from
the vertex stage.
2024-10-17 17:28:52 +02:00
Henri Verbeet
8943999bd2 vkd3d: Slightly simplify the SRV/UAV logic in vk_write_descriptor_set_from_d3d12_desc(). 2024-10-17 17:28:52 +02:00
Conor McCarthy
bfaab9700d vkd3d: Lay out virtual descriptor heap buffer and image bindings consecutively instead of interleaving them.
Slightly simplifies descriptor write addressing, and makes layouts
essentially the same as array layouts, differing only in the binding
details, and therefore easier to understand. This also simplifies the
addition of storage buffer bindings, which can all be added onto the end.
2024-10-17 17:28:46 +02:00
Giovanni Mascellani
0b8a53d75d vkd3d: Create Vulkan bindings in d3d12_root_signature_append_vk_binding(). 2024-10-17 17:23:04 +02:00
Conor McCarthy
74da9ed6fe vkd3d: Create a separate Vulkan descriptor binding array for each descriptor set.
Allows descriptor set layouts to be created after all bindings are
mapped. This is less complex and fragile than the current scheme, and in
a future patch it will support separating descriptor types into different
sets. Descriptors on virtual heaps are currently allocated from pools
which contain an equal number of each descriptor type used by vkd3d, and
this can waste a significant amount of device memory.
2024-10-17 17:23:04 +02:00
Giovanni Mascellani
b5c56a50b5 vkd3d: Use vk_binding_array_add_binding() in d3d12_root_signature_init_root_descriptors(). 2024-10-17 17:23:04 +02:00
Giovanni Mascellani
3aec841a9f vkd3d: Use vk_binding_array_add_binding() in d3d12_root_signature_init_static_samplers(). 2024-10-17 17:23:04 +02:00
Giovanni Mascellani
416ce575f6 vkd3d: Introduce a helper function to add bindings to struct vk_binding_array. 2024-10-17 17:23:04 +02:00
Conor McCarthy
eca344ff56 vkd3d: Introduce a separate structure for storing Vulkan descriptor binding arrays. 2024-10-17 17:23:04 +02:00
Conor McCarthy
3f98ca53ca vkd3d: Access the current range via the declared pointer in d3d12_root_signature_init_root_descriptor_tables(). 2024-10-17 17:23:04 +02:00
Conor McCarthy
b092fcfc46 tests/d3d12: Test buffer and texture SRVs in test_unbounded_resource_arrays().
On virtual heaps, SRV/UAV unbounded ranges are implemented using two
descriptor sets, one for buffers and another for textures, and this case
should be tested.
2024-10-17 17:23:04 +02:00
Giovanni Mascellani
c89e547e3e ci: Use the macOS image from the master vkd3d repository.
The current URL is from my own testing repository and it's not
meant for general use.
2024-10-16 21:40:58 +02:00
Giovanni Mascellani
2b45878ff8 vkd3d-shader/ir: Validate the line density SV_TessFactor signature element for isolines domains. 2024-10-16 21:40:58 +02:00
Giovanni Mascellani
f470eb2a1a vkd3d-shader/ir: Validate the line detail SV_TessFactor signature element for isolines domains. 2024-10-16 21:40:58 +02:00
Giovanni Mascellani
c5c3151414 vkd3d-shader/ir: Validate SV_InsideTessFactor signature elements for tri domains. 2024-10-16 21:40:58 +02:00
Giovanni Mascellani
4e8b34c075 vkd3d-shader/ir: Validate SV_TessFactor signature elements for tri domains. 2024-10-16 21:40:58 +02:00
Giovanni Mascellani
b2460a6794 vkd3d-shader/ir: Validate SV_InsideTessFactor signature elements for quad domains. 2024-10-16 21:40:58 +02:00
Giovanni Mascellani
a8b9a92c10 vkd3d-shader/ir: Validate SV_TessFactor signature elements for quad domains. 2024-10-16 21:40:58 +02:00
Shaun Ren
1ed5f1a4d0 vkd3d-shader/tpf: Write the patch constant function in hull shaders.
We use a single hs_fork_phase here for the patch constant function.
2024-10-16 21:40:40 +02:00
Shaun Ren
f771f081d9 tests: Test signature reflection for hull shaders. 2024-10-16 21:22:02 +02:00
Shaun Ren
ae2d86b99c vkd3d-shader/tpf: Determine SIV from SV and index in write_sm4_dcl_semantic(). 2024-10-16 21:12:29 +02:00
Shaun Ren
df3aaac7cf vkd3d-shader/tpf: Introduce tpf_write_shader_function(). 2024-10-16 21:12:13 +02:00
Shaun Ren
147f8898ca vkd3d-shader/hlsl: Process the patch constant function in hlsl_emit_bytecode().
Also, support patch constant function semantics in sm4_sysval_semantic_from_semantic_name().
2024-10-16 21:10:24 +02:00
Shaun Ren
aee00ea55a tests: Test hull shader uniform input parameters. 2024-10-16 21:07:53 +02:00
Shaun Ren
cbed70c60f vkd3d-shader/tpf: Implement semantics for hull shaders. 2024-10-16 21:07:53 +02:00
Shaun Ren
beb342ed5f vkd3d-shader/tpf: Write hull shader declarations. 2024-10-16 21:07:53 +02:00
Henri Verbeet
47fcbc335b vkd3d-shader/d3dbc: Avoid D3DXSHADER_CONSTANTTABLE. 2024-10-16 21:07:53 +02:00
Shaun Ren
069b8aac64 vkd3d-shader/hlsl: Implement struct single inheritance.
Here, we implement single inheritance by inserting a field at the
beginning of the derived struct with name "$super".

For the following struct declarations

  struct a
  {
      float4 aa;
      float4 bb;
  };

  struct b : a
  {
      float4 cc;
  };

  struct c : b
  {
      float4 bb;
  };

this commit generates the following:

  struct a
  {
      float4 aa;
      float4 bb;
  };

  struct b
  {
      struct a $super;
      float4 cc;
  };

  struct c
  {
      struct b $super;
      float4 bb;
  };
2024-10-16 21:07:53 +02:00
Shaun Ren
013e354b46 tests: Test struct single inheritance. 2024-10-16 21:07:53 +02:00
Francisco Casas
7eee877dd4 vkd3d-shader/tpf: Make hlsl_sm4_register_from_semantic() independent of HLSL IR. 2024-10-16 21:07:51 +02:00
Francisco Casas
a243862b8c vkd3d-shader/tpf: Make sysval_semantic_from_hlsl() independent of HLSL IR. 2024-10-16 21:05:10 +02:00
Francisco Casas
7cc8151b81 vkd3d-shader/tpf: Replace uses of ctx->profile with tpf->program->shader_version. 2024-10-16 18:50:15 +02:00
Francisco Casas
c75fbaf94e vkd3d-shader/tpf: Use the I/O signatures from the vsir program in tpf_write_signature(). 2024-10-16 17:40:26 +02:00
Francisco Casas
10442369d8 vkd3d-shader/tpf: Pass a tpf_compiler structure to tpf_compile() callees. 2024-10-16 17:26:47 +02:00
Francisco Casas
16d9a10dd5 vkd3d-shader/tpf: Rename "tpf_writer" to "tpf_compiler".
Analog to d3dbc_compiler.
2024-10-16 17:09:15 +02:00
Francisco Casas
5b21cc67f1 vkd3d-shader/hlsl: Split hlsl_sm4_write().
Similarly to the already done split from

    HLSL IR -> d3dbc

to

    HLSL IR -> vsir -> d3bc

we now start splitting the

    HLSL IR -> tpf

translation into

    HLSL IR -> vsir -> tpf

So hlsl_sm4_write is split into two functions, sm4_generate_vsir() and
tpf_compile().

This translation should be completed once tpf_compile() no longer needs
the hlsl_ctx and entry_func parameters.
2024-10-16 17:08:50 +02:00
Francisco Casas
3601397703 vkd3d-shader/d3dbc: Remove the "hlsl_" prefix from external functions.
They no longer rely on HLSL IR.

Also, rename them from "_from_semantic" to "from_semantic_name".
2024-10-16 16:52:45 +02:00
Francisco Casas
0ab5e1cb03 tests: Test interstage signature with arrays. 2024-10-16 16:49:55 +02:00
Francisco Casas
d3c464212d tests: Test interstage signature optimizations. 2024-10-16 16:47:41 +02:00
Giovanni Mascellani
bc351f4b70 tests/shader-runner: Make geometry shaders optional.
This allows the Vulkan runner to execute in environments which do
not support geometry shaders, most notably MoltenVK. In particular,
that enables SM<4 shaders to run in such environments
2024-10-15 16:55:15 +02:00
Giovanni Mascellani
7f834f57e5 vkd3d-shader/ir: Validate that signatures are sensible for shader type. 2024-10-15 16:47:04 +02:00
Giovanni Mascellani
859b911b3a vkd3d-shader/ir: Validate the output control point count. 2024-10-15 16:47:04 +02:00
Giovanni Mascellani
bd3ba87747 vkd3d-shader/ir: Validate the input control point count. 2024-10-15 16:47:04 +02:00
Henri Verbeet
90616be301 vkd3d-shader/dxil: Shift register write masks by the component index in sm6_parser_emit_dx_store_output().
To account for the change we made in commit
c571a45e65 on the SPIR-V side.
2024-10-15 16:45:28 +02:00
Henri Verbeet
2d848cf001 tests: Add a basic shader model 6 interface packing test as well. 2024-10-15 16:45:28 +02:00
Francisco Casas
104435df5f vkd3d-shader/tpf: Use dcl_input_ps_sgv for sv_isfrontface.
As the native compiler does.
2024-10-15 16:44:38 +02:00
Francisco Casas
ad2f821ff5 vkd3d-shader/tpf: Write sysval semantic consistently.
Specifically we should write the sysval semantic as an instruction idx
for the following instructions:

    VKD3D_SM4_OP_DCL_INPUT_SGV
    VKD3D_SM4_OP_DCL_INPUT_PS_SGV
    VKD3D_SM4_OP_DCL_INPUT_SIV
    VKD3D_SM4_OP_DCL_INPUT_PS_SIV
    VKD3D_SM4_OP_DCL_OUTPUT_SIV

and not the following ones:

    VKD3D_SM4_OP_DCL_INPUT
    VKD3D_SM4_OP_DCL_PS_INPUT
    VKD3D_SM4_OP_DCL_OUTPUT

Which is consistent with what we do when reading these instructions in
the following functions:

    shader_sm4_read_declaration_register_semantic()
    shader_sm4_read_dcl_input_ps_siv()

and

    shader_sm4_read_dcl_input_ps()
    shader_sm4_read_declaration_dst()

for the non-SGV and non-SIV cases.

Note that the non-SGV and non-SIV instructions don't need/use this
extra information because they rely on the dst register type and index.

I suggest to introduce this change because the here replaced check is
brittle, and we might be omitting the sysval semantic in some cases.
2024-10-15 16:44:38 +02:00
Nikolay Sivov
5fb3a91276 vkd3d-shader/hlsl: Implement the modf() intrinsic.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-10-15 16:43:33 +02:00
Shaun Ren
cb55ba5b9b vkd3d-shader/hlsl: Invoke prepend_uniform_copy() only once for global uniforms.
We store the copy instructions in a separate block that is cloned for
each function processed.
2024-10-15 16:42:47 +02:00
Shaun Ren
0c5dc53fd2 vkd3d-shader/hlsl: Allocate temporary registers separately for each entry function. 2024-10-15 16:39:50 +02:00
Shaun Ren
5f8570b933 vkd3d-shader/hlsl: Track whether a variable is read in any entry function. 2024-10-15 16:18:36 +02:00
Shaun Ren
f15a1c0b23 vkd3d-shader/hlsl: Record semantic extern vars separately for each entry function.
This is required in order to process the entry point function and the
patch constant function in hull shaders.
2024-10-15 16:18:27 +02:00
Shaun Ren
bbc6b56ab0 vkd3d-shader/hlsl: Clone static_initializers for each entry function. 2024-10-15 16:13:31 +02:00
Shaun Ren
5571522efe vkd3d-shader/hlsl: Introduce process_entry_function() helper.
This will be used in order to process both the entry point function
and the patch constant function in hull shaders.
2024-10-15 16:10:56 +02:00
Henri Verbeet
9dd42d15dd build: Actually run interface-packing.shader_test and tessellation-patch-vars.shader_test. 2024-10-14 19:40:13 +02:00
Giovanni Mascellani
5dfaa26990 vkd3d-shader/ir: Validate the allowed data type and component count for SV_CullDistance. 2024-10-14 19:39:12 +02:00
Giovanni Mascellani
cd5718f59d vkd3d-shader/ir: Validate the allowed signatures and stages for SV_CullDistance. 2024-10-14 19:39:12 +02:00
Giovanni Mascellani
33972998a9 vkd3d-shader/ir: Validate the allowed data type and component count for SV_ClipDistance. 2024-10-14 19:39:12 +02:00
Giovanni Mascellani
0465549c9d vkd3d-shader/ir: Validate the allowed signatures and stages for SV_ClipDistance. 2024-10-14 19:39:12 +02:00
Giovanni Mascellani
20b3a4c362 vkd3d-shader/ir: Validate the allowed data type and component count for SV_Position. 2024-10-14 19:39:12 +02:00
Giovanni Mascellani
962ce961d4 vkd3d-shader/ir: Validate the allowed signatures and stages for SV_Position. 2024-10-14 19:39:12 +02:00
Giovanni Mascellani
2d452842ed vkd3d-shader/ir: Introduce a helper for validating MISCTYPE registers. 2024-10-14 15:42:00 +02:00
Giovanni Mascellani
15d8591a26 vkd3d-shader/ir: Introduce a helper for validating RASTOUT registers. 2024-10-14 15:42:00 +02:00
Giovanni Mascellani
7021a57193 vkd3d-shader/ir: Introduce a helper for validating UAV registers. 2024-10-14 15:42:00 +02:00
Giovanni Mascellani
c60eecbac8 vkd3d-shader/ir: Introduce a helper for validating RESOURCE registers. 2024-10-14 15:42:00 +02:00
Giovanni Mascellani
edbf7349bd vkd3d-shader/ir: Introduce a helper for validating SAMPLER registers. 2024-10-14 15:42:00 +02:00
Giovanni Mascellani
52761e689b vkd3d-shader/ir: Introduce a helper for validating registers without indices. 2024-10-14 15:42:00 +02:00
Giovanni Mascellani
ce638b9cca vkd3d-shader/ir: Introduce a helper for validating LABEL registers. 2024-10-14 15:42:00 +02:00
Giovanni Mascellani
92d1ba9188 vkd3d-shader/ir: Introduce a helper for validating SSA registers. 2024-10-14 15:42:00 +02:00
Giovanni Mascellani
1c43b2e55f vkd3d-shader/ir: Introduce a helper for validating TEMP registers. 2024-10-14 15:42:00 +02:00
Nikolay Sivov
35d2df14d8 vkd3d-shader/fx: Add support for tracing string variables.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-10-14 15:40:46 +02:00
Nikolay Sivov
907b6705fe vkd3d-shader/fx: Add support for parsing constant buffer elements.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-10-14 15:40:14 +02:00
Nikolay Sivov
6801ad9b7a vkd3d-shader/fx: Introduce a parser/disassembler.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-10-14 15:20:41 +02:00
Elizabeth Figura
cd249a47b8 tests: Test FFP point size clamping. 2024-10-10 22:44:33 +02:00
Elizabeth Figura
1e3c1392bd vkd3d-shader/ir: Allow controlling FFP point size clamping through vkd3d-shader parameters. 2024-10-10 22:44:26 +02:00
Elizabeth Figura
ec53e325b6 tests: Test FFP point size. 2024-10-10 22:30:35 +02:00
Henri Verbeet
3ddf46649b tests/shader_runner: Trace the "clip-planes" cap. 2024-10-10 22:28:26 +02:00
Elizabeth Figura
54092286be vkd3d-shader/ir: Allow controlling FFP point size through a vkd3d-shader parameter. 2024-10-10 22:25:09 +02:00
Elizabeth Figura
6ee17cf77e vkd3d-shader/spirv: Implement shader point size. 2024-10-10 22:14:45 +02:00
Elizabeth Figura
a29a4288d2 tests: Add a test for shader point size output. 2024-10-10 21:50:30 +02:00
Elizabeth Figura
56e5fca501 vkd3d-shader/spirv: Always write the point size in vertex shaders.
Vulkan requires that point size be written.

There should be no backwards compatibility concern here, since the vertex shader
supplies point size with the lowest priority.
2024-10-10 21:50:30 +02:00
Giovanni Mascellani
f0e31dd6b3 vkd3d-shader/ir: Only allow PATCHCONST registers as destination parameteres in Hull Shaders. 2024-10-10 20:04:13 +02:00
Giovanni Mascellani
f2d181e65c vkd3d-shader/ir: Only allow PATCHCONST registers as source parameteres in Hull and Domain Shaders. 2024-10-10 20:04:13 +02:00
Giovanni Mascellani
6cbe5ffa15 vkd3d-shader/ir: Disallow OUTPUT registers in source parameters. 2024-10-10 20:04:13 +02:00
Giovanni Mascellani
5b5a27dccb vkd3d-shader/ir: Disallow INPUT registers in destination parameters. 2024-10-10 20:04:13 +02:00
Henri Verbeet
bf71b13797 vkd3d-shader/glsl: Implement support for compute shaders. 2024-10-10 20:00:45 +02:00
Henri Verbeet
fb17ba18ae vkd3d-shader/glsl: Implement VKD3DSIH_STORE_UAV_TYPED. 2024-10-10 20:00:45 +02:00
Henri Verbeet
8e47ecbd92 vkd3d-shader/glsl: Use the semantic index for shader_out_* declarations.
Because that's what we use in shader_glsl_print_sysval_name(). Fragment
shaders like the ones from uav-rwtexture.shader_test that output to
sv_target1 would declare "shader_out_0", but then store to
"shader_out_1" in the epilogue.
2024-10-10 20:00:45 +02:00
Henri Verbeet
afb1a2610e vkd3d-shader/glsl: Use VKD3D_SHADER_ERROR_GLSL_UNSUPPORTED for unsupported CBV descriptor arrays. 2024-10-10 20:00:45 +02:00
Henri Verbeet
845d6f9134 vkd3d-shader/ir: Remove VKD3DSIH_DCL_UAV_TYPED instructions. 2024-10-10 20:00:45 +02:00
Giovanni Mascellani
080f25c583 vkd3d-shader/ir: Do not search for signature elements using a scalar write mask.
The fallback code was added when shader_signature_find_element_for_reg()
would crash when unable to find the requested signature element.
Now it doesn't any more, and the second search is redundant.
2024-10-10 20:00:19 +02:00
Giovanni Mascellani
690c47dbf8 vkd3d-shader/ir: Validate that constant interpolation is used with integer types. 2024-10-10 19:58:00 +02:00
Giovanni Mascellani
e366fc3ad6 vkd3d-shader/ir: Validate interpolation mode in shader signatures. 2024-10-10 19:58:00 +02:00
Giovanni Mascellani
831a797837 vkd3d-shader/ir: Validate minimum precision in shader signatures. 2024-10-10 19:58:00 +02:00
Giovanni Mascellani
7b1bc5ca74 vkd3d-shader/ir: Validate component types in shader signatures. 2024-10-10 19:58:00 +02:00
Giovanni Mascellani
5034e1eeb5 vkd3d-shader/ir: Validate system value semantics in shader signatures. 2024-10-10 19:58:00 +02:00
Giovanni Mascellani
6e14d7ab90 vkd3d-shader/ir: Validate usage masks in shader signatures. 2024-10-10 19:58:00 +02:00
Giovanni Mascellani
71dccc0132 vkd3d-shader/ir: Do not emit an instruction number before starting validating instructions. 2024-10-10 19:58:00 +02:00
Giovanni Mascellani
3285d1ad8c tests: Only destroy the device if the context has one in vulkan_test_context_destroy().
If vulkan_test_context_init_device() was never called, or failed to
create a device, the context won't have a device.
2024-10-10 19:53:18 +02:00
Feifan He
ccc48291b3 vkd3d-shader/msl: Implement support for VKD3DSPR_OUTPUT registers. 2024-10-10 19:45:34 +02:00
Feifan He
48a2207511 vkd3d-shader/msl: Implement support for VKD3DSPR_INPUT registers. 2024-10-10 19:43:12 +02:00
Feifan He
75e0cde045 vkd3d-shader/msl: Implement support for VKD3DSPR_CONSTBUFFER registers. 2024-10-10 19:41:31 +02:00
Feifan He
2d7832e738 vkd3d-shader/msl: Generate shader descriptor structure declarations. 2024-10-10 19:40:34 +02:00
Giovanni Mascellani
9cb4207c92 vkd3d-shader/spirv: Write spirv_compiler_emit_variable() in terms of spirv_compiler_emit_array_variable().
Essentially for code clarity, so that it's more obvious that a
non-array variable is indeed an array variable with no indices.
2024-10-09 13:15:25 +02:00
Henri Verbeet
aba45d0386 vkd3d-shader/glsl: Implement VKD3DSIH_CONTINUE. 2024-10-09 13:14:31 +02:00
Henri Verbeet
bc4aacd21e vkd3d-shader/glsl: Implement VKD3DSIH_ULT. 2024-10-09 13:14:31 +02:00
Henri Verbeet
27eb3c07ad vkd3d-shader/glsl: Implement switches. 2024-10-09 13:14:31 +02:00
Henri Verbeet
93f1af721f vkd3d-shader/glsl: Implement loops. 2024-10-09 13:14:31 +02:00
Henri Verbeet
790f35533b vkd3d-shader/glsl: vkd3d-shader/glsl: Implement support for VKD3D_SHADER_COMPONENT_INT inputs. 2024-10-09 13:14:31 +02:00
Giovanni Mascellani
bb0e4506a6 vkd3d-shader/ir: Validate masks in shader signatures. 2024-10-09 13:13:00 +02:00
Giovanni Mascellani
c3b31b96e1 vkd3d-shader/ir: Validate register counts in patch constant signatures. 2024-10-09 13:13:00 +02:00
Giovanni Mascellani
a29270fa64 vkd3d-shader/ir: Validate register counts in output signatures. 2024-10-09 13:13:00 +02:00
Giovanni Mascellani
118f494de3 vkd3d-shader/ir: Validate register counts in input signatures. 2024-10-09 13:13:00 +02:00
Giovanni Mascellani
7202e6e2f3 vkd3d-shader/ir: Allow a patch constant signature only for Hull and Domain Shaders. 2024-10-09 13:13:00 +02:00
Giovanni Mascellani
16efb7c0c6 vkd3d-shader: Ignore the patch constant signature when it doesn't make sense. 2024-10-09 13:13:00 +02:00
Giovanni Mascellani
cd74461d6d vkd3d-shader/ir: Set the signature sort indices in shader_signature_merge().
Since the sort index is just a convenience field it is more
appropriate to only set it where it is required, instead of
requiring all frontends and passes to retain sensible values for
it.
2024-10-08 22:05:38 +02:00
Giovanni Mascellani
c332adaa68 vkd3d-shader/d3d-asm: Dump signatures when tracing a VSIR program. 2024-10-08 22:04:59 +02:00
Giovanni Mascellani
c7d09bba97 vkd3d-shader/d3d-asm: Rename dump_signatures() to dump_dxbc_signatures(). 2024-10-08 22:04:59 +02:00
Giovanni Mascellani
b21ae8d9c2 vkd3d-shader/d3d-asm: Rename dump_signature() to dump_dxbc_signature().
To stress the fact that only the fields that appear in the DXBC
signature sections are considered.
2024-10-08 22:04:59 +02:00
Giovanni Mascellani
1256b4f862 vkd3d-shader/d3d-asm: Rename vkd3d_shader_trace() to vsir_program_trace(). 2024-10-08 22:04:59 +02:00
Giovanni Mascellani
3428ed7a64 vkd3d-shader/dxil: Emit double arithmetic operations when appropriate. 2024-10-08 22:04:32 +02:00
Henri Verbeet
cf92d9f398 vkd3d-shader/ir: Store the thread group size in struct vsir_program. 2024-10-08 22:03:05 +02:00
Henri Verbeet
fc8384462f vkd3d-shader/glsl: Implement VKD3DSIH_IMAX. 2024-10-08 22:01:56 +02:00
Henri Verbeet
c2a42214ff vkd3d-shader/glsl: Implement VKD3DSIH_INEG. 2024-10-08 22:01:56 +02:00
Henri Verbeet
e55bc76fd2 vkd3d-shader/glsl: Implement support for VKD3D_SHADER_COMPONENT_UINT inputs. 2024-10-08 22:01:56 +02:00
Henri Verbeet
0acebd6e09 vkd3d-shader/glsl: Implement support for VKD3D_SHADER_COMPONENT_UINT outputs. 2024-10-08 22:01:56 +02:00
Henri Verbeet
95a46fb0f0 vkd3d-shader/glsl: Handle SV_POSITION inputs in fragment shaders. 2024-10-08 22:01:56 +02:00
Conor McCarthy
fcb09be6e3 tests/shader-runner: Move the Vulkan helper functions to vulkan_utils.h. 2024-10-08 20:34:03 +02:00
Conor McCarthy
ce83628882 tests/shader-runner: Move struct vulkan_test_context to vulkan_utils.h. 2024-10-08 20:34:03 +02:00
Conor McCarthy
fc65170521 tests/shader_runner: Introduce struct vulkan_test_context for the Vulkan runner. 2024-10-08 20:34:03 +02:00
Conor McCarthy
d76435cd21 tests: Move the dxc compilation helpers to utils.h. 2024-10-08 20:34:03 +02:00
Evan Tang
102cfdab36 tests: Add a test for writing patch constants during tessellation. 2024-10-07 17:44:29 +02:00
Evan Tang
3342d307a8 tests: Add a test for shader interstage register packing. 2024-10-07 17:39:45 +02:00
Evan Tang
c571a45e65 vkd3d-shader/ir: Don't shift register write masks by the component index in shader_dst_param_io_normalise().
This loses information about which source elements they want, making
"o.yzw = reg.xxyz" compile to "o = reg.xxy" instead of "o = reg.xyz".
2024-10-07 17:36:11 +02:00
Evan Tang
b5ccc0e705 vkd3d-shader/ir: Remove an unnecessary typecast in shader_instruction_eliminate_phase_instance_id(). 2024-10-07 17:34:54 +02:00
Giovanni Mascellani
fbd8b1a8c4 tests/shader-runner: Print the WARP driver version.
Since recent versions seem to have more features and possibly
fewer bugs it is useful to know what you're dealing with.

Currently the latest WARP drivers are distributed here:

  https://www.nuget.org/packages/Microsoft.Direct3D.WARP
2024-10-07 17:33:50 +02:00
Elizabeth Figura
34fdb304bb vkd3d-shader/hlsl: Handle error expressions in increments. 2024-10-07 17:33:07 +02:00
Elizabeth Figura
84685fb56d vkd3d-shader/hlsl: Handle error expressions in subscripts. 2024-10-07 17:33:07 +02:00
Elizabeth Figura
c66f25016b vkd3d-shader/hlsl: Handle error expressions in array indexes. 2024-10-07 17:33:07 +02:00
Elizabeth Figura
41ff4343e1 vkd3d-shader/hlsl: Handle error expressions in explicit casts. 2024-10-07 17:33:07 +02:00
Elizabeth Figura
10efdd3f63 vkd3d-shader/hlsl: Introduce an add_explicit_conversion() helper. 2024-10-07 17:33:07 +02:00
Elizabeth Figura
aa79bfa681 vkd3d-shader/preproc: Store argument values per expansion, not per macro. 2024-10-07 17:32:27 +02:00
Henri Verbeet
e7c4867359 vkd3d-shader/glsl: Implement support for VKD3DSPR_IDXTEMP registers. 2024-10-07 17:31:20 +02:00
Henri Verbeet
944929d0da vkd3d-shader/glsl: Implement VKD3DSIH_IADD. 2024-10-07 17:31:20 +02:00
Henri Verbeet
4eed6b8887 vkd3d-shader/glsl: Add interpolation modifiers to interstage inputs and outputs. 2024-10-07 17:31:20 +02:00
Henri Verbeet
7b47528e4b vkd3d-shader/glsl: Handle SV_VERTEX_ID inputs. 2024-10-07 17:31:20 +02:00
Henri Verbeet
79455041f0 vkd3d-shader/glsl: Implement VKD3DSIH_EQO. 2024-10-07 17:31:19 +02:00
Nikolay Sivov
565698711b tests: Add a test for uniform array indexing. 2024-10-07 17:30:41 +02:00
Nikolay Sivov
d1c2ae3f0e vkd3d-shader/hlsl: Remove the type equality assertion for binary expression arguments. 2024-10-07 17:29:40 +02:00
Francisco Casas
0b989c9f37 vkd3d-shader/hlsl: Fix the conditions to discard default values.
Otherwise default_values for strings are lost.

Thanks to Nikolay Sivov for pointing this out.
2024-10-07 17:28:07 +02:00
Feifan He
b7314e2438 vkd3d-shader/msl: Handle signature element masks in the prologue and epilogue. 2024-10-07 17:21:52 +02:00
Feifan He
7c42da465a vkd3d-shader/msl: Generate the shader entry point prologue. 2024-10-07 17:21:52 +02:00
Feifan He
cd070f9995 vkd3d-shader/msl: Generate the shader entry point epilogue. 2024-10-07 17:21:52 +02:00
Feifan He
a88f3168e5 vkd3d-shader/msl: Generate the shader entry point. 2024-10-07 17:21:52 +02:00
Feifan He
577cc47740 vkd3d-shader/msl: Generate shader input structure declarations. 2024-10-07 17:21:52 +02:00
Feifan He
cd5917c648 vkd3d-shader/msl: Generate shader output structure declarations. 2024-10-07 17:21:27 +02:00
Henri Verbeet
25232f2b2b vkd3d-shader/glsl: Implement VKD3DSIH_IMUL. 2024-10-03 19:20:14 +02:00
Henri Verbeet
4dec4e9959 vkd3d-shader/glsl: Implement VKD3DSIH_ILT. 2024-10-03 19:18:15 +02:00
Henri Verbeet
68492e704f vkd3d-shader/glsl: Implement VKD3DSIH_IGE. 2024-10-03 19:15:48 +02:00
Henri Verbeet
cf6a3ad676 vkd3d-shader/glsl: Implement VKD3DSIH_SAMPLE. 2024-10-03 19:15:48 +02:00
Henri Verbeet
eb10f0897e vkd3d-shader/glsl: Implement VKD3DSIH_LD. 2024-10-03 19:14:43 +02:00
Giovanni Mascellani
0e50825b83 vkd3d-shader/ir: Validate indices for UAV registers. 2024-10-03 19:08:33 +02:00
Giovanni Mascellani
3ab68c1e46 vkd3d-shader/ir: Validate indices for RESOURCE registers. 2024-10-03 19:08:33 +02:00
Giovanni Mascellani
ab23038367 vkd3d-shader/ir: Validate indices for SAMPLER registers. 2024-10-03 19:08:33 +02:00
Giovanni Mascellani
da7c9694f1 vkd3d-shader/dxil: Emit SAMPLER, UAV and RESOURCE registers with only 2 indices.
DXIL handles are used to represent descriptors. Currently they are
translated to registers of the appropriate type (depending on the
descriptor type) and three indices. The first two indices are used
to represent the descriptor itself (through its signature and array
index), and are filled when the handle itself is created. The last
index is used with constant buffers to address the data inside the
buffer itself, and it goes unused with other descriptor types.

As currently implemented, however, registers for descriptors other
than constant buffers are still created with three indices, even if
the last one is useless and set to -1. In the interest of creating
more sensible VSIR code, this is now removed: DXIL handles are
created with just two indices; a third one is added when accessing
constant buffers, and nothing is changed for other descriptor types.
2024-10-03 19:08:33 +02:00
Elizabeth Figura
cebe0a8b95 vkd3d-shader/hlsl: Handle error expressions in method calls. 2024-10-03 17:47:26 +02:00
Elizabeth Figura
600f90e8b0 vkd3d-shader/hlsl: Handle error expressions in assignments. 2024-10-03 17:47:26 +02:00
Elizabeth Figura
c94aa5e03c vkd3d-shader/hlsl: Handle error expressions in binary expressions. 2024-10-03 17:47:26 +02:00
Elizabeth Figura
d6052bc31b vkd3d-shader/hlsl: Handle error expressions in function calls. 2024-10-03 17:47:26 +02:00
Elizabeth Figura
5d52bef19d vkd3d-shader/hlsl: Return an "error" expression when using an undeclared variable. 2024-10-03 17:47:26 +02:00
Elizabeth Figura
67093c5833 vkd3d-shader/hlsl: Free static initializers after functions.
We need users of a value to be freed before the value itself is.
Due to copy propagation or use of the pre-allocated error instruction,
static_initializers can contain values that will be used in function blocks.
2024-10-03 17:47:26 +02:00
Giovanni Mascellani
ae27fded1a vkd3d-shader/spirv: Handle all possible destination modifiers.
Historically the SPIR-V backend was only fed by the TPF parser,
which only generates _sat destination modifiers. Now it is fed
by the D3DBC parser too (among others), so it mustn't assert on
other modifiers.

Modifier _pp can be trivially ignored. Modifier _centroid would
probably require some handling, but I'm not immediately sure of
what should happen and it doesn't look like a very urgent thing
anyway, so I'm degrading the assertion to FIXME().
2024-10-02 22:31:50 +02:00
Henri Verbeet
fc4c9b7a95 vkd3d-shader/glsl: Implement VKD3DSIH_USHR. 2024-10-02 22:30:58 +02:00
Henri Verbeet
babbf11d52 vkd3d-shader/glsl: Implement VKD3DSIH_ISHR. 2024-10-02 22:30:58 +02:00
Henri Verbeet
7f1c78f8e2 vkd3d-shader/glsl: Implement VKD3DSIH_ISHL. 2024-10-02 22:30:58 +02:00
Henri Verbeet
f501b8c661 vkd3d-shader/glsl: Implement VKD3DSIH_MAD. 2024-10-02 22:30:58 +02:00
Henri Verbeet
4103e76245 vkd3d-shader/glsl: Implement support for VKD3DSPDM_SATURATE modifiers. 2024-10-02 22:30:58 +02:00
Giovanni Mascellani
49121937cf readme: Document some preprocessor definitions used by vkd3d. 2024-10-02 22:30:29 +02:00
Giovanni Mascellani
2129a7f09d readme: Move the "Developing vkd3d" section upwards.
The idea is to keep at the beginning of the files the sections that
contain general introduction to vkd3d and how it works, which are
likely the first things a reader needs. Then the sections going into
more specific and verbose topics, which are probably to be read only
when looking some specific piece of information.
2024-10-02 22:30:23 +02:00
Nikolay Sivov
79aa75e98f vkd3d-shader/fx: Implement writing fx_2_0 object initializer data sections.
Object data is used for strings, textures, and shaders. Samplers are handled separately.
The section is a contigious stream of <id><size><object-data>, size field is used
to advance to the next <id> position.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-10-02 22:17:41 +02:00
Giovanni Mascellani
7e9dc8da97 vkd3d-shader/ir: Validate index count for MISCTYPE registers. 2024-10-02 22:12:47 +02:00
Giovanni Mascellani
99aebb1b31 vkd3d-shader/ir: Validate index count for RASTOUT registers. 2024-10-02 22:12:47 +02:00
Giovanni Mascellani
19d35d89cd vkd3d-shader/ir: Validate index count for DEPTHOUTLE registers. 2024-10-02 22:12:47 +02:00
Giovanni Mascellani
6259832680 vkd3d-shader/ir: Validate index count for DEPTHOUTGE registers. 2024-10-02 22:12:47 +02:00
Giovanni Mascellani
c3757e6930 vkd3d-shader/ir: Validate index count for DEPTHOUT registers. 2024-10-02 22:12:47 +02:00
Giovanni Mascellani
53e35f2d76 vkd3d-shader/d3dbc: Do not emit indices for DEPTHOUT registers. 2024-10-02 22:11:48 +02:00
Francisco Casas
caa2a9d314 vkd3d-shader/hlsl: Parse sampler_state. 2024-10-02 22:07:34 +02:00
Francisco Casas
f47d523e0b vkd3d-shader/hlsl: Process 'texture' as a valid stateblock lhs. 2024-10-02 22:07:34 +02:00
Francisco Casas
125bf74ef3 tests: Test sampler_state keyword syntax. 2024-10-02 22:07:34 +02:00
Nikolay Sivov
994e994231 vkd3d-shader/fx: Handle assignments with array RHS indexed with a constant or a single variable.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-10-02 22:05:46 +02:00
Nikolay Sivov
2722346ffb vkd3d-shader/hlsl: Do not lower index expressions for effects.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-10-02 22:05:24 +02:00
Nikolay Sivov
849d4b3b2b tests: Add some tests for state value assignments.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-10-02 22:04:44 +02:00
Elizabeth Figura
3b1760134f tests: Test clip planes. 2024-10-02 21:49:54 +02:00
Elizabeth Figura
4400315c4b vkd3d-shader: Allow controlling clip planes through vkd3d-shader parameters. 2024-10-02 21:49:54 +02:00
Elizabeth Figura
85b8503995 vkd3d-shader/ir: Remove newlines from some vkd3d_shader_error() calls. 2024-10-02 21:49:54 +02:00
Henri Verbeet
3452d126a8 vkd3d-shader/glsl: Implement VKD3DSIH_ELSE. 2024-10-01 17:29:48 +02:00
Henri Verbeet
01ba2ba6db vkd3d-shader/glsl: Implement VKD3DSIH_NOT. 2024-10-01 17:29:48 +02:00
Henri Verbeet
1812258f37 vkd3d-shader/glsl: Implement VKD3DSIH_RSQ. 2024-10-01 17:29:48 +02:00
Henri Verbeet
5cf8562124 vkd3d-shader/glsl: Implement VKD3DSIH_MIN. 2024-10-01 17:29:48 +02:00
Henri Verbeet
4f054aed48 vkd3d-shader/glsl: Implement VKD3DSIH_MAX. 2024-10-01 17:29:48 +02:00
Victor Chiletto
2ea5f187f9 vkd3d-shader/hlsl: Allow cbuffer reservations to overlap if only one of them is allocated. 2024-10-01 17:28:41 +02:00
Victor Chiletto
8010ef8771 tests: Add a test for unused overlapping cbuffer reservations. 2024-10-01 17:28:41 +02:00
Nikolay Sivov
5e52ccbf3d vkd3d-shader/hlsl: Move default values indexing fixup to the tpf writer stage.
The primary goal here is to move compilation profile type and version
check outside of a parsing stage. Default values for parameters were
never subjected to this fixup, and it does look tpf-specific, so moving
it where it belongs.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-10-01 17:27:12 +02:00
Andrey Gusev
f28d39b609 vkd3d-utils: Store the actual serialisation return value in D3DStripShader(). 2024-09-30 20:57:15 +02:00
Andrey Gusev
c94eac2d33 vkd3d-utils: Store the actual serialisation return value in get_blob_part(). 2024-09-30 20:52:24 +02:00
Giovanni Mascellani
6822f1fe6c vkd3d-shader/dxil: Trace the program when validation fails after parsing. 2024-09-30 20:48:43 +02:00
Giovanni Mascellani
5f20103518 vkd3d-shader/d3dbc: Trace the program when validation fails after parsing. 2024-09-30 20:48:43 +02:00
Giovanni Mascellani
8acaa3a62c vkd3d-shader/tpf: Propagate validation errors after parsing.
Also, trace the program when validation fails after parsing, mostly
to make debugging easier.
2024-09-30 20:48:43 +02:00
Giovanni Mascellani
0f91149260 vkd3d-shader/d3d-asm: Dump all indices when tracing VSIR code.
Our ASM dumper currently hides or interprets some register indices
in order to match users expectations. This can be inconvenient for
developers, though, because it makes it harder to understand what's
really going on in the VSIR code when reading logs. With this change
the whole index structure is dumped.
2024-09-30 20:22:53 +02:00
Henri Verbeet
10559fa17a vkd3d-shader/glsl: Implement VKD3DSIH_LOG. 2024-09-30 20:21:14 +02:00
Henri Verbeet
700eba0b01 vkd3d-shader/glsl: Handle SV_IS_FRONT_FACE inputs. 2024-09-30 20:20:11 +02:00
Henri Verbeet
0cc0b68fb4 vkd3d-shader/glsl: Implement VKD3DSIH_ROUND_NE. 2024-09-30 20:08:58 +02:00
Henri Verbeet
308121ba04 vkd3d-shader/glsl: Implement VKD3DSIH_IF and VKD3DSIH_ENDIF. 2024-09-30 20:08:58 +02:00
Henri Verbeet
e911433e0c vkd3d-shader/glsl: Implement VKD3DSIH_ROUND_NI. 2024-09-30 20:08:58 +02:00
Giovanni Mascellani
5c2b057b56 vkd3d-shader/ir: Validate UAV registers. 2024-09-30 20:05:52 +02:00
Giovanni Mascellani
b7b5b0cff8 vkd3d-shader/ir: Validate RESOURCE registers. 2024-09-30 20:05:52 +02:00
Giovanni Mascellani
a0b98c1610 vkd3d-shader/ir: Validate SAMPLER registers. 2024-09-30 20:05:52 +02:00
Giovanni Mascellani
7404fa5285 vkd3d-shader/dxil: Emit RESOURCE and UAV registers with data type UNUSED. 2024-09-30 20:05:39 +02:00
Nikolay Sivov
300e4e0d12 vkd3d-shader/fx: Add support for writing annotations for fx_2_0.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-30 20:02:51 +02:00
Nikolay Sivov
c9c537faa0 vkd3d-shader/fx: Add initial support for writing default values for fx_2_0.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-30 20:02:05 +02:00
Nikolay Sivov
da0469f190 vkd3d-shader/fx: Handle the 'half' type in fx_4+.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-30 20:01:57 +02:00
Nikolay Sivov
2626dcc55d tests: Add some tests for initial values in effects.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-30 19:59:21 +02:00
Conor McCarthy
2bf517782d vkd3d-shader/dxil: Load forward-referenced sources as value/type pairs in sm6_parser_emit_store(). 2024-09-30 19:58:06 +02:00
Conor McCarthy
6a86e1a8d9 vkd3d-shader/dxil: Load forward-referenced comparands as value/type pairs in sm6_parser_emit_cmpxchg(). 2024-09-30 19:57:55 +02:00
Francisco Casas
95bd06be83 tests/shader-runner: Query for SM6 support instead of checking VKD3D_SHADER_UNSUPPORTED_DXIL.
This change avoids skipping the tests on a Windows build, where the
support is present but the macro is not defined.

Thanks Giovanni for pointing this out.
2024-09-30 19:29:14 +02:00
Francisco Casas
42f910e56e tests/shader_runner: Query for GLSL target support instead of checking VKD3D_SHADER_UNSUPPORTED_GLSL. 2024-09-30 19:28:09 +02:00
Giovanni Mascellani
828e5f1249 vkd3d-shader/ir: Disallow RESOURCE registers in destination parameters. 2024-09-26 17:44:52 +02:00
Giovanni Mascellani
674ad7d655 vkd3d-shader/ir: Disallow SAMPLER registers in destination parameters. 2024-09-26 17:44:52 +02:00
Giovanni Mascellani
6de741e5e7 vkd3d-shader/ir: Do not allow NULL registers in source parameters. 2024-09-26 17:44:52 +02:00
Giovanni Mascellani
8d85ea2dc5 vkd3d-shader: Get rid of the RESOURCE data type. 2024-09-26 17:42:16 +02:00
Giovanni Mascellani
e58726310b vkd3d-shader: Get rid of the UAV data type. 2024-09-26 17:42:16 +02:00
Giovanni Mascellani
2934f820a9 vkd3d-shader: Get rid of the SAMPLER data type. 2024-09-26 17:42:16 +02:00
Giovanni Mascellani
afa2fd527c vkd3d-shader/dxil: Release memory on exceptional paths when parsing DXIL code. (Valgrind) 2024-09-26 17:41:21 +02:00
Henri Verbeet
466c8bfbb7 vkd3d-shader/glsl: Implement VKD3DSIH_LTO. 2024-09-26 17:40:07 +02:00
Henri Verbeet
44e96ad4d6 vkd3d-shader/glsl: Implement VKD3DSIH_EXP. 2024-09-26 17:40:07 +02:00
Henri Verbeet
d68e60a78a vkd3d-shader/glsl: Implement VKD3DSIH_IEQ. 2024-09-26 17:40:07 +02:00
Henri Verbeet
55de9ea405 vkd3d-shader/glsl: Implement VKD3DSIH_DCL_INPUT_PS. 2024-09-26 17:40:07 +02:00
Henri Verbeet
f0c8b4a3c5 vkd3d-shader/glsl: Implement VKD3DSIH_SQRT. 2024-09-26 17:40:07 +02:00
Giovanni Mascellani
5ad83a05ff vkd3d-shader/dxil: Release memory on exceptional paths in sm6_parser_read_signature(). (Valgrind) 2024-09-26 01:05:35 +02:00
Henri Verbeet
92a7cc3420 vkd3d-shader/glsl: Implement VKD3DSIH_DP2. 2024-09-26 01:04:32 +02:00
Henri Verbeet
b9d8b84b06 vkd3d-shader/glsl: Implement VKD3DSIH_DP4. 2024-09-26 01:04:32 +02:00
Henri Verbeet
93cd63bc93 vkd3d-shader/glsl: Implement VKD3DSIH_DP3. 2024-09-26 01:04:32 +02:00
Henri Verbeet
929010ffd7 vkd3d-shader/glsl: Implement support for the VKD3DSPR_DEPTHOUT register. 2024-09-26 01:04:32 +02:00
Henri Verbeet
459f141e81 vkd3d-shader/glsl: Implement VKD3DSIH_ROUND_Z. 2024-09-26 01:04:32 +02:00
Feifan He
e8b14d765d vkd3d-shader/msl: Implement support for VKD3DSPR_TEMP registers. 2024-09-24 13:56:11 +02:00
Francisco Casas
ebc4f84185 tests/shader_runner: Use skip() when the d3d12 device doesn't support shader model 6. 2024-09-24 13:54:27 +02:00
Francisco Casas
a4262c3836 tests/shader_runner: Skip the DXIL tests when DXIL support is not enabled. 2024-09-24 13:51:14 +02:00
Francisco Casas
94af1754dd tests/shader_runner: Skip the GLSL tests when GLSL support is not enabled. 2024-09-24 13:45:57 +02:00
Henri Verbeet
f37be27bdc vkd3d-shader/ir: Properly check the register bounds in shader_signature_find_element_for_reg().
Perhaps the existing code is safe in practice, but doing the check
properly avoids having to make that determination.
2024-09-24 13:39:43 +02:00
Henri Verbeet
8e39783770 vkd3d-shader/glsl: Implement VKD3DSIH_ROUND_PI. 2024-09-24 13:38:26 +02:00
Henri Verbeet
58472e7404 vkd3d-shader/glsl: Implement VKD3DSIH_FTOU. 2024-09-24 13:38:26 +02:00
Atharva Nimbalkar
f441d3e112 vkd3d-shader/glsl: Implement VKD3DSIH_UTOF. 2024-09-24 13:38:26 +02:00
Henri Verbeet
a3d06c8f12 vkd3d-shader/glsl: Implement VKD3DSIH_FTOI. 2024-09-24 13:38:26 +02:00
Atharva Nimbalkar
b81cdcb488 vkd3d-shader/glsl: Implement VKD3DSIH_ITOF. 2024-09-24 13:38:26 +02:00
Conor McCarthy
91475c684f vkd3d: Clear the output pointer on failure in vkd3d_create_versioned_root_signature_deserializer(). 2024-09-24 13:34:40 +02:00
Conor McCarthy
ae4a6c7044 tests/d3d12: Test invalid bytecode in test_root_signature_byte_code(). 2024-09-24 13:30:33 +02:00
Giovanni Mascellani
e2c6058734 vkd3d-shader/spirv: Do not specify depth for SPIR-V images.
SPIR-V images have a "depth" parameter that, as far as I understand
(the spec doesn't look terribly clear in that regard), specifies
whether the image can be used for depth-comparison operations.

In TPF (and therefore in VSIR) the same information is specified
on the sampler type instead of on the image type. This puts us in
a hard spot, because in principle an image can be used with
many different samplers, and the mapping might even be unknown
at compilation time, so it's not clear how we should define our
images.

We currently have some algorithms to deal with that, but they are
incomplete and lead to SPIR-V validation errors like:

    Expected Image to have the same type as Result Type Image
      %63 = OpSampledImage %62 %59 %61

The problem here is that the image has a non-depth type, but is
being sampled as a depth image. This check was added recently to
SPIRV-Tools, so we became aware of the problem.

As I said, it's not easy in general to decide whether an image is
going to be sampled with depth-comparison operators or not.
Fortunately the SPIR-V spec allow to mark the depth parameter as
unknown (using value 2), so until we come up with something better
we use that for all images to please the validator and avoid
giving misleading hints to the driver.
2024-09-24 13:19:17 +02:00
Arkadiusz Hiler
a3017fe9d5 vkd3d-shader/preproc: Support namespaces in macro identifiers. 2024-09-24 13:17:24 +02:00
Giovanni Mascellani
a2aeb3a142 vkd3d-shader/spirv: Cache numeric types without through the general declaration cache.
Numeric types are used very frequently, and doing a tree search
each time one is needed tends to waste a lot of time.

I ran the compilation of ~1000 DXBC-TPF shaders randomly taken from
my collection and measured the performance using callgrind and the
kcachegrind "cycle count" estimation.

BEFORE:
 * 1,764,035,136 cycles
 * 1,767,948,767 cycles
 * 1,773,927,734 cycles

AFTER:
 * 1,472,384,755 cycles
 * 1,469,506,188 cycles
 * 1,470,191,425 cycles

So callgrind would estimate a 16% improvement at least.
2024-09-23 15:48:35 +02:00
Giovanni Mascellani
3a21daa49e vkd3d-shader/spirv: Rewrite vkd3d_spirv_get_type_id_for_data_type() in terms of vkd3d_spirv_get_type_id(). 2024-09-23 15:48:35 +02:00
Conor McCarthy
945e8a9024 vkd3d: Sort bounded descriptor ranges after unbounded ones of equal offset.
Enables the bounded range to be mapped to the unbounded one, instead of
being mapped to a separate binding which will be populated from the same
d3d12 descriptors as the unbounded one.
2024-09-23 15:45:26 +02:00
Conor McCarthy
966e627733 tests/d3d12: Test a bounded range at the same offset as an unbounded one in test_unbounded_resource_arrays(). 2024-09-23 15:45:26 +02:00
Elizabeth Figura
650bf4d83f vkd3d-shader/hlsl: Fix a corner case in ternary type conversion.
If the condition and argument types are compatible, i.e. there is no broadcast,
the resulting shape should be the shape of the arguments, not the shape of the
condition.
2024-09-23 15:43:15 +02:00
Elizabeth Figura
b2cddecfc5 vkd3d-shader/hlsl: Use add_cast() in append_conditional_break().
Instead of creating a cast node directly.

This specifically handles the 1x1 matrix case, which currently the backend code does not expect.
2024-09-23 15:43:15 +02:00
Henri Verbeet
1e97e1203f vkd3d-shader/d3dbc: Write the actual constant info offset in write_sm1_uniforms(). 2024-09-23 15:42:25 +02:00
Atharva Nimbalkar
ee8e005209 vkd3d-shader/glsl: Implement VKD3DSIH_MOVC. 2024-09-23 15:41:07 +02:00
Henri Verbeet
7b99c33510 vkd3d-shader/glsl: Implement VKD3DSIH_FRC. 2024-09-23 15:41:07 +02:00
Henri Verbeet
36c08b47e9 vkd3d-shader/glsl: Implement VKD3DSIH_GEO. 2024-09-23 15:41:07 +02:00
Henri Verbeet
28ef331704 vkd3d-shader/glsl: Implement support for VKD3DSPSM_NEG modifiers. 2024-09-23 15:41:07 +02:00
Henri Verbeet
b9366def96 vkd3d-shader/glsl: Implement VKD3DSIH_DIV. 2024-09-23 15:41:07 +02:00
Elizabeth Figura
43b714d896 vkd3d-shader/hlsl: Handle error expressions in unary expressions. 2024-09-23 15:28:47 +02:00
Elizabeth Figura
7e3231c749 vkd3d-shader/hlsl: Return an "error" expression when constructing an arithmetic expression from incompatible types. 2024-09-23 15:28:47 +02:00
Elizabeth Figura
c43e5c8eb5 vkd3d-shader/hlsl: Introduce the "error" type.
Currently, if an expression successfully parses according to the bison grammar,
but for one reason or another cannot generate a meaningful IR instruction, we
abort parsing with YYABORT. This includes, for example, an undefined variable or
function, invalid swizzle or field reference, or a constructor with a complex or
non-numeric data type.

Aborting parsing is unfortunate, however, because it means that any further
errors in the program cannot be caught by the programmer, increasing the number
of times they will need to fix errors and recompile.

The idea of this patch is that any such expression will instead generate an IR
node whose data type is of HLSL_CLASS_ERROR. Any further expression which would
consume an "error" typed instruction will instead immediately return an
expression of type "error" (probably the same one) instead of aborting or doing
any other type-checking.

Currently these "error" instructions should not pass the parsing stage, since
hlsl_compile_shader() will immediately notice that compilation has failed and
skip any optimization, lowering, or bytecode-writing.

A further direction to take this is to pre-allocate one "error" expression
immediately when creating the HLSL parser, and return that expression when we
fail to allocate an hlsl_ir_node of any type. This means we do not need to
handle allocation errors when constructing nodes, saving us quite a lot of error
handling (which is not only tedious but currently often broken, if nothing else
by virtue of neglecting cleanup of local variables).
2024-09-23 15:28:47 +02:00
Elizabeth Figura
7daaaf6386 vkd3d-shader/hlsl: Clarify a comment. 2024-09-23 15:28:47 +02:00
Elizabeth Figura
010aa53bfa vkd3d-shader/hlsl: Do not handle HLSL_CLASS_CONSTANT_BUFFER in copy_propagation_transform_load(). 2024-09-23 15:28:47 +02:00
Elizabeth Figura
f73a23f735 vkd3d-shader/hlsl: Do not create a copy in add_assignment(). 2024-09-23 15:28:47 +02:00
Elizabeth Figura
eb7f5f7f68 vkd3d-shader/hlsl: Return bool from add_assignment(). 2024-09-23 15:28:47 +02:00
Elizabeth Figura
8975933aff vkd3d-shader/hlsl: Store a pointer to the block's "value" instruction in the block. 2024-09-23 15:28:47 +02:00
Nikolay Sivov
799e6105a4 vkd3d-shader/d3dbc: Add an option to treat doubles as floats.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55448
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-23 15:26:35 +02:00
Nikolay Sivov
d7def84253 vkd3d-shader/hlsl: Remove the 'double' keyword.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-23 15:26:35 +02:00
Nikolay Sivov
968a3dfc1a tests: Add some more tests for type name handling.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-23 15:26:28 +02:00
Nikolay Sivov
b5c5783293 vkd3d-shader: Explicitly set indices for the numeric type names array.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-23 15:25:36 +02:00
Andrey Gusev
2ac7f650a1 vkd3d: Recognise VK_QUEUE_VIDEO_ENCODE_BIT_KHR in debug_vk_queue_flags(). 2024-09-20 17:21:44 +02:00
Nikolay Sivov
f64689eed8 vkd3d-shader/tpf: Set temps count in the STAT section.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-20 17:20:02 +02:00
Nikolay Sivov
478e28ea79 vkd3d-shader/tpf: Move STAT fields update to a separate helper.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-20 17:20:02 +02:00
Henri Verbeet
bec7188333 vkd3d-utils: Make D3D12CreateDevice a variadic macro, if possible.
Mostly to make life easier for (external) code invoking this with
IID_PPV_ARGS or similar constructions.
2024-09-20 17:17:30 +02:00
Henri Verbeet
bc70d575ae vkd3d-shader/glsl: Implement VKD3DSIH_OR. 2024-09-20 17:16:33 +02:00
Henri Verbeet
e289c3999d vkd3d-shader/glsl: Implement VKD3DSIH_INE. 2024-09-20 17:16:33 +02:00
Henri Verbeet
3b3fe1da2c vkd3d-shader/glsl: Implement VKD3DSIH_MUL. 2024-09-20 17:16:33 +02:00
Atharva Nimbalkar
2fc35da940 vkd3d-shader/glsl: Implement support for VSIR_DIMENSION_VEC4 immediate constants. 2024-09-20 17:16:33 +02:00
Henri Verbeet
2409966ff2 vkd3d-shader/glsl: Implement VKD3DSIH_NEU. 2024-09-20 17:16:33 +02:00
Giovanni Mascellani
9777c8bc65 vkd3d-shader/spirv: Do not reallocate the SPIR-V program.
I ran the compilation of ~1000 DXBC-TPF shaders randomly taken from
my collection and measured the performance using callgrind and the
kcachegrind "cycle count" estimation.

BEFORE:
 * 1,846,641,596 cycles
 * 1,845,635,336 cycles
 * 1,841,335,225 cycles

AFTER:
 * 1,764,035,136 cycles
 * 1,767,948,767 cycles
 * 1,773,927,734 cycles

So callgrind would estimate a 3.6% improvement at least.

The counterpoint is that the caller might get an allocation that
is potentially bigger than necessary. I would expect that allocation
to be rather short-lived anyway, so that's probably not a problem.
2024-09-20 17:14:49 +02:00
Giovanni Mascellani
35d3161f9d vkd3d-shader/spirv: Propagate errors from vkd3d_spirv_stream_append(). 2024-09-20 17:04:31 +02:00
Giovanni Mascellani
637a3cabe7 vkd3d-shader/ir: Allow failure in shader_signature_find_element_for_reg().
shader_signature_find_element_for_reg() is also used in the TPF parser,
where the program has not been validated yet, so it must not crash
on errors.

The I/O normaliser can instead assume that the shader is already
validated.

This fixes a crash with a shader used by The Falconeer. The bug is still
present, because the shader will be incorrectly rejected, but at least
the vkd3d-shader will fail gracefully.
2024-09-20 17:01:29 +02:00
Nikolay Sivov
32ced3bd8f vkd3d-shader/tpf: Set 'gather' instructions counter in the STAT. 2024-09-19 14:38:59 +02:00
Nikolay Sivov
01f6ef5e6d vkd3d-shader/tpf: Add a 'lod' counter to the STAT. 2024-09-19 14:38:59 +02:00
Nikolay Sivov
7c9695b261 vkd3d-shader/tpf: Handle barrier instructions in STAT.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-19 14:38:59 +02:00
Henri Verbeet
d4bc51b850 vkd3d-shader/d3dbc: Introduce enum vkd3d_sm1_rastout_register. 2024-09-19 14:38:03 +02:00
Atharva Nimbalkar
f8d403f330 vkd3d-shader/glsl: Implement VKD3DSIH_AND. 2024-09-19 14:35:24 +02:00
Henri Verbeet
c8acf285cb vkd3d-shader/glsl: Implement support for VKD3DSPSM_ABS modifiers. 2024-09-19 14:35:20 +02:00
Atharva Nimbalkar
1d485cc8a9 vkd3d-shader/glsl: Implement support for VKD3DSPR_IMMCONST registers. 2024-09-19 14:32:29 +02:00
Atharva Nimbalkar
ab07637ee1 vkd3d-shader/glsl: Implement VKD3DSIH_ADD. 2024-09-19 14:29:46 +02:00
Henri Verbeet
ae40184631 vkd3d-shader/glsl: Implement support for VKD3DSPR_CONSTBUFFER registers. 2024-09-19 14:29:46 +02:00
Henri Verbeet
e9f0c6fef3 vkd3d-shader/glsl: Handle SV_TARGET outputs. 2024-09-18 15:04:52 +02:00
Henri Verbeet
6cae2d006c vkd3d-shader/d3dbc: Introduce enum vkd3d_sm1_misc_register. 2024-09-18 15:04:10 +02:00
Henri Verbeet
29e58a2be3 build: Use a tab to indent the "tests/hlsl/constructgswithso.shader_test" line in Makefile.am.
I had originally noticed this during review, and then promptly forgot about it.
2024-09-18 15:03:53 +02:00
Feifan He
9b1b7e86cf vkd3d-shader/msl: Implement VKD3DSIH_RET. 2024-09-18 15:02:57 +02:00
Feifan He
7aa0de27e9 vkd3d-shader/msl: Implement VKD3DSIH_MOV. 2024-09-18 14:48:03 +02:00
Henri Verbeet
a1487380bb vkd3d-shader/glsl: Implement support for VKD3DSPR_OUTPUT registers. 2024-09-17 18:05:47 +02:00
Henri Verbeet
c462c62108 vkd3d-shader/glsl: Implement support for VKD3DSPR_INPUT registers. 2024-09-17 18:05:47 +02:00
Feifan He
deda49e501 vkd3d-shader/msl: Implement VKD3DSIH_NOP. 2024-09-17 11:30:26 +02:00
Feifan He
842841907e vkd3d-shader/msl: Add vkd3d-shader version information to the generated shader. 2024-09-17 11:30:26 +02:00
Feifan He
c278c901b5 vkd3d-shader/msl: Keep track of the current indentation level 2024-09-17 11:30:26 +02:00
Giovanni Mascellani
56ec211d04 vkd3d-shader/ir: Introduce a helper for validating Hull Shader phases. 2024-09-16 19:32:32 +02:00
Giovanni Mascellani
259273a133 vkd3d-shader/ir: Introduce a helper for validating DCL_TESSELLATOR_PARTITIONING. 2024-09-16 19:32:32 +02:00
Giovanni Mascellani
a3c7bebc18 vkd3d-shader/ir: Introduce a helper for validating DCL_TESSELLATOR_OUTPUT_PRIMITIVE. 2024-09-16 19:32:32 +02:00
Giovanni Mascellani
48f512a83a vkd3d-shader/ir: Introduce a helper for validating DCL_TESSELLATOR_DOMAIN. 2024-09-16 19:32:32 +02:00
Giovanni Mascellani
8aa2364381 vkd3d-shader/ir: Introduce a helper for validating DCL_OUTPUT_CONTROL_POINT_COUNT. 2024-09-16 19:32:32 +02:00
Nikolay Sivov
0e9fcb1431 vkd3d-shader/tpf: Handle tessellation stage fields in STAT.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-16 14:04:46 +02:00
Nikolay Sivov
947b151ed4 vkd3d-shader/tpf: Handle atomic instructions in STAT.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-16 14:01:29 +02:00
Nikolay Sivov
7c12371298 vkd3d-shader/tpf: Handle bitwise instructions in STAT.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-16 14:01:18 +02:00
Nikolay Sivov
90fc57ff89 vkd3d-shader/tpf: Handle GS reflection fields in the STAT section.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-16 14:01:07 +02:00
Nikolay Sivov
97cc27d33f vkd3d-shader/d3d-asm: Tweak some GS declaration names.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-16 13:58:57 +02:00
Giovanni Mascellani
c45bb5badc vkd3d-shader/ir: Introduce a helper for validating DCL_GL_INSTANCES. 2024-09-16 13:53:52 +02:00
Giovanni Mascellani
dec7a0dbd2 vkd3d-shader/ir: Introduce a helper for validating DCL_OUTPUT_TOPOLOGY. 2024-09-16 13:53:52 +02:00
Giovanni Mascellani
22ba37c8b9 vkd3d-shader/ir: Introduce a helper for validating DCL_VERTICES_OUT. 2024-09-16 13:53:51 +02:00
Giovanni Mascellani
936adff58b vkd3d-shader/ir: Introduce a helper for validating DCL_INPUT_PRIMITIVE. 2024-09-16 13:53:51 +02:00
Giovanni Mascellani
0f07a2c512 vkd3d-shader/ir: Introduce a helper for validating DCL_HS_MAX_TESSFACTOR. 2024-09-16 13:53:51 +02:00
Giovanni Mascellani
e1c3266793 vkd3d-shader/ir: Record entering a block in the LABEL validation handler. 2024-09-16 13:53:51 +02:00
Giovanni Mascellani
1d21588de7 vkd3d-shader/ir: Record leaving a block in the relevant validation handlers. 2024-09-16 13:53:51 +02:00
Giovanni Mascellani
3e012c355d vkd3d-shader/ir: Validate NOP instructions. 2024-09-14 16:44:17 +02:00
Giovanni Mascellani
27b421be6a vkd3d-shader/ir: Do not access a missing destination register when validating PHI. 2024-09-14 16:44:17 +02:00
Giovanni Mascellani
e27cf68173 vkd3d-shader/ir: Introduce a helper for validating PHI. 2024-09-14 16:44:16 +02:00
Giovanni Mascellani
9696a0cd4a vkd3d-shader/ir: Introduce a helper for validating SWITCH_MONOLITHIC. 2024-09-14 16:44:16 +02:00
Giovanni Mascellani
ce6306c6fb vkd3d-shader/ir: Introduce a helper for validating BRANCH. 2024-09-14 16:44:16 +02:00
Giovanni Mascellani
504f4223c2 vkd3d-shader/ir: Introduce a helper for validating LABEL. 2024-09-14 16:44:16 +02:00
Giovanni Mascellani
c447a062c4 vkd3d-shader/ir: Introduce a helper for validating RET. 2024-09-14 16:44:16 +02:00
Giovanni Mascellani
88b3d4fb3a vkd3d-shader/ir: Introduce a helper for validating ENDSWITCH. 2024-09-14 16:44:16 +02:00
Giovanni Mascellani
4939f580a4 vkd3d-shader/ir: Introduce a helper for validating SWITCH. 2024-09-14 16:44:16 +02:00
Francisco Casas
4b85e6b1f8 vkd3d-shader/d3dbc: Remove ctx and entry_func args in d3dbc_compile(). 2024-09-14 16:39:24 +02:00
Francisco Casas
b72ef6038d vkd3d-shader/hlsl: Remove hlsl_ir_vsir_instruction_ref. 2024-09-14 16:39:17 +02:00
Francisco Casas
6bd0390498 vkd3d-shader/hlsl: Save hlsl_ir_if in the vsir_program for SM1. 2024-09-14 16:33:25 +02:00
Henri Verbeet
6b0baeb6c2 vkd3d-shader/ir: Merge vsir_program_normalise_combined_samplers() into vsir_program_lower_instructions(). 2024-09-14 16:11:45 +02:00
Henri Verbeet
3b68aa5b87 vkd3d-shader/ir: Introduce vsir_src_param_init_sampler(). 2024-09-14 16:11:45 +02:00
Henri Verbeet
7ea8a29036 vkd3d-shader/ir: Introduce vsir_src_param_init_resource(). 2024-09-14 16:11:45 +02:00
Henri Verbeet
ca445cd832 vkd3d-shader/ir: Move the instruction helpers together. 2024-09-14 16:11:45 +02:00
Henri Verbeet
d54e2ebd7d vkd3d-shader/ir: Move the destination parameter helpers up. 2024-09-14 16:11:45 +02:00
Henri Verbeet
4bad83c9fb vkd3d-shader/ir: Move the source parameter helpers up. 2024-09-14 16:11:45 +02:00
Francisco Casas
ffc1449412 vkd3d-shader/hlsl: Allow effect calls on default value initializers. 2024-09-14 16:09:12 +02:00
Francisco Casas
4aa262d773 vkd3d-shader/hlsl: Parse ConstructGSWithSO(). 2024-09-14 16:09:08 +02:00
Francisco Casas
1f9fc2a422 vkd3d-shader/hlsl: Process GeometryShader as a valid stateblock lhs. 2024-09-14 16:02:43 +02:00
Francisco Casas
3423d1b54b tests: Test ConstructGSWithSO() parsing. 2024-09-14 15:59:35 +02:00
Francisco Casas
02b249d5e7 vkd3d-shader/hlsl: Introduce enum hlsl_compile_type. 2024-09-14 15:57:40 +02:00
Nikolay Sivov
4c03cda3c7 vkd3d-shader/tpf: Handle texture instructions in STAT.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-13 16:01:22 +02:00
Nikolay Sivov
9e4b2f5a1b vkd3d-shader/tpf: Handle 'movc' in STAT.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-13 16:01:22 +02:00
Nikolay Sivov
7bd6c6b172 vkd3d-shader/tpf: Handle 'emit' and 'cut' in STAT.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-13 16:01:22 +02:00
Nikolay Sivov
908833fa6b vkd3d-shader/tpf: Handle arithmetic instructions in STAT.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-13 16:01:22 +02:00
Nikolay Sivov
cfa8f0dccb vkd3d-shader/tpf: Handle conversion instructions in STAT.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-13 16:01:22 +02:00
Giovanni Mascellani
44222ea739 vkd3d-shader/ir: Introduce a helper for validating ENDREP. 2024-09-13 15:59:49 +02:00
Giovanni Mascellani
e9fbbf26bb vkd3d-shader/ir: Introduce a helper for validating REP. 2024-09-13 15:59:15 +02:00
Giovanni Mascellani
bf9022d3df vkd3d-shader/ir: Introduce a helper for validating ENDLOOP. 2024-09-13 15:58:46 +02:00
Giovanni Mascellani
5ce10b9e68 vkd3d-shader/ir: Introduce a helper for validating LOOP. 2024-09-13 15:58:01 +02:00
Giovanni Mascellani
34c8aaad29 vkd3d-shader/ir: Introduce a helper for validating ENDIF. 2024-09-13 15:57:39 +02:00
Giovanni Mascellani
244838d344 vkd3d-shader/ir: Introduce a helper for validating ELSE. 2024-09-13 15:56:18 +02:00
Giovanni Mascellani
8af2d04dbc vkd3d-shader/ir: Introduce a helper for validating IFC. 2024-09-13 15:54:51 +02:00
Giovanni Mascellani
af687c9522 vkd3d-shader/ir: Introduce a helper for validating IF. 2024-09-13 15:54:16 +02:00
Giovanni Mascellani
35fe5b48c8 vkd3d-shader/ir: Introduce a helper for validating DCL_TEMPS. 2024-09-13 15:52:07 +02:00
Henri Verbeet
d30160710b vkd3d-shader/tpf: Include vkd3d_d3dcommon.h only from tpf.c. 2024-09-12 18:50:51 +02:00
Henri Verbeet
14ee3b3e4a vkd3d-shader/d3dbc: Use VKD3D_SM1_DCL_USAGE_SHIFT and VKD3D_SM1_DCL_USAGE_INDEX_SHIFT in d3dbc_write_semantic_dcl(). 2024-09-12 18:49:57 +02:00
Elizabeth Figura
1aa857735f vkd3d-shader/hlsl: Preserve doubles in intrinsic_determinant(). 2024-09-12 18:48:52 +02:00
Elizabeth Figura
e146cc4c8e vkd3d-shader/hlsl: Preserve doubles in intrinsic_cross(). 2024-09-12 18:48:52 +02:00
Elizabeth Figura
1176aaad22 vkd3d-shader/hlsl: Preserve doubles in elementwise_intrinsic_float_convert_args(). 2024-09-12 18:48:52 +02:00
Elizabeth Figura
ebaf877b62 vkd3d-shader/hlsl: Preserve doubles in intrinsic_float_convert_arg(). 2024-09-12 18:48:52 +02:00
Elizabeth Figura
534d546ed9 vkd3d-shader/hlsl: Use expr_common_base_type() in intrinsic_cross(). 2024-09-12 18:48:52 +02:00
Elizabeth Figura
9260078300 vkd3d-shader/hlsl: Use intrinsic_float_convert_arg() in write_acos_or_asin(). 2024-09-12 18:48:52 +02:00
Anna (navi) Figueiredo Gomes
e61046fb23 vkd3d-shader/hlsl: Implement the "earlydepthstencil" attribute. 2024-09-12 18:46:24 +02:00
Anna (navi) Figueiredo Gomes
fe8a2f820b tests/shader_runner: Test the "earlydepthstencil" attribute. 2024-09-12 18:45:56 +02:00
Francisco Casas
0c621f9e4e vkd3d-shader/hlsl: Save hlsl_ir_jump in the vsir_program for SM1. 2024-09-12 18:43:55 +02:00
Francisco Casas
08fb683784 vkd3d-shader/hlsl: Save hlsl_ir_resource_load in the vsir_program for SM1. 2024-09-12 18:42:25 +02:00
Francisco Casas
961c4f8b23 vkd3d-shader/hlsl: Save CAST hlsl_ir_exprs in the vsir_program for SM1. 2024-09-12 18:39:43 +02:00
Francisco Casas
8933620109 vkd3d-shader/hlsl: Save REINTERPRET hlsl_ir_exprs as vsir_program MOVs for SM1. 2024-09-12 18:33:19 +02:00
Giovanni Mascellani
866f138875 vkd3d-shader/ir: Record the control flow type in the program. 2024-09-12 18:31:32 +02:00
Giovanni Mascellani
dcee148b1a vkd3d-shader/ir: Move the control flow type enumeration to vkd3d_shader_private.h. 2024-09-12 18:27:20 +02:00
Nikolay Sivov
ec644b395b vkd3d-shader/tpf: Create a stub STAT section.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-12 18:26:08 +02:00
Feifan He
5df81049aa vkd3d-shader/msl: Call vsir_program_transform() before generating code. 2024-09-12 18:09:00 +02:00
Feifan He
47981def0d vkd3d-shader/msl: Generate comments for unhandled instructions.
Similar to commit 8a60814476 for the GLSL
target.
2024-09-12 18:04:44 +02:00
Feifan He
23ba1a5e07 vkd3d-shader: Introduce VKD3D_SHADER_TARGET_MSL. 2024-09-12 17:03:32 +02:00
Henri Verbeet
ab525f31e4 vkd3d-shader/d3dbc: Use enum vkd3d_shader_src_modifier in struct sm1_src_register. 2024-09-11 15:24:54 +02:00
Henri Verbeet
f3e6c75c89 vkd3d-shader/d3dbc: Use enum vkd3d_shader_dst_modifier in struct sm1_dst_register. 2024-09-11 15:19:29 +02:00
Giovanni Mascellani
b31c9831fa vkd3d-shader/ir: Print results as signed numbers. 2024-09-11 15:13:14 +02:00
Giovanni Mascellani
096f133b09 vkd3d-shader/ir: Rename vsir_program_normalise() to vsir_program_transform(). 2024-09-11 15:13:14 +02:00
Giovanni Mascellani
03ab0156a2 vkd3d-shader/ir: Run validation after inserting the alpha test. 2024-09-11 15:13:14 +02:00
Giovanni Mascellani
5c0d640d18 vkd3d-shader/ir: Run validation after flattening control flow constructs. 2024-09-11 15:13:14 +02:00
Giovanni Mascellani
4b06729be8 vkd3d-shader/ir: Run validation after normalising combined samplers. 2024-09-11 15:13:14 +02:00
Giovanni Mascellani
c2fd1e42fd vkd3d-shader/ir: Run validation after removing dead code. 2024-09-11 15:13:14 +02:00
Elizabeth Figura
82773eb805 vkd3d-shader/hlsl: Use elementwise_intrinsic_float_convert_args() in refract(). 2024-09-11 15:11:42 +02:00
Elizabeth Figura
2688a24bde vkd3d-shader/hlsl: Preserve halves in intrinsic_step(). 2024-09-11 15:11:42 +02:00
Elizabeth Figura
b23c172a47 vkd3d-shader/hlsl: Use elementwise_intrinsic_float_convert_args() in intrinsic_smoothstep(). 2024-09-11 15:11:42 +02:00
Elizabeth Figura
e7eadb38b8 vkd3d-shader/hlsl: Use elementwise_intrinsic_float_convert_args() in intrinsic_faceforward(). 2024-09-11 15:11:42 +02:00
Elizabeth Figura
24e29649c4 vkd3d-shader/hlsl: Use elementwise_intrinsic_convert_args() in intrinsic_dst().
This one preserves integer arguments.
2024-09-11 15:11:42 +02:00
Elizabeth Figura
7636f2a233 vkd3d-shader/hlsl: Use elementwise_intrinsic_float_convert_args() in write_atan_or_atan2(). 2024-09-11 15:11:42 +02:00
Francisco Casas
6e6e2910d6 vkd3d-shader/hlsl: Save DP2ADD hlsl_ir_exprs in the vsir_program for SM1. 2024-09-11 15:10:16 +02:00
Francisco Casas
4ed16108f0 vkd3d-shader/hlsl: Save COS_REDUCED and SIN_REDUCED in the vsir_program for SM1. 2024-09-11 15:09:58 +02:00
Francisco Casas
5db2c2a949 vkd3d-shader/hlsl: Save DOT hlsl_ir_exprs in the vsir_program for SM1. 2024-09-11 15:09:17 +02:00
Francisco Casas
d70342d66d vkd3d-shader/hlsl: Save per-component hlsl_ir_exprs in the vsir_program for SM1. 2024-09-11 15:07:35 +02:00
Francisco Casas
82dec5db46 vkd3d-shader/hlsl: Save simple hlsl_ir_exprs in the vsir_program for SM1. 2024-09-11 15:06:09 +02:00
Elizabeth Figura
f6a8cdf2bb vkd3d-shader: Do not use \ref for parameters. 2024-09-11 14:55:48 +02:00
Elizabeth Figura
304724608a vkd3d-shader: Escape a hash in Doxygen documentation. 2024-09-11 14:55:48 +02:00
Elizabeth Figura
4683186166 vkd3d-shader: Mention the structure name when referring to a struct field. 2024-09-11 14:55:48 +02:00
Elizabeth Figura
9fbf646748 build: Do not warn on incomplete documentation.
Some functions in vkd3d_utils.h are altered versions of Windows
functions, and only the vkd3d-specific parts need documentation.
2024-09-11 14:55:30 +02:00
Anna (navi) Figueiredo Gomes
127ae6cf12 vkd3d: Implement d3d12_command_list_OMSetDepthBounds().
Based on the design document, "The runtime will not clamp or validate
the input, but implementations may clamp to the range [0,1] if necessary.",
so we test for the EXT_depth_range_unrestricted extension, and only clamp if
it's not available (thus, necessary to do so).

NaNs are converted to zero as per "NaNs must be treated as 0, but the runtime
will convert NaNs to 0 on behalf of the implementation.", and a default bounds
are set to 0.0 and 1.0.
2024-09-11 14:53:33 +02:00
Anna (navi) Figueiredo Gomes
61a700bcdc tests: Test depth bounds. 2024-09-11 14:53:33 +02:00
Anna (navi) Figueiredo Gomes
e761b2cad1 tests/shader_runner: Introduce a "d3d12" tag. 2024-09-11 14:53:33 +02:00
Anna (navi) Figueiredo Gomes
3eb2a3d0e4 tests/shader_runner: Introduce a 'depth-bounds' test option. 2024-09-11 14:53:21 +02:00
Anna (navi) Figueiredo Gomes
12a7cde092 tests/shader_runner: Use ID3D12Device2_CreatePipelineState() when available. 2024-09-11 14:13:59 +02:00
Anna (navi) Figueiredo Gomes
04d7ad90e5 tests/shader_runner: Extract a pipeline creation function from d3d12_runner_draw(). 2024-09-11 14:08:37 +02:00
Nikolay Sivov
3b4e0ce8e9 vkd3d-shader/fx: Check modifiers when reusing types.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-10 21:48:03 +02:00
Giovanni Mascellani
d71966c77e vkd3d: Do not keep track of descriptor heaps when using virtual heaps.
Descriptors only need flushing when using Vulkan heaps, so let's avoid
uselessly scanning an array and taking and releasing a mutex if we're not.
2024-09-10 21:47:38 +02:00
Giovanni Mascellani
05a5bd620d vkd3d: Directly call the function to update descriptors.
For better code clarity.
2024-09-10 21:46:46 +02:00
Conor McCarthy
e550901efa vkd3d-shader/ir: Free the semantic names of deleted signature elements in shader_signature_merge(). (Valgrind) 2024-09-10 21:45:22 +02:00
Giovanni Mascellani
828dfdf1bd vkd3d-shader/ir: Run validation after normalising flat constants. 2024-09-10 21:43:14 +02:00
Giovanni Mascellani
1c285d40bd vkd3d-shader/ir: Run validation after normalising I/O registers. 2024-09-10 21:43:14 +02:00
Giovanni Mascellani
d8c41cc270 vkd3d-shader/ir: Run validation after normalising Hull Shader control points I/O registers. 2024-09-10 21:43:14 +02:00
Giovanni Mascellani
a3fdc447de vkd3d-shader/ir: Run validation after flattening hull shader phases. 2024-09-10 21:43:14 +02:00
Giovanni Mascellani
5fd93c28c4 vkd3d-shader/ir: Run validation after remapping the output signature. 2024-09-10 21:43:14 +02:00
Anna (navi) Figueiredo Gomes
5ebbba6fff vkd3d/state: Replace ERR with WARN in vkd3d_validate_descriptor_set_count(). 2024-09-10 21:42:47 +02:00
Henri Verbeet
207664baca vkd3d-shader/d3dbc: Use VKD3D_SM1_REGISTER_TYPE_SHIFT and related constants in sm1_encode_register_type(). 2024-09-10 21:42:23 +02:00
Henri Verbeet
f163df787e vkd3d-shader/d3dbc: Avoid D3DVS_VERSION and D3DPS_VERSION. 2024-09-10 21:41:33 +02:00
Nikolay Sivov
de6abd964e vkd3d-shader/hlsl: Implement the mad() intrinsic.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-10 21:40:32 +02:00
Nikolay Sivov
75299c04fd vkd3d-shader: Handle the SV_SampleIndex semantic.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-10 21:39:03 +02:00
Giovanni Mascellani
bfd1fc9cd6 vkd3d-shader/ir: Assume that Hull Shaders have a control point phase in vsir_program_normalise_io_registers().
The control point phase is always introduced, when missing, by the
earlier instruction_array_normalise_hull_shader_control_point_io()
pass.
2024-09-05 16:33:05 +02:00
Giovanni Mascellani
7b9a1bf6df vkd3d-shader/ir: Run validation after materializing undominated SSAs to TEMPs. 2024-09-05 16:29:47 +02:00
Giovanni Mascellani
08c1f4d45e vkd3d-shader/ir: Run validation after flattening control flow constructs. 2024-09-05 16:29:17 +02:00
Giovanni Mascellani
455c826a6a vkd3d-shader/ir: Run validation after structurization. 2024-09-05 16:29:11 +02:00
Giovanni Mascellani
e935dcb88d vkd3d-shader/ir: Run validation after lowering switches to selection ladders. 2024-09-05 16:29:02 +02:00
Giovanni Mascellani
4a28433ef5 vkd3d-shader/ir: Run validation after materializing PHI SSAs to TEMPs. 2024-09-05 16:26:52 +02:00
Giovanni Mascellani
fade5dd54c vkd3d-shader/ir: Run validation after lowering instructions. 2024-09-05 16:25:33 +02:00
Giovanni Mascellani
ffb7284fb6 vkd3d-shader/ir: Do not decide the control flow type on NOPs. 2024-09-05 16:20:39 +02:00
Giovanni Mascellani
829e6f5cd0 vkd3d-shader/ir: Emit a warning instead of an error on validation failures. 2024-09-05 16:20:39 +02:00
Henri Verbeet
03d76f653b vkd3d-shader/d3dbc: Use VKD3D_SM1_INSTRUCTION_LENGTH_SHIFT instead of D3DSI_INSTLENGTH_SHIFT. 2024-09-05 12:47:43 +02:00
Henri Verbeet
b9693393fd vkd3d-shader/d3dbc: Store a enum vkd3d_sm1_opcode in struct sm1_instruction. 2024-09-05 12:45:43 +02:00
Nikolay Sivov
0a6bcf5da7 vkd3d-shader/tpf: Fix a typo when adding the SFI0 section.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-04 18:43:41 +02:00
Henri Verbeet
a214e96cf8 vkd3d-shader/tpf: Use enum vkd3d_sm4_data_type in sm4_resource_format(). 2024-09-04 18:42:26 +02:00
Henri Verbeet
b61675d0f3 vkd3d-shader/tpf: Use enum vkd3d_shader_component_type in write_sm4_signature(). 2024-09-04 18:40:56 +02:00
Shaun Ren
c1babbc8aa vkd3d-shader/hlsl: Validate hull shader attributes. 2024-09-04 18:30:04 +02:00
Shaun Ren
6c1dc53d15 vkd3d-shader/hlsl: Parse the patchconstantfunc attribute. 2024-09-04 18:30:04 +02:00
Shaun Ren
41cb29c4c8 vkd3d-shader/hlsl: Parse the partitioning attribute. 2024-09-04 18:28:59 +02:00
Shaun Ren
615ffb823b vkd3d-shader/hlsl: Parse the outputtopology attribute. 2024-09-04 18:28:57 +02:00
Shaun Ren
dae88bab52 vkd3d-shader/hlsl: Parse the outputcontrolpoints attribute. 2024-09-04 18:28:46 +02:00
Shaun Ren
4dfd682446 vkd3d-shader/hlsl: Parse the domain attribute. 2024-09-04 18:21:15 +02:00
Shaun Ren
51e9b05fe5 vkd3d-shader/hlsl: Introduce parse_entry_function_attributes() helper. 2024-09-04 18:18:23 +02:00
Shaun Ren
62fad1c185 tests: Test hull shader function overloads. 2024-09-04 18:18:23 +02:00
Shaun Ren
ed1e74dd62 tests: Test hull shader attributes. 2024-09-04 18:18:23 +02:00
Shaun Ren
73ee5a135a vkd3d-shader/hlsl: Check for duplicate attributes in function declaration. 2024-09-04 18:18:23 +02:00
Petrichor Park
855b9713b8 vkd3d-shader/hlsl: Implement the sincos() intrinsic. 2024-09-04 18:16:37 +02:00
Petrichor Park
384810b4ba vkd3d-shader/hlsl: Implement the dst() intrinsic. 2024-09-04 18:08:24 +02:00
Francisco Casas
7ec44bd70b vkd3d-shader/hlsl: Parse the CompileShader() syntax. 2024-09-04 17:59:34 +02:00
Francisco Casas
45f18a7838 vkd3d-shader/hlsl: Parse the shader 'compile' syntax.
The hlsl_ir_compile node is introduced to represent the "compile"
syntax, and later the CompileShader() and ConstructGSWithSO()
constructs.

It basically represents a function call that remembers its arguments
using hlsl_srcs and keeps its own instruction block, which is discarded
when working on non-effect shaders.

For shader compilations it can be asserted that args_count is 1, and
that this argument (and the last node in hlsl_ir_effect_call.instrs)
is a regular hlsl_ir_call pointing to the declaration of the function
to be compiled.
2024-09-04 17:58:56 +02:00
Francisco Casas
379cd9b7b5 vkd3d-shader/hlsl: Save hlsl_ir_swizzles in the vsir_program for SM1. 2024-09-04 17:51:32 +02:00
Francisco Casas
b46eac35c0 vkd3d-shader/hlsl: Save hlsl_ir_stores in the vsir_program for SM1. 2024-09-04 17:51:32 +02:00
Francisco Casas
9aace1ac4e vkd3d-shader/hlsl: Save hlsl_ir_loads in the vsir_program for SM1. 2024-09-04 17:51:32 +02:00
Francisco Casas
23e3ec84f7 vkd3d-shader/hlsl: Save hlsl_ir_constants in the vsir_program for SM1. 2024-09-04 17:51:30 +02:00
Francisco Casas
a61846c28a vkd3d-shader/hlsl: Store SM1 sampler dcls on the vsir_program. 2024-09-04 17:47:47 +02:00
Francisco Casas
9a564872c5 vkd3d-shader/hlsl: Store SM1 constant dcls on the vsir_program. 2024-09-04 17:44:46 +02:00
Francisco Casas
7abf3c3a37 vkd3d-shader/hlsl: Introduce hlsl_ir_vsir_instruction_ref.
This node type will be deleted once the hlsl->vsir->d3dbc translation is
complete. For now it serves the purpose of allowing to keep both real
hlsl_ir_nodes and vsir_instructions in the hlsl_block, until all the
former can be translated into the latter.
2024-09-04 16:49:00 +02:00
Anna (navi) Figueiredo Gomes
3d8fc1a467 vkd3d-shader/spirv: Break long assembly lines.
Avoid overflowing the (Wine) debug log buffer when output lines are too
long, and keep spirv-text output more legible. The output is still valid
SPIR-V asm, as the assembler does not care for which kind of whitespace
is used.
2024-09-03 17:06:20 +02:00
Victor Chiletto
a39227c79c vkd3d-shader/hlsl: Fold logic AND and logic OR identities. 2024-09-03 15:11:16 +02:00
Elizabeth Figura
d507acb5ac vkd3d-utils: Do not emit implicit truncation warnings from D3DCompile2VKD3D() before version 42. 2024-09-03 15:07:36 +02:00
Elizabeth Figura
8515fcbc70 vkd3d-utils: Add a D3DCompile2VKD3D() that allows configuring DLL version.
This would allow us to use vkd3d-utils directly in Wine [with the exception of
D3D_COMPILE_STANDARD_FILE_INCLUDE, but we can simply pass the ID3DInclude object
to D3DCompile2VKD3D().]
2024-09-03 15:06:29 +02:00
Nikolay Sivov
6d28cc131b vkd3d-shader/fx: Fix the unpacked size and stride fields of the fx_4_0 types.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-02 19:14:59 +02:00
Nikolay Sivov
9673b660d4 vkd3d-shader/fx: Expand BlendState array fields for fx_4_1 as well.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-02 19:14:59 +02:00
Nikolay Sivov
1ed4543007 vkd3d-shader/fx: Only add numeric variables when writing buffers.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-02 19:14:59 +02:00
Nikolay Sivov
ee2da76e6d vkd3d-shader/fx: Set structure field offsets in bytes.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-02 19:14:59 +02:00
Henri Verbeet
7a74e79f2d vkd3d-shader/d3dbc: Return a vkd3d_decl_usage from hlsl_sm1_usage_from_semantic(). 2024-09-02 19:14:01 +02:00
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
Francisco Casas
f8108a4753 tests: Add additional string tests. 2024-08-13 21:16:46 +02:00
Nikolay Sivov
e0b5fe1288 vkd3d-shader/hlsl: Add a test for assigning to DSV and RTV variables.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-08-13 21:11:48 +02:00
Nikolay Sivov
b4d957f848 vkd3d-shader/hlsl: Handle NULL constants.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-08-13 21:10:45 +02:00
Nikolay Sivov
d945d5e78c vkd3d-shader/hlsl: Check MS texture declaration without sample count only for used variables.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-08-13 21:10:29 +02:00
Anna (navi) Figueiredo Gomes
80b2a2eb55 vkd3d-shader/ir: Periodically flush buffers when tracing blocks.
Avoids overflowing the output buffer for the trace in cases where the
output is too long, which raises an exception.
2024-08-12 14:19:13 +02:00
Nikolay Sivov
b0ca3627bf vkd3d-shader/fx: Turn assignments to arrays to element assignments for certain states. 2024-08-12 14:15:14 +02:00
Nikolay Sivov
25e1c3e374 vkd3d-shader/fx: Explicitly handle bool values in state entries. 2024-08-12 14:15:14 +02:00
Nikolay Sivov
c81223d086 vkd3d-shader/fx: Handle states of a BlendState object. 2024-08-12 14:15:14 +02:00
Nikolay Sivov
2affc8f5c5 vkd3d-shader/fx: Run full set of constants passes on state block entries values. 2024-08-12 14:15:14 +02:00
Nikolay Sivov
f1e65ecc83 vkd3d-shader/fx: Enable writing BlendState variables. 2024-08-12 14:15:14 +02:00
Nikolay Sivov
91e88fac2e vkd3d-shader/hlsl: Add parser support for BlendState type. 2024-08-12 14:15:14 +02:00
Nikolay Sivov
1be0d99b76 vkd3d-shader/fx: Check destination array index when checking for duplicate state entries. 2024-08-12 14:15:14 +02:00
Nikolay Sivov
b23874dad6 vkd3d-shader/hlsl: Add parser support for GeometryShader type.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-08-08 23:42:37 +02:00
Nikolay Sivov
de48960b33 vkd3d-shader/fx: Add support for the OMSetRenderTargets() state. 2024-08-08 23:42:37 +02:00
Nikolay Sivov
c565a60b9e vkd3d-shader/fx: Add an array size field to the states description table. 2024-08-08 23:42:37 +02:00
Nikolay Sivov
d55a709992 vkd3d-shader/fx: Use more descriptive names for FX-specific types. 2024-08-08 23:42:37 +02:00
Nikolay Sivov
9fb23b9090 vkd3d-shader/fx: Handle "Texture" field of the sampler state objects.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-08-08 23:42:37 +02:00
Giovanni Mascellani
8b6ab9627d vkd3d-shader: Replace assert() with VKD3D_ASSERT() in vkd3d_shader_private.h. 2024-08-08 23:39:23 +02:00
Giovanni Mascellani
27bceec965 vkd3d-shader: Replace assert() with VKD3D_ASSERT() in vkd3d_shader_main.c. 2024-08-08 23:39:23 +02:00
Giovanni Mascellani
0294aa62f3 vkd3d-shader: Replace assert() with VKD3D_ASSERT() in tpf.c. 2024-08-08 23:38:02 +02:00
Giovanni Mascellani
d5126b4d98 vkd3d-shader: Replace assert() with VKD3D_ASSERT() in spirv.c. 2024-08-08 23:36:23 +02:00
Victor Chiletto
8c3a5e5458 vkd3d-shader/hlsl: Implement f16tof32 intrinsic. 2024-08-08 23:35:02 +02:00
Victor Chiletto
693e89c74e vkd3d-shader/hlsl: Push a new scope when compiling internal functions.
This allows for typedef usage without interfering with user code.
Thanks Zeb for the suggestion.
2024-08-08 23:35:02 +02:00
Francisco Casas
016be7e591 vkd3d-shader/hlsl: Lower non-constant row_major matrix loads for SM1. 2024-08-08 23:33:33 +02:00
Francisco Casas
87f01f5205 vkd3d-shader/hlsl: Remove SM1 fixme for matrix writemasks.
hlsl_ir_store instructions don't use writemasks for whole matrices.
2024-08-08 23:32:03 +02:00
Francisco Casas
9f515a9daa vkd3d-shader/hlsl: Lower non-constant array loads for SM1.
This is achieved by means of creating a variable storing zero,
loading every array element, comparing if the non-constant index
matches the index of that element at runtime, and in that case
store the corresponding element in the variable.

This seems to be the same strategy that the native compiler uses.
2024-08-08 23:30:39 +02:00
Francisco Casas
e0cfd8f86a tests: Add additional non-constant array indexing tests. 2024-08-08 23:28:31 +02:00
Francisco Casas
eb2d320596 vkd3d-shader/hlsl: Avoid dereferencing rel_offset if it is NULL.
We are currently using &offset_node->loc when offset_node is NULL.

A NULL dereference of rel_offset can also happen if
hlsl_offset_from_deref() fails because the dereference is out of
bounds.
2024-08-08 23:28:31 +02:00
Francisco Casas
51abec8c99 tests: Introduce VKD3D_TEST_DETAILED for the test driver.
Useful to know which tests on which backends were skipped.
2024-08-07 15:54:36 +02:00
Francisco Casas
9dec7403d9 tests/shader-runner: Add missing trace for wave_ops caps. 2024-08-07 15:54:36 +02:00
Francisco Casas
2efc79bb81 tests: Report tests skipped because of missing capabilities. 2024-08-07 15:54:36 +02:00
Francisco Casas
84676c378f tests: Add missing double precission require directives.
Otherwise these tests fail on Intel UHD Graphics 770.
2024-08-07 15:54:36 +02:00
Francisco Casas
e8354ac499 vkd3d-shader/hlsl: Parse string type. 2024-08-07 15:53:07 +02:00
Francisco Casas
652db433e1 vkd3d-shader/hlsl: Parse string escape sequences. 2024-08-07 15:51:43 +02:00
Francisco Casas
090df488ba vkd3d-shader/hlsl: Parse string constants. 2024-08-07 15:48:59 +02:00
Francisco Casas
4b2e847d11 tests: Test string escape sequences. 2024-08-07 15:45:24 +02:00
Nikolay Sivov
c44a18b3d1 vkd3d-shader/fx: Add support for SetDomainShader(), SetComputeShader(), and SetHullShader() states.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-08-06 16:54:19 +02:00
Nikolay Sivov
1559237780 vkd3d-shader/fx: Fix state block entry array shifting when decomposing.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-08-06 16:54:19 +02:00
Nikolay Sivov
7c3677b114 vkd3d-shader/hlsl: Add parser support for ComputeShader, DomainShader, and HullShader types.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-08-06 16:54:19 +02:00
Nikolay Sivov
2cbad81b55 vkd3d-shader/fx: Handle SetRasterizerState().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-08-06 16:54:19 +02:00
Giovanni Mascellani
784e69a366 vkd3d: Check the entire root signature for register conflicts.
Not just each descriptor table individually.
2024-08-06 16:53:06 +02:00
Nikolay Sivov
a3f4785720 vkd3d-shader/fx: Decompose function-style state assignments to individual states.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-08-05 16:01:33 +02:00
Stefan Dösinger
d4c2a7f22b vkd3d: Pass a proper struct shader_cache_key * to rb_put() in vkd3d_shader_cache_add_entry(). 2024-08-05 15:59:53 +02:00
Giovanni Mascellani
46aec9fba8 vkd3d-shader: Replace assert() with VKD3D_ASSERT() in preproc.y. 2024-08-05 15:57:56 +02:00
Giovanni Mascellani
625327653b vkd3d-shader: Replace assert() with VKD3D_ASSERT() in preproc.l. 2024-08-05 15:57:56 +02:00
Giovanni Mascellani
351220f182 vkd3d-shader: Replace assert() with VKD3D_ASSERT() in preproc.h. 2024-08-05 15:57:56 +02:00
Giovanni Mascellani
4a04324ecc vkd3d-shader: Replace assert() with VKD3D_ASSERT() in ir.c. 2024-08-05 15:57:56 +02:00
Giovanni Mascellani
5e1ae5aaa3 vkd3d-shader: Replace assert() with VKD3D_ASSERT() in hlsl.y. 2024-08-05 15:57:56 +02:00
Giovanni Mascellani
97a7ec8914 vkd3d-shader: Replace assert() with VKD3D_ASSERT() in hlsl.h. 2024-08-05 15:57:56 +02:00
Conor McCarthy
969cae8b67 vkd3d: Add support for the ID3D12CommandList6 interface. 2024-08-05 15:56:09 +02:00
Giovanni Mascellani
9ff5b2ce7a vkd3d-shader: Replace assert() with VKD3D_ASSERT() in hlsl.c. 2024-08-01 15:18:15 +02:00
Giovanni Mascellani
4e7d0faaf0 vkd3d-shader: Replace assert() with VKD3D_ASSERT() in hlsl_constant_ops.c. 2024-08-01 15:18:15 +02:00
Giovanni Mascellani
eff30577af vkd3d-shader: Replace assert() with VKD3D_ASSERT() in hlsl_codegen.c. 2024-08-01 15:18:15 +02:00
Giovanni Mascellani
02ef731b9a vkd3d-shader: Replace assert() with VKD3D_ASSERT() in fx.c. 2024-08-01 15:18:15 +02:00
Giovanni Mascellani
7d3e8f49e4 vkd3d-shader: Replace assert() with VKD3D_ASSERT() in dxil.c. 2024-08-01 15:18:15 +02:00
Francisco Casas
e6e82ad3f6 vkd3d-shader/hlsl: Add missing src1 and src2 constants to sincos on SM2.
The sincos instruction expects two specific constants on 2.0 and 2.1 profiles.

Consider the following shader:

    uniform float u;
    float4 main() : sv_target
    {
        return sin(u);
    }

On native, with ps_2_0, this compiles as:

    ps_2_0
    def c3, 0.159154937, 0.5, 6.28318548, -3.14159274
    def c1, -1.55009923e-006, -2.17013894e-005, 0.00260416674, 0.00026041668
    def c2, -0.020833334, -0.125, 1, 0.5
    mov r0.xy, c3
    mad r0.x, c0.x, r0.x, r0.y
    frc r0.x, r0.x
    mad r0.x, r0.x, c3.z, c3.w
    sincos r1.y, r0.x, c1, c2
    mov r0, r1.y
    mov oC0, r0

We are not emitting the src1 and src2 constant arguments before this
patch.
2024-07-31 22:22:38 +02:00
Giovanni Mascellani
9f4a568868 tests: Mark a couple of tests as working on recent NVIDIA GPUs.
I don't know the exact version that fixed this todo, but on the
same hardware this test was failing a couple of years ago, so
I presume something was fixed at some point. I am writing my
current driver version, but a lower one might turn out to be
sufficient.
2024-07-31 20:50:58 +02:00
Giovanni Mascellani
4094e5dbeb vkd3d-shader: Replace assert() with VKD3D_ASSERT() in dxbc.c. 2024-07-30 16:32:59 +02:00
Giovanni Mascellani
bcffcb4a29 vkd3d-shader: Replace assert() with VKD3D_ASSERT() in d3dbc.c 2024-07-30 16:32:59 +02:00
Giovanni Mascellani
8e08fa6bf2 vkd3d-shader: Replace assert() with VKD3D_ASSERT() in d3d_asm.c. 2024-07-30 16:32:59 +02:00
Giovanni Mascellani
5af138b247 vkd3d-shader: Replace assert() with VKD3D_ASSERT() in checksum.c. 2024-07-30 16:32:59 +02:00
Giovanni Mascellani
ba381497cc vkd3d-common: Remove an assertion in vkd3d_dbg_printf().
We want to get rid of assertions and only use the new VKD3D_ASSERT(),
but this cannot be done here, because a failing VKD3D_ASSERT() would
call back again to vkd3d_dbg_printf().

At the same time the asserted condition should be simple enough to
debug even without the assertion, since logging with a bad level
will likely result in either a crash or writing garbage to the log.
2024-07-30 16:32:59 +02:00
Atharva Nimbalkar
2170fdc633 vkd3d-shader/glsl: Implement support for VKD3DSPR_TEMP registers. 2024-07-30 16:31:59 +02:00
Atharva Nimbalkar
337a030908 vkd3d-shader/glsl: Implement VKD3DSIH_MOV. 2024-07-30 16:31:59 +02:00
Henri Verbeet
c7589d8f19 vkd3d-shader/ir: Remove VKD3DSIH_DCL_SAMPLER instructions. 2024-07-30 16:31:44 +02:00
Henri Verbeet
fffe521b80 vkd3d-shader/ir: Remove VKD3DSIH_DCL instructions. 2024-07-30 16:31:44 +02:00
Giovanni Mascellani
240d31c793 vkd3d: Replace assert() with VKD3D_ASSERT() in vkd3d_private.h. 2024-07-29 19:12:13 +02:00
Giovanni Mascellani
529647142c vkd3d: Replace assert() with VKD3D_ASSERT() in utils.c. 2024-07-29 19:12:13 +02:00
Giovanni Mascellani
bd75396b38 vkd3d: Replace assert() with VKD3D_ASSERT() in state.c. 2024-07-29 19:12:13 +02:00
Giovanni Mascellani
02b898bec0 vkd3d: Replace assert() with VKD3D_ASSERT() in resource.c. 2024-07-29 19:12:13 +02:00
Giovanni Mascellani
150bf69da9 vkd3d: Replace assert() with VKD3D_ASSERT() in command.c. 2024-07-29 19:12:13 +02:00
Giovanni Mascellani
507cc2976f tests: Test register conflicts in a root signature. 2024-07-29 13:19:10 +02:00
Giovanni Mascellani
51b65688e1 ci: Abort on assertions on the CI. 2024-07-29 13:17:19 +02:00
Giovanni Mascellani
fb55c2b227 vkd3d: Emit an ERR() when reaching unreachable code.
This way the ERR() configuration is reused for unreachable code.
2024-07-29 13:17:19 +02:00
Giovanni Mascellani
4ada72a397 vkd3d: Allow aborting on ERR(). 2024-07-29 13:17:19 +02:00
Giovanni Mascellani
d7fc2693c4 vkd3d: Introduce a softer form of assertion.
Triggering an ERR() instead of aborting the program.
2024-07-29 13:17:19 +02:00
Giovanni Mascellani
a484063cd2 vkd3d: Introduce debug severity MESSAGE.
That's intended for messages that it's pretty important that the
user receives, but that are not proper error messages.
2024-07-29 13:17:19 +02:00
Giovanni Mascellani
021a7f030a vkd3d: Allow disabling ERR() by defining VKD3D_NO_ERROR_MESSAGES. 2024-07-29 13:17:19 +02:00
Giovanni Mascellani
60ecf8c12b vkd3d: Disable FIXME_ONCE() when VKD3D_NO_DEBUG_MESSAGES is defined.
Similarly to FIXME().
2024-07-29 13:17:19 +02:00
Giovanni Mascellani
4c1cc6101f vkd3d: Disable WARN_ON() when VKD3D_NO_DEBUG_MESSAGES is defined.
Similarly to WARN().
2024-07-29 13:17:19 +02:00
Elizabeth Figura
947b937a1a tests: Test shade mode. 2024-07-24 16:08:10 +02:00
Elizabeth Figura
ae5cd6573f vkd3d-shader: Allow controlling d3d color shade mode through vkd3d-shader parameters. 2024-07-24 16:08:10 +02:00
Elizabeth Figura
d20d0fc69f vkd3d-shader: Use the program parameters in spirv_compiler_alloc_spec_constant_id(). 2024-07-24 16:07:13 +02:00
Victor Chiletto
a0de05f0b4 vkd3d-shader/hlsl: Implement the asint() intrinsic. 2024-07-24 16:06:03 +02:00
Nikolay Sivov
91dce79227 vkd3d-shader/fx: Correct one of the object counters in the fx_2_0 header.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-07-24 16:04:21 +02:00
Elizabeth Figura
97cd941710 vkd3d-shader: Do not make the alpha test ref parameter VSIR_DIMENSION_VEC4. 2024-07-23 21:12:28 +02:00
Elizabeth Figura
1db7c03185 vkd3d-shader/spirv: Pass a vkd3d_data_type to spirv_compiler_emit_shader_parameter(). 2024-07-23 21:11:15 +02:00
Elizabeth Figura
f6dd6d52b3 vkd3d-shader: Factor out a vsir_program_get_parameter() helper. 2024-07-23 21:10:00 +02:00
Elizabeth Figura
6b58b6f261 vkd3d-shader/spirv: Allocate output_info after normalization.
Normalization may change the signatures.
2024-07-23 21:09:00 +02:00
Shaun Ren
49caeee1fd vkd3d-shader/hlsl: Support default values for function parameters. 2024-07-23 15:36:32 +02:00
Nikolay Sivov
29699d3d22 vkd3d-shader/fx: Set total pass count for fx_2_0.
Binaries with that field set incorrectly fail to load on Windows.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-07-23 15:23:54 +02:00
Nikolay Sivov
dcf4ce753b vkd3d-shader/fx: Correct empty pass check.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-07-23 15:23:54 +02:00
Nikolay Sivov
958117df2f vkd3d-shader/hlsl: Allow annotations on global variables.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-07-23 15:23:54 +02:00
Giovanni Mascellani
ba0fec4c51 vkd3d: Propagate errors out of d3d12_root_signature_append_vk_binding(). 2024-07-22 16:01:37 +02:00
Giovanni Mascellani
4b7fe26b33 vkd3d: Remove the temporary pointers in vkd3d_physical_device_info_init().
They were rather pointless now.
2024-07-22 16:00:28 +02:00
Giovanni Mascellani
75c64e55cd vkd3d: Rebuild the vkd3d_physical_device_info chain before creating the device.
vkd3d might decide to disable some extensions after the chain is created,
so the chain must be recreated with only the structures corresponding to
enabled extensions.
2024-07-22 16:00:28 +02:00
Giovanni Mascellani
7eb63a7c0d vkd3d: Document how to install "Graphics Tools" to use the Agility SDK.
This is a required step, otherwise the debug layer will not work.
2024-07-17 15:54:31 +02:00
Giovanni Mascellani
7e557420b1 tests: Terminate the Agility SDK path with a slash.
That's what the documentation recommends. It used to work for me without
the slash, but maybe they changed something in recent versions.
2024-07-17 15:54:31 +02:00
Giovanni Mascellani
e4e7368c1c tests: Pad the constant buffer in test_update_compute_descriptor_tables() to 256 bytes.
The D3D12 debug layer signals an error otherwise.
2024-07-17 15:53:31 +02:00
Giovanni Mascellani
a876e0b192 vkd3d: Allocate temporary arrays on the stack in d3d12_command_list_update_push_descriptors(). 2024-07-17 15:52:37 +02:00
Conor McCarthy
ae0faf4500 vkd3d: Limit the workgroup X count for buffer UAV clears to the supported max. 2024-07-17 15:51:39 +02:00
Conor McCarthy
3e25356abb tests: Add a test for clearing a large buffer UAV.
Large buffers can exceed the maximum workgroup X count.
2024-07-17 15:51:39 +02:00
Conor McCarthy
15f8657d74 vkd3d: Create a descriptor pool for static samplers when Vulkan-backed heaps are used.
Static samplers may be allocated from these pools.
2024-07-17 15:50:24 +02:00
Shaun Ren
0202393d41 vkd3d-shader/d3dbc: Implement HLSL_OP1_{COS,SIN}_REDUCED for SM1.
Also enable SM1 trigonometry function tests.
2024-07-16 19:03:52 +02:00
Shaun Ren
ea2ffc0b6c vkd3d-shader/hlsl: Allocate registers for HLSL_OP1_{COS,SIN}_REDUCED with the required writemasks. 2024-07-16 19:02:01 +02:00
Shaun Ren
8724cbe5d5 vkd3d-shader/d3dbc: Implement HLSL_OP3_MAD for SM1. 2024-07-16 18:56:44 +02:00
Shaun Ren
b4845b9dca vkd3d-shader/hlsl: Implement sin/cos for SM1.
Also introduce HLSL_OP3_MAD.
2024-07-16 18:55:22 +02:00
Shaun Ren
b3a11a9ec4 vkd3d-shader/ir: Lower SM1 SINCOS to SM4 SINCOS. 2024-07-16 15:24:58 +02:00
Elizabeth Figura
5a53b73995 tests: Test alpha test. 2024-07-11 17:02:53 +02:00
Elizabeth Figura
7e868f1f4b tests: Factor out a set_default_target() helper. 2024-07-11 17:02:45 +02:00
Elizabeth Figura
ded0733ff8 tests: Offset the viewport by 0.5 when running d3dbc shaders. 2024-07-11 17:02:40 +02:00
Elizabeth Figura
806363b765 vkd3d-shader: Allow controlling alpha test through vkd3d-shader parameters. 2024-07-11 17:02:11 +02:00
Elizabeth Figura
c2ce15b623 vkd3d-shader/spirv: Respect VKD3D_SHADER_CONDITIONAL_OP_Z when discard has a bool argument. 2024-07-11 16:59:06 +02:00
Elizabeth Figura
9e59e57cb3 tests: Add a test for the vkd3d_shader_parameter APIs. 2024-07-11 16:58:56 +02:00
Elizabeth Figura
e8bdac8147 vkd3d-shader/spirv: Support passing shader parameters through uniform buffers. 2024-07-11 16:58:52 +02:00
Elizabeth Figura
3dff608bf8 include: Document shader parameters. 2024-07-11 16:48:09 +02:00
Elizabeth Figura
98def3214b vkd3d-shader: Introduce struct vkd3d_shader_parameter_info and struct vkd3d_shader_parameter1.
As the newly added documentation describes, this reroll serves two purposes:

* to allow shader parameters to be used for any target type (which allows using
  parameters for things like Direct3D 8-9 alpha test),

* to allow the union in struct vkd3d_shader_parameter to contain types larger
  than 32 bits (by specifying them indirectly through a pointer).
2024-07-11 16:48:09 +02:00
Petrichor Park
bec4f413dc vkd3d-shader/tpf: Implmenent HLSL_OP1_RCP.
SM5 comes with a RCP opcode; for SM4, implement it as `DIV dst, 1, x`.
2024-07-11 16:44:16 +02:00
Petrichor Park
b3f0cd5788 vkd3d-shader/hlsl: Implement the rcp() intrinisic.
SM1 already has the RCP opcode implemented; SM4 implementation is in the
next commit.
2024-07-11 16:44:02 +02:00
Petrichor Park
3a49852075 vkd3d-shader/hlsl: Implement tests for the rcp() intrinsic. 2024-07-11 16:43:48 +02:00
Nikolay Sivov
c792114a6a vkd3d-shader/fx: Do not output empty strings for missing semantics for fx_2_0.
This is directly visible in parameter description. For a parameter without semantic
it should return null, instead of a pointer to an empty string.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-07-11 00:36:05 +02:00
Giovanni Mascellani
85fe4c421b tests: Define WIDL macros in utils.h.
This way other headers including utils.h, like d3d12_test_utils.h,
are self-contained.
2024-07-11 00:34:58 +02:00
Giovanni Mascellani
9ebf779ef0 vkd3d: Propagate a failure in d3d12_descriptor_heap_init(). 2024-07-11 00:34:58 +02:00
Elizabeth Figura
59f770214a vkd3d-shader/hlsl: Implement output SV_Coverage. 2024-07-11 00:33:57 +02:00
Elizabeth Figura
71a3d55e8c vkd3d-shader/hlsl: Implement the GetRenderTargetSampleCount() intrinsic. 2024-07-11 00:33:57 +02:00
Elizabeth Figura
a5a75d45d3 tests: Implement multisampling in the GL renderer. 2024-07-11 00:33:57 +02:00
Elizabeth Figura
737967604e tests: Implement multisampling in the Vulkan renderer. 2024-07-11 00:33:57 +02:00
Elizabeth Figura
fe21318b5f tests/shader_runner: Factor out a resource_desc structure. 2024-07-11 00:33:57 +02:00
Elizabeth Figura
fa570ee1f3 tests/shader_runner: Use resource->width instead of resource->size for buffer width. 2024-07-11 00:33:57 +02:00
Victor Chiletto
76ae871f5b tests/hlsl: Test loop unrolling edge cases. 2024-07-11 00:32:53 +02:00
Victor Chiletto
2034a8bab9 vkd3d-shader/hlsl: Implement loop unrolling.
Based on a patch by Nikolay Sivov.

Co-authored-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-07-11 00:32:53 +02:00
Victor Chiletto
7edd7dcf79 vkd3d-shader/hlsl: Allow cloned blocks to contain external references. 2024-07-11 00:32:53 +02:00
Victor Chiletto
5bc56d43bb vkd3d-shader/hlsl: Parse loop and unroll loop attributes.
Based on a patch by Nikolay Sivov.

Co-authored-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-07-11 00:32:53 +02:00
Victor Chiletto
323f53bd7d vkd3d-shader/hlsl: Pull evaluate_static_expression_as_uint() upwards. 2024-07-11 00:32:53 +02:00
Victor Chiletto
50e28f70ed vkd3d-shader/hlsl: Defer bounds checks to after copy propagation.
We potentially generate OOB accesses during loop unrolling that are later deleted.
2024-07-11 00:32:53 +02:00
Victor Chiletto
317bd46efd vkd3d-shader/hlsl: Use a switch in validate_static_object_references(). 2024-07-11 00:32:49 +02:00
Victor Chiletto
900433e371 tests/hlsl: Add a test for dynamically indexed multisampled texture loads. 2024-07-11 00:31:06 +02:00
Victor Chiletto
67c690aa07 vkd3d-shader/d3dbc: Fix implicit enum conversion warning.
This slipped through and broke CI.
2024-07-10 00:06:14 +02:00
Petrichor Park
746222b349 vkd3d-shader/hlsl: Implement the faceforward() intrinsic. 2024-07-09 20:43:41 +02:00
Francisco Casas
60c8a813a3 vkd3d-shader/hlsl: Validate state block function calls. 2024-07-09 20:38:08 +02:00
Francisco Casas
af7c4010f4 tests: Test whether valid state block function names are case-sensitive. 2024-07-09 20:37:20 +02:00
Francisco Casas
b5f2e7daeb vkd3d-shader/hlsl: Parse function call syntax on state blocks. 2024-07-09 20:36:28 +02:00
Francisco Casas
f15d8dc9e9 tests: Separate the valid stateblock function names test from the string arg test.
This test is important because it checks that all the valid names for
stateblock functions with the expected amount of arguments are tested,
but, after parsing state block function calls, the only reason it is
not passing is that we don't parse strings yet.
2024-07-09 20:34:17 +02:00
Francisco Casas
7bd53cf6d9 vkd3d-shader/hlsl: Free array sizes on function parameters (Valgrind). 2024-07-09 20:32:25 +02:00
Francisco Casas
b92baa40ec vkd3d-shader/d3dbc: Don't write inconsequential MOVs.
CASTs from floats to integers are implemented as mere MOVs. These often,
but not always, end up moving the value from one register to the same
register.

This patch avoids writing the MOV instructions if they have no effect.
2024-07-09 20:32:25 +02:00
Francisco Casas
daa13934a4 vkd3d-shader/d3dbc: Use vsir_program I/O signatures to write dcls.
Instead of relying on ctx->extern vars, semantics are now stored in the
vsir_program signatures, and then read to write the declarations.
2024-07-09 20:31:14 +02:00
Francisco Casas
704ce03561 vkd3d-shader/d3dbc: Don't require a hlsl_semantic to get register and usage. 2024-07-09 20:12:47 +02:00
Francisco Casas
003f4c7600 vkd3d-shader/d3dbc: Use program->shader_version instead of ctx->profile. 2024-07-09 20:06:23 +02:00
Francisco Casas
a333090288 vkd3d-shader/d3dbc: Introduce struct d3dbc_compiler. 2024-07-09 19:44:03 +02:00
Francisco Casas
dd8aa2ec91 vkd3d-shader/hlsl: Generate CTAB outside d3dbc_compile().
There is no way to store this information from the vsir_program alone,
so we make d3dbc_compile() expect the CTAB blob.
2024-07-09 18:59:54 +02:00
Francisco Casas
130b3335cb vkd3d-shader/d3dbc: Split hlsl_sm1_write().
The idea is to start splitting the

    HLSL IR -> d3dbc

translation into

    HLSL IR -> vsir -> d3dbc

So hlsl_sm1_write is split into two functions, sm1_generate_vsir()
which should handle the first part and d3dbc_compile() which should
handle the second part.

This translation should be completed once the hlsl_ctx and entry_func
are no longer used in d3dbc_compile().
2024-07-09 18:38:00 +02:00
Zebediah Figura
6db2bc3eff vkd3d-shader/d3dbc: Use enum vkd3d_shader_register_type in struct sm1_instruction. 2024-07-09 16:59:02 +02:00
Giovanni Mascellani
4f67675a51 tests: Support using the Agility SDK in the crosstests. 2024-07-09 16:57:03 +02:00
Giovanni Mascellani
c49daadce1 tests: Enable the d3d12 debug layer message callbacks. 2024-07-09 15:24:18 +02:00
Giovanni Mascellani
e3ddb76a3e tests: Improve feedback when enabling d3d12 debug layers. 2024-07-09 14:55:55 +02:00
Nikolay Sivov
3dc43e8945 vkd3d-shader: Disallow object structure fields for fx profiles.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-07-08 18:49:28 +02:00
Nikolay Sivov
c8720f1229 tests: Add some fx profiles tests for structure types containing objects.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-07-08 18:49:28 +02:00
Giovanni Mascellani
7958babb39 vkd3d: Do not synchronize with the tessellation shader stages if they're not enabled.
Similarly to a54187f3c9, this fixes some validation
errors on devices that do not support tessellation; the Adreno 540 on my OnePlus 5
phone in my specific case.
2024-07-08 18:49:28 +02:00
Giovanni Mascellani
3ff8130566 tests: Check that depth/stencil formats are supported before using them.
This fixes a crash with the Qualcomm proprietary driver on an Adreno 540
GPU on my OnePlus 5 phone.
2024-07-08 18:49:28 +02:00
Giovanni Mascellani
9f056f3989 tests: Transition resources to PIXEL_SHADER_RESOURCE in test_sample_c_lz(). 2024-07-08 18:49:28 +02:00
Giovanni Mascellani
fe787cf77f tests: Skip sampling cube textures on Qualcomm.
They seem to always crash on the Adreno 540 on my OnePlus 5 phone with the
Qualcomm proprietary driver.
2024-07-08 18:49:28 +02:00
Nikolay Sivov
937a80ead6 vkd3d-shader/fx: Write annotations for fx_4+ profiles.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-07-08 18:49:28 +02:00
Nikolay Sivov
0f7ac0a054 vkd3d-shader/hlsl: Set default values for annotations variables.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-07-08 18:49:06 +02:00
Nikolay Sivov
4d2ce385a7 vkd3d-shader/hlsl: Do not crash on initialization of a redefined variable.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-07-08 18:24:46 +02:00
Nikolay Sivov
0a344bd3c9 vkd3d-shader/fx: Add missing fields for structure types on fx_5_0.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-07-08 18:24:46 +02:00
Nikolay Sivov
8738e4662e vkd3d-shader/fx: Preserve parsing order of initializer components.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-07-08 18:24:46 +02:00
Nikolay Sivov
c97c652ff0 vkd3d-shader/fx: Fix packed size for fx_4+ types.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-07-08 18:24:46 +02:00
Nikolay Sivov
856686b2a2 vkd3d-shader/fx: Write default numeric values.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-07-08 18:24:46 +02:00
Nikolay Sivov
aea36be94c vkd3d-shader/fx: Fix structure type data written for fx_4.
Strings and field types are written to the same unstructured area
as structure type itself, so it has to be done in two passes.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-07-08 18:24:46 +02:00
Nikolay Sivov
2176294df8 vkd3d-shader/hlsl: Implement tex*grad() functions.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-07-08 18:23:38 +02:00
Nikolay Sivov
4ff288bd32 vkd3d-shader: Implement tex*() functions variants with gradient arguments.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-07-08 18:23:38 +02:00
Elizabeth Figura
4cd2dd50f9 vkd3d-shader/hlsl: Separate an "array" rule. 2024-07-08 18:22:39 +02:00
Nikolay Sivov
94130c2394 vkd3d-shader/fx: Add support for writing RasterizerState objects.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-07-08 18:12:03 +02:00
Nikolay Sivov
f03cb7e911 vkd3d-shader/hlsl: Add RasterizerState type.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-07-08 18:12:03 +02:00
Nikolay Sivov
12947aa50d vkd3d-shader/fx: Add support for writing DepthStencilState objects.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-07-08 18:12:03 +02:00
Nikolay Sivov
1008c49ce6 vkd3d-shader/fx: Cast state block field values to target type.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-07-08 18:12:03 +02:00
Francisco Casas
597e55691a vkd3d-shader/hlsl: Only error out on bind_count register reservation overlaps for SM1.
While on SM1 a register reservation reserves the whole size in
registers of the variable's data type, overlapping conflicts are only
checked up to the bind_count (used size) for each variable.
2024-07-08 18:12:03 +02:00
Francisco Casas
2179c79c91 tests: Test register reservations on unused variables. 2024-07-08 18:12:03 +02:00
Nikolay Sivov
48ff7de8ef vkd3d-shader/hlsl: Add support for ConstantBuffer<> type.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-07-08 18:12:03 +02:00
Victor Chiletto
44725a651b tests: Add reflection tests for register expressions. 2024-07-03 17:09:16 -03:00
Victor Chiletto
abbcf0461f vkd3d-shader/hlsl: Reserve register slots for unused buffers. 2024-07-03 17:09:16 -03:00
Victor Chiletto
da36a447b8 vkd3d-shader/hlsl: Validate cbuffer register allocations. 2024-07-03 17:09:16 -03:00
Victor Chiletto
27414ef928 vkd3d-shader/hlsl: Do not immediately fail parsing for malformed 'b' register reservations.
This is a fxc quirk. In most cases, this throws an error, but for global
variables it's completely ignored.
2024-07-03 17:09:16 -03:00
Victor Chiletto
b5b3c8b9ff vkd3d-shader/hlsl: Ignore bracket offsets for 'b' register types prior to SM 5.1.
This is a fxc quirk that was fixed for SM >= 5.1 only.
2024-07-03 14:34:45 -03:00
Victor Chiletto
8fb3b604bf vkd3d-shader/hlsl: Pass a pointer to struct hlsl_reg_reservation in parse_reservation_index.
Instead of passing the struct components individually.
2024-07-03 14:05:58 -03:00
Victor Chiletto
e13eb64d4c vkd3d-shader/hlsl: Support expressions as register offsets. 2024-07-03 14:05:58 -03:00
Victor Chiletto
d11c777092 tests: Add more register reservations tests. 2024-07-03 14:05:58 -03:00
Yuxuan Shui
ccb6150aab vkd3d-shader/hlsl: Implement storing to a swizzled matrix. 2024-06-20 12:39:46 +02:00
Elizabeth Figura
acc9d79fbb vkd3d-shader/hlsl: Only allocate the aligned size for uniforms. 2024-06-18 13:19:44 -05:00
Elizabeth Figura
7fe581203b vkd3d-shader/hlsl: Respect the coords writemask in write_sm1_resource_load().
Spotted by Francisco Casas.
2024-06-18 13:19:44 -05:00
Elizabeth Figura
8d946f3c20 tests: Add another combined sampler test.
Shader provided by Francisco Casas.
2024-06-18 13:01:31 -05:00
Elizabeth Figura
669e85171e tests: Run combined-samplers.shader_test on sm1 as well.
Now that we have if() this is easier.
2024-06-18 13:00:59 -05:00
Giovanni Mascellani
46a1b66df7 ci: Assume an Apple Silicon-based environment for the macOS CI job.
The previous Intel-based macOS runner was replaced with another one
running as a virtual machine on top of an Apple Silicon host.

Since the current macOS runner is not yet able to deal with
different exit codes, we temporarily allow failure unconditionally.
This will be reverted as soon as the runner issue is fixed.
2024-06-17 12:32:33 +02:00
Elizabeth Figura
d3ba810c98 tests: Stop probing all pixels when drawing a uniform colour.
This is simply unnecessary and wastes time.

As part of this, simply remove the "all" directive. Only for a couple of tests
is it even potentially interesting to validate all pixels (e.g.
nointerpolation.shader_test), and for those "all" is replaced with an explicit
(0, 0, 640, 480) rect.

In all other cases we just probe (0, 0).
2024-06-13 23:55:31 +02:00
Stefan Dösinger
021eb28584 include: Get rid of the RB_FOR_EACH* macros.
They're largely unused, and RB_FOR_EACH_ENTRY_DESTRUCTOR is broken
because it uses WINE_RB_ENTRY_VALUE which doesn't exist in vkd3d.
2024-06-13 23:44:43 +02:00
Henri Verbeet
90f26759b5 vkd3d: Always use UINT views to clear UAVs with integer formats.
We would previously try to use float pipelines for SINT formats.
2024-06-13 23:26:35 +02:00
Giovanni Mascellani
a54187f3c9 vkd3d: Do not synchronize with the geometry shader stage if it's not enabled. 2024-06-13 23:24:22 +02:00
Giovanni Mascellani
a1a07de8ca vkd3d: Enable VK_KHR_portability_subset if available.
We don't check it, but at least the validation layer does not complain
when using MoltenVK.
2024-06-13 23:24:22 +02:00
Giovanni Mascellani
3254eff328 vkd3d: Do not request VK_EXT_debug_marker if debug is disabled.
Because it requires VK_EXT_debug_report.
2024-06-13 23:24:22 +02:00
Giovanni Mascellani
3ad4d984ad tests: Mark some root signature unbounded range failures as todo on MoltenVK. 2024-06-13 23:24:22 +02:00
Yuxuan Shui
8a459f5903 tests: Pass the correct buffer size to vsnprintf() in vkd3d_test_push_context(). 2024-06-12 19:04:22 +02:00
Nikolay Sivov
222c52380b vkd3d-shader/fx: Fix variable buffer offset value.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-06-12 19:02:20 +02:00
Nikolay Sivov
402dc94259 vkd3d-shader/fx: Set EXPLICIT_BIND_POINT flag for packoffset() reservations as well.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-06-12 19:02:20 +02:00
Conor McCarthy
da1d96f708 tests/shader-runner: Create a new runner object for the shader model 6 tests.
If cleaning up the old runner is not completed, descriptors for
destroyed resources may remain on the heap.
2024-06-11 15:56:43 +02:00
Conor McCarthy
7534b88a15 tests/shader-runner: Set the correct flag and format for raw UAVs. 2024-06-11 15:55:48 +02:00
Elizabeth Figura
2f88442d7d vkd3d-shader/hlsl: Always initialize $$ when parsing modifiers from an arbitrary string.
This avoids spurious errors like "row_major and column_major are mutually
exclusive" when an invalid modifier is used.

Fixes: cf7c05f431
2024-06-11 15:54:10 +02:00
Nikolay Sivov
72ddea6030 vkd3d-shader/fx: Use original full semantic name.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-06-11 15:53:19 +02:00
Nikolay Sivov
1124ea46ee vkd3d-shader/hlsl: Store original semantic name.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-06-11 15:53:19 +02:00
Conor McCarthy
47d077e5ce vkd3d: Interpret a null vertex buffer 'views' pointer as a null buffer. 2024-06-11 15:52:28 +02:00
Conor McCarthy
c3ea43b619 tests/d3d12: Test a null vertex buffer 'views' pointer on multiple slots. 2024-06-11 15:52:28 +02:00
Conor McCarthy
589ed1e358 vkd3d: Allow block compressed textures to have unaligned width and height. 2024-06-11 15:51:34 +02:00
Conor McCarthy
9244f2b536 tests/d3d12: Check for unaligned block texture support in test_create_committed_resource(). 2024-06-11 15:51:33 +02:00
Nikolay Sivov
ba18035260 vkd3d-shader/d3dbc: Write load instruction for tex2Dbias().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-06-11 15:50:34 +02:00
Nikolay Sivov
a289393fe7 vkd3d-shader/asm: Output 'bias' flag for 'texld'.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-06-11 15:50:34 +02:00
Nikolay Sivov
ccbe36fb8d vkd3d-shader/hlsl: Implement tex2Dbias().
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56701
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-06-11 15:50:34 +02:00
Elizabeth Figura
f0cd35b40d tests: Add reflection tests for register space. 2024-06-11 15:49:30 +02:00
Elizabeth Figura
33e5553158 vkd3d-shader/hlsl: Write SM5.1 binding reflection data. 2024-06-11 15:49:30 +02:00
Elizabeth Figura
bb41947fc6 vkd3d-shader: Write SM5.1 register spaces. 2024-06-11 15:49:30 +02:00
Elizabeth Figura
4355e6ca69 vkd3d-shader/hlsl: Allocate register spaces for objects. 2024-06-11 15:49:30 +02:00
Elizabeth Figura
7b61b0219e vkd3d-shader/hlsl: Allocate register spaces for constant buffers. 2024-06-11 15:49:30 +02:00
Elizabeth Figura
28a5e23814 vkd3d-shader: Write SM5.1 register indices.
Separate ID and index. Allocate IDs for all external resources (but ignore them
for shader models other than 5).
2024-06-11 15:49:30 +02:00
Elizabeth Figura
19a13740de vkd3d-shader/hlsl: Put constant buffers into the extern_resources struct.
Mostly to get the same sorting logic.
2024-06-11 15:49:30 +02:00
Elizabeth Figura
558320b52f vkd3d-shader/hlsl: Add a hlsl_fixme() for 5.1 resource arrays.
These are a bit trickier to handle, and need more tests.
2024-06-11 15:49:30 +02:00
Conor McCarthy
9b070edf01 vkd3d-shader/spirv: Implement the QUAD_READ_LANE_AT instruction. 2024-06-11 15:48:21 +02:00
Conor McCarthy
0b8b5b2d0f vkd3d-shader/dxil: Implement DX intrinsic QuadReadLaneAt. 2024-06-11 15:48:21 +02:00
Conor McCarthy
c298493e4f vkd3d-shader/spirv: Implement the QUAD_READ_ACROSS_* instructions. 2024-06-11 15:48:21 +02:00
Conor McCarthy
8a15642f45 vkd3d-shader/dxil: Implement DX intrinsic QuadOp. 2024-06-11 15:48:21 +02:00
Francisco Casas
f5bfa728eb vkd3d-shader/hlsl: Reorder default values for matrices for SM4.
Default value initializers behave differently than regular initializers
for matrices on SM4 profiles.

While regular initializers assign the rhs elements in reading-order
(completing one row at the time), default initializers assing the rhs
elements in Chinese reading-order (completing one column at the time).

So after lowering a default value to a constant, the index of the
component to which this default value is stored is computed to meet
this expectation. This can be done because the default values.

For reference, compiling this shader:

    row_major int2x3 m = {1, 2, 3, 4, 5, 6};

    float4 main() : sv_target
    {
        return float4(m[0][0], 99, 99, 99);
    }

gives the following buffer definition:

    // cbuffer $Globals
    // {
    //
    //   row_major int2x3 m;                // Offset:    0 Size:    28
    //      = 0x00000001 0x00000003 0x00000005 0x00000000
    //        0x00000002 0x00000004 0x00000006
    //
    // }

Given that the matrix is column-major, m's default value is actually
{{1, 3, 5}, {2, 4, 6}}, unlike the {{1, 2, 3}, {4, 5, 6}} one would
expect in a regular initializer.

SM1 profiles assign the elements in regular reading order.
2024-06-11 15:46:40 +02:00
Francisco Casas
ab01fedc5d vkd3d-shader/hlsl: Fix numeric register offset for matrix components. 2024-06-11 15:46:40 +02:00
Francisco Casas
ade3daa311 tests: Test matrix default value initializers. 2024-06-11 15:46:40 +02:00
Francisco Casas
affadf319c vkd3d-shader/d3dbc: Write default values for SM1. 2024-06-11 15:46:40 +02:00
Francisco Casas
253c994155 vkd3d-shader/tpf: Write default values for SM4. 2024-06-11 15:46:40 +02:00
Francisco Casas
b44a25ce19 tests: Test default values using reflection. 2024-06-11 15:46:40 +02:00
Francisco Casas
099a64aeb2 vkd3d-shader/hlsl: Initialize default values with braceless initializers.
It is hard to initialize default values on add_assignment() and calling
add_assignment() for initializers is not really necessary: the only
thing we need from it the implicit cast.
2024-06-11 15:46:40 +02:00
Francisco Casas
e8dbc36bd2 vkd3d-shader/hlsl: Record default values for uniforms and constant buffers. 2024-06-11 15:46:40 +02:00
Henri Verbeet
1fe7a6581b vkd3d-shader/ir: Rename the "handler_idx" field of struct vkd3d_shader_instruction to "opcode". 2024-05-30 19:57:01 +02:00
Nikolay Sivov
5265fbb789 vkd3d-shader/fx: Do not write shared buffers block when not compiling as a child effect.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-05-30 19:56:50 +02:00
Nikolay Sivov
727aacca18 tests: Add a few tests for the NULL value.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-05-30 19:56:44 +02:00
Nikolay Sivov
163aaf9729 tests: Add some basic tests for ConstantBuffer type.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-05-30 19:56:39 +02:00
Nikolay Sivov
ea177a7750 vkd3d-shader/hlsl: Handle "unsigned int" type.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-05-30 19:56:29 +02:00
366 changed files with 94863 additions and 22955 deletions

16
.editorconfig Normal file
View File

@@ -0,0 +1,16 @@
# https://editorconfig.org/
root = true
[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 4
tab_width = 8
trim_trailing_whitespace = true
max_line_length = 120
insert_final_newline = true
[Makefile*]
indent_style = tab
indent_size = 8

1370
ANNOUNCE

File diff suppressed because it is too large Load Diff

View File

@@ -3,6 +3,8 @@ Alexandre Julliard
Alistair Leslie-Hughes
Andrew Eikum
Andrey Gusev
Anna (navi) Figueiredo Gomes
Arkadiusz Hiler
Atharva Nimbalkar
Biswapriyo Nath
Brendan Shanks
@@ -14,6 +16,7 @@ Elizabeth Figura
Ethan Lee
Evan Tang
Fabian Maurer
Feifan He
Florian Weimer
Francisco Casas
Francois Gouget
@@ -33,8 +36,10 @@ Petrichor Park
Philip Rebohle
Rémi Bernon
Robin Kertels
Shaun Ren
Stefan Dösinger
Sven Hesse
Victor Chiletto
Vinson Lee
Yuxuan Shui
Zhiyi Zhang

View File

@@ -1,4 +1,4 @@
Copyright 2016-2024 the Vkd3d project authors (see the file AUTHORS for a
Copyright 2016-2025 the Vkd3d project authors (see the file AUTHORS for a
complete list)
Vkd3d is free software; you can redistribute it and/or modify it under

View File

@@ -1,3 +1,481 @@
# What's new in vkd3d 1.17 (21 August 2025)
### libvkd3d
- The EnumerateMetaCommands() method of the ID3D12Device5 interface is
implemented.
### libvkd3d-shader
- Several new features and improvements for the HLSL source type:
- Initial thread group shared memory support.
- Improved support for geometry shaders: shader model 5 multiple output
streams, as well as SV_IsFrontFace, SV_RenderTargetArrayIndex, and
SV_ViewportArrayIndex outputs.
- Structure variable input/output semantics are propagated to the
constituent structure fields.
- Shader entry point return values are allocated before any other outputs
in the output signature. This matches d3dcompiler/fxc more closely.
- Hull shader control point pass-through.
- Reflection information can be retrieved using vkd3d_shader_scan().
- Improved preprocessor handling of comments inside include directives, as
well as inclusion of empty files.
- Memory barrier intrinsics are supported in shader model 4 target
profiles. Previous these were only supported in shader model 5 target
profiles.
- Parser support for the noise() intrinsic. Although the intrinsic itself
isn't implemented, parser support for the intrinsic is required to allow
compilation of any other shaders in the same source file to succeed as
well.
- Parser support for StructuredBuffer resources.
- Various new features and improvements for the effects (FX) source type:
- Shader blob assignments and FXLVM value expressions in fx_2_0 effects.
- Nameless structure types.
- Explicit constant buffer bind points and constant packing offsets.
- The d3ds_noiseswiz, ge, lt, and noise FXLVM operations.
- The experimental Metal Shading Language (MSL) target supports the
following features:
- Texture sampling and gather operations.
- Loops and switches.
- Screen-space partial derivatives.
- Various integer arithmetic and comparison operations.
- Indirect addressing of constant buffers.
- Indexable temporary registers.
- Fragment shader output sample coverage masks.
- SV_Position and SV_SampleIndex fragment shader inputs.
- SV_VertexID inputs.
- When the experimental MSL target is enabled, the dxbc-dxil source type
can be used in combination with the msl target type to convert DXIL
shaders to MSL.
- The new tx source type can be used in combination with the d3d-asm
target type to disassemble D3DX tx_1_0 texture shaders.
- The FX target takes alignment and padding into account in fx_4_0 buffer
size calculations.
- The SPIR-V target is capable of outputting OpSource and OpLine debug
information.
- The core grammar for the experimental SPIR-V disassembler has been updated
to the vulkan-sdk-1.4.313.0 release.
- New interfaces:
- The VKD3D_SHADER_SOURCE_TX source type specifies D3DX tx_1_0 texture
shaders.
### vkd3d-compiler
- The new tx source type specifies D3DX tx_1_0 texture shaders.
### demos
- The new vkd3d-teapot demo uses tessellation shaders to render a version of
Martin Newell's famous teapot. It should be noted that current versions of
MoltenVK unfortunately do not support all features required to execute
this demo correctly.
# What's new in vkd3d 1.16 (20 May 2025)
### libvkd3d
- DXIL shaders are supported in the default configuration. Previously this
required building vkd3d with the -DVKD3D_SHADER_UNSUPPORTED_DXIL
preprocessor option. The also raises the maximum supported shader model to
version 6.0.
- Graphics pipeline state objects can be created from shaders with embedded
root signatures. This was already possible for compute pipeline state
objects.
- The SetEventOnMultipleFenceCompletion() method of the ID3D12Device1
interface is implemented.
- When the VK_KHR_zero_initialize_workgroup_memory extension is supported,
libvkd3d supports zero-initialising compute shader thread group shared
memory.
- The VK_KHR_maintenance2 extension is now explicitly required. libvkd3d
already unconditionally used features provided by this extension, but
unfortunately didn't explicitly require it. Support for this extension is
widespread, and the extension is part of Vulkan 1.1.
### libvkd3d-shader
- The previously experimental support for compiling DXIL shaders is now a
supported feature and enabled by default. Please note that this feature is
nevertheless still far from perfect.
- New features for the HLSL source type:
- Initial support for geometry shaders.
- Indirect addressing in shader model 1-3 target profiles.
- Modulus and truncation operations in shader model 1-3 target profiles.
- Vectorised output code.
- Further improved constant folding and propagation.
- The following intrinsic functions are supported:
- AllMemoryBarrier()
- AllMemoryBarrierWithGroupSync()
- DeviceMemoryBarrier()
- DeviceMemoryBarrierWithGroupSync()
- GroupMemoryBarrier()
- GroupMemoryBarrierWithGroupSync()
- The .Length Texture object property.
- The SV_RenderTargetArrayIndex and SV_ViewportArrayIndex semantics in
tessellation shaders.
- Disassembler support for binary fx_2_0 effects.
- Experimental built-in support for disassembling SPIR-V shaders, enabled by
building vkd3d with the -DVKD3D_SHADER_UNSUPPORTED_SPIRV_PARSER
preprocessor option. When enabled, the built-in SPIR-V disassembler is
used instead of SPIRV-Tools for the spirv-text target type, as well as
for the debug output enabled by the VKD3D_SHADER_DEBUG environment
variable.
- The experimental OpenGL Shading Language (GLSL) target supports indirect
addressing of constant buffers.
- The experimental Metal Shading Language (MSL) target supports texture
loads.
- New interfaces:
- The VKD3D_SHADER_COMPILE_OPTION_FEATURE_ZERO_INITIALIZE_WORKGROUP_MEMORY
flag indicates support for zero-initialising workgroup memory in the
SPIR-V target environment.
- The VKD3D_SHADER_COMPONENT_INT64 enumeration value indicates a 64-bit
signed integer value.
- The VKD3D_SHADER_COMPONENT_FLOAT16 enumeration value indicates a 16-bit
IEEE floating-point value.
- The VKD3D_SHADER_COMPONENT_UINT16 enumeration value indicates a 16-bit
unsigned integer value.
- The VKD3D_SHADER_COMPONENT_INT16 enumeration value indicates a 16-bit
signed integer value.
- When targeting VKD3D_SHADER_API_1_16, the
VKD3D_SHADER_RESOURCE_DATA_NONE enumeration value is returned for the
resource_data_type field in the vkd3d_shader_descriptor_info structure
for sampler descriptors. VKD3D_SHADER_API_1_15 and before use the
VKD3D_SHADER_RESOURCE_DATA_UINT enumeration value for this.
### demos
- The vkd3d demos now work on both the Microsoft Windows and Apple macOS
builds. The macOS versions of the vkd3d demos are completely new in vkd3d
1.16, while the Windows demos could previously be built, but only worked
on Wine. Note that the vkd3d demos produced by a Windows build of vkd3d
are distinct from those produced by the make crosstest target: the
former are Vulkan applications using vkd3d, while the latter are Direct3D
12 applications.
- The vkd3d demos have basic support for DPI scaling.
### build
- Perl and the JSON Perl module have been added as build dependencies.
These are used for the experimental built-in SPIR-V disassembler, as well
as for the macOS versions of the vkd3d demos.
# What's new in vkd3d 1.15 (19 February 2025)
### libvkd3d
- New interfaces:
- vkd3d_queue_signal_on_cpu() allows a Direct3D 12 fence to be signalled
when all preceding work on a Direct3D 12 command queue has been submitted
to the corresponding Vulkan queue.
### libvkd3d-shader
- New features for the HLSL source type:
- InputPatch and OutputPatch tessellation shader objects. This was the
main feature required by most tessellation shaders that was still missing,
and tessellation shaders should be considered generally usable now.
- Unrolling of loops containing conditional jumps.
- Improved function overload resolution. Previously the compiler was unable
to decide between multiple function overloads with the same number of
parameters.
- The parser is able to continue parsing in a larger number of error cases.
This allows more issues in the input to be reported during a single
compilaton attempt.
- The following intrinsic functions are supported:
- GatherCmp()
- GatherCmpAlpha(), GatherCmpBlue(), GatherCmpGreen(), and GatherCmpRed()
- InterlockedAdd(), InterlockedAnd(), InterlockedCompareExchange(),
InterlockedCompareStore(), InterlockedExchange(), InterlockedMax(),
InterlockedMin(), InterlockedOr(), and InterlockedXor()
- isinf()
- Separate resource and sampler support for shader model 1-3 target
profiles.
- Casts on the left hand side of assignments.
- Reassociation and redistribution of constants in binary expressions, to
facilitate constant folding.
- Packing of interstage I/O variables with the SV_IsFrontFace,
SV_PrimitiveID, SV_RenderTargetArrayIndex, SV_SampleIndex, and
SV_ViewPortArrayIndex semantics matches d3dcompiler/fxc more closely.
- Parser support for the LineStream, PointStream, and TriangleStream
Stream-Output objects.
- A number of instructions have been implemented for the experimental MSL
target. Although more and more shaders are starting to work, support is
still fairly limited. For example, shader resource views and unordered
access views are still entirely unsupported.
- Shader code generation for fixed-function fog. Like the existing shader code
generation for other fixed-function features, this is mainly relevant for
executing shader model 1-3 sources in modern target environments like
Vulkan.
- The fx parser can parse binary effects containing inline shader blobs.
- Internal validator support for validating I/O signatures, as well as I/O
source and destination parameters. The validator is enabled by the
force_validation option, specified through the VKD3D_SHADER_CONFIG
environment variable.
- Internal validator support for validating the number of indices used with a
register, as well as basic bounds checking for static indices.
- New interfaces:
- The vkd3d_shader_scan_hull_shader_tessellation_info structure extends the
vkd3d_shader_compile_info structure, and can be used to retrieve the
output primitive type and partitioning mode used by a hull shader. This
information is particularly useful for specifying
vkd3d_shader_spirv_domain_shader_target_info structures when targetting
SPIR-V in OpenGL environments.
- The VKD3D_SHADER_PARAMETER_NAME_FOG_FRAGMENT_MODE shader parameter
specifies the kind of fog to generate in a fragment shader.
- The VKD3D_SHADER_PARAMETER_NAME_FOG_COLOUR shader parameter
specifies the fog colour.
- The VKD3D_SHADER_PARAMETER_NAME_FOG_END shader parameter
specifies the end parameter used for linear fog generation.
- The VKD3D_SHADER_PARAMETER_NAME_FOG_SCALE shader parameter
specifies the scale parameter used for fog generation.
- The VKD3D_SHADER_PARAMETER_NAME_FOG_SOURCE shader parameter
specifies the kind of fog coordinate to output from a pre-rasterisation
shader.
### vkd3d-compiler
- The new dxbc-fx source type specifies an effect binary embedded in a DXBC
container. This is a convenience feature;
vkd3d-compiler -x dxbc-fx blob.dxbc is equivalent to
vkd3d-dxbc -x t:FX10 blob.dxbc | vkd3d-compiler -x fx.
# What's new in vkd3d 1.14 (21 November 2024)
### libvkd3d
- Depth bounds can be changed dynamically using the OMSetDepthBounds() method
of the ID3D12GraphicsCommandList1 interface.
- The new VKD3D_CAPS_OVERRIDE environment variable can be used to override the
value of capabilities like the maximum feature level and resource binding
tier reported to applications.
### libvkd3d-shader
- New features for the HLSL source type:
- Interstage I/O variable packing matches d3dcompiler/fxc more closely.
- The following intrinsic functions are supported:
- dst()
- f32tof16()
- mad()
- modf()
- sincos()
- discard support for shader model 1-3 target profiles.
- The SV_SampleIndex input semantic for fragment shaders.
- The SV_GroupIndex input semantic for compute shaders.
- The earlydepthstencil function attribute.
- Constant folding of expressions like x && c and x || c, where c is a
constant.
- Preprocessor support for namespaces in macro identifiers. I.e., syntax
like #define NAME1::NAME2::NAME3 1 works as intended now.
- Structure inheritance. Multiple inheritance is not supported.
- Register assignments for unused constant buffers are allowed to overlap
register assignments for used constant buffers.
- Instruction count reflection data for shader model 4+ target profiles.
This data is contained in the STAT DXBC section, and can be queried with
the GetDesc() method of the ID3D11ShaderReflection and
ID3D12ShaderReflection interfaces. Note that the ID3D12ShaderReflection
implementation provided by vkd3d-utils does not currently correctly report
this information.
- unorm and snorm resource format modifiers. For example,
Texture2D<unorm float4> t;
- Parser support for ByteAddressBuffer resources, as well as their
Load()/Load2()/Load3()/Load4() methods.
- Parser support for RWByteAddressBuffer resources, as well as their
Store()/Store2()/Store3()/Store4() methods.
- Parser support for the compile keyword, as well as the CompileShader()
and ConstructGSWithSO() intrinsic functions. Actual compilation of
embedded shaders is not implemented yet, but parser support is sufficient
for allowing compilation of HLSL sources containing this syntax to succeed
when targetting shader target profiles like vs_5_0 or ps_5_0.
- Initial support for tessellation shaders. Only the most trivial shaders
are supported in this release. Perhaps most notably, both InputPatch and
OutputPatch are not implemented yet.
- The new fx source type can be used in combination with the d3d-asm
target type to disassemble binary effects.
- More complete support for fx_2_0 binary effect output, including support for
annotations, default values, as well as object initialiser data used for e.g.
string, texture, and shader objects.
- A significant number of instructions have been implemented for the
experimental GLSL target. The GLSL output currently targets version 4.40
without extensions, but the intention is to make this configurable in a
future release of vkd3d.
- Experimental support for Metal Shading Language (MSL) output, enabled by
building vkd3d with the -DVKD3D_SHADER_UNSUPPORTED_MSL preprocessor
option. The current release is only able to compile the most basic shaders
when targetting MSL. Being an experimental feature, both the ABI and API may
change in future releases; the feature may even go away completely.
Nevertheless, we hope our users find this feature useful, and welcome
feedback and contributions.
- Shader code generation for various legacy fixed-function features, including
clip planes, point sizes, and point sprites. This is mainly relevant for
executing shader model 1-3 sources in modern target environments like
Vulkan, because those target environments do not implement equivalent
fixed-function features.
- The amount of shader validation done by the internal validator has been
greatly extended. The validator is enabled by the force_validation option,
specified through the VKD3D_SHADER_CONFIG environment variable.
- New interfaces:
- The VKD3D_SHADER_COMPILE_OPTION_DOUBLE_AS_FLOAT_ALIAS flag specifies that
the double type behaves as an alias for the float type in HLSL sources
with shader model 1-3 target profiles.
- The VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32_VEC4 enumeration value
specifies that a shader parameter contains a 4-dimensional vector of
32-bit floating-point data.
- The VKD3D_SHADER_PARAMETER_NAME_CLIP_PLANE_MASK shader parameter specifies
which clip planes are enabled.
- The VKD3D_SHADER_PARAMETER_NAME_CLIP_PLANE_[0-7] shader parameters specify
the corresponding clip planes.
- The VKD3D_SHADER_PARAMETER_NAME_POINT_SIZE shader parameter specifies the
point size to output when the source shader does not explicitly output a
point size.
- The VKD3D_SHADER_PARAMETER_NAME_POINT_SIZE_MIN shader parameter specifies
the minimum point size to clamp point size outputs to.
- The VKD3D_SHADER_PARAMETER_NAME_POINT_SIZE_MAX shader parameter specifies
the maximum point size to clamp point size outputs to.
- The VKD3D_SHADER_PARAMETER_NAME_POINT_SPRITE shader parameter specifies
whether texture coordinate inputs in fragment shaders should be replaced
with point coordinates.
- The VKD3D_SHADER_SOURCE_FX source type specifies binary Direct3D effects.
- The VKD3D_SHADER_TARGET_MSL target type specifies Metal Shading Language
shaders.
### libvkd3d-utils
- The GetDesc() method of the ID3D12ShaderReflection interface returned by
D3DReflect() returns shader version information.
- New interfaces:
- D3DCompile2VKD3D() is a variant of D3DCompile2() that allows targeting the
behaviour of a specific d3dcompiler version.
### vkd3d-compiler
- The --alias-double-as-float option specifies that the double type
behaves as an alias for the float type in HLSL sources with shader model
1-3 target profiles.
- The fx source type specifies binary Direct3D effects.
- The msl target type specifies Metal Shading Language shaders.
# What's new in vkd3d 1.13 (29 August 2024)
### libvkd3d
- The ID3D12CommandList6 interface is supported.
- Block-compressed textures can be created with unaligned dimensions. This
corresponds to
D3D12_FEATURE_D3D12_OPTIONS8.UnalignedBlockTexturesSupported.
- Some minor issues pointed out by the Vulkan validation layers have been
addressed. These are not known to affect applications in practice, but
should make libvkd3d slightly more well-behaved.
### libvkd3d-shader
- New features for the HLSL source type:
- Basic loop unrolling support. Some of the more complicated cases like
loops containing conditional jumps are still unsupported.
- Initialisation values for global variables, function parameters, and
annotation variables are parsed and stored in output formats supporting
them.
- Shader model 5.1 register spaces are supported when using the
corresponding target profiles, as well as shader model 5.1 reflection
data.
- Register reservations support expressions as offsets. For example:
float f : register(c0[1 + 1 * 2]);
- The tex1D(), tex2D(), tex3D(), and texCUBE() intrinsic function variants
with explicit derivatives are supported.
- The following intrinsic functions are supported:
- asint()
- f16tof32()
- faceforward()
- GetRenderTargetSampleCount()
- rcp()
- tex2Dbias()
- tex1Dgrad(), tex2Dgrad(), tex3Dgrad(), and texCUBEgrad()
- The sin() and cos() intrinsic functions are supported in shader model
1-3 profiles. These were already supported in shader model 4+ profiles.
- The following features specific to effects target profiles:
- Types supported in version 4.0+:
- BlendState
- ComputeShader, DomainShader, GeometryShader, and HullShader
- DepthStencilState
- RasterizerState
- State application functions implemented for version 4.0+ effects:
- OMSetRenderTargets()
- SetBlendState()
- SetComputeShader(), SetDomainShader(), SetGeometryShader(),
SetHullShader(), SetPixelShader(), and SetVertexShader()
- SetDepthStencilState()
- SetRasterizerState()
- String types. These are mainly used for annotations.
- Annotations on global variables.
- Support for the Texture field of the SamplerState type.
- Support for NULL values.
- Stores to swizzled matrix variables.
- The unsigned type modifier is supported. (For example,
unsigned int.) Note that uint and related types were already
supported.
- ConstantBuffer<> types.
- The SV_Coverage output semantic for fragment shaders.
- The experimental DXIL source type supports quad group operations.
- The Direct3D shader model 2-3 texldb instruction is correctly disassembled
when outputting Direct3D shader assembly.
- New interfaces:
- The vkd3d_shader_parameter_info structure extends the
vkd3d_shader_compile_info structure, and can be used to specify shader
parameters. This is a more generic version of the shader parameter
interface for SPIR-V targets in struct vkd3d_shader_spirv_target_info.
- The VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32 enumeration value specifies
that a shader parameter contains 32-bit floating-point data.
- The VKD3D_SHADER_PARAMETER_NAME_ALPHA_TEST_FUNC shader parameter
specifies the alpha test function.
- The VKD3D_SHADER_PARAMETER_NAME_ALPHA_TEST_REF shader parameter
specifies the alpha test reference value.
- The VKD3D_SHADER_PARAMETER_NAME_FLAT_INTERPOLATION shader parameter
specifies the interpolation mode for colour inputs in Direct3D shader
model 1-3 fragment shaders.
- The VKD3D_SHADER_PARAMETER_TYPE_BUFFER enumeration value specifies that
the value of a shader parameter is provided at run-time through a buffer
resource.
# What's new in vkd3d 1.12 (28 May 2024)
### libvkd3d

View File

@@ -10,6 +10,7 @@ OPTIMIZE_OUTPUT_FOR_C = YES
EXTRACT_STATIC = YES
QUIET = YES
WARN_IF_UNDOCUMENTED = NO
WARN_IF_INCOMPLETE_DOC = NO
LATEX_BATCHMODE = YES
INPUT = @srcdir@/include/vkd3d.h \

View File

@@ -2,6 +2,12 @@ ACLOCAL_AMFLAGS = -I m4
AM_CFLAGS = @VKD3D_CFLAGS@
AM_CPPFLAGS = -I$(srcdir)/include -I$(srcdir)/include/private -I$(builddir)/include/private
AM_LDFLAGS = -no-undefined
VKD3D_PERL = $(PERL) -w
objc_headers = \
include/private/appkit.h \
include/private/foundation.h \
include/private/quartzcore.h
widl_headers = \
include/vkd3d_d3d12.h \
@@ -48,8 +54,8 @@ vkd3d_cross_tests = \
vkd3d_shader_tests = \
tests/hlsl/abs.shader_test \
tests/hlsl/all.shader_test \
tests/hlsl/alpha-test.shader_test \
tests/hlsl/angle-unit.shader_test \
tests/hlsl/annotations.shader_test \
tests/hlsl/any.shader_test \
tests/hlsl/arithmetic-float-uniform.shader_test \
tests/hlsl/arithmetic-float.shader_test \
@@ -60,8 +66,11 @@ vkd3d_shader_tests = \
tests/hlsl/array-parameters.shader_test \
tests/hlsl/array-size-expr.shader_test \
tests/hlsl/asfloat.shader_test \
tests/hlsl/asint.shader_test \
tests/hlsl/asuint.shader_test \
tests/hlsl/attributes.shader_test \
tests/hlsl/barriers.shader_test \
tests/hlsl/bitwise-assignment.shader_test \
tests/hlsl/bitwise.shader_test \
tests/hlsl/bool-cast.shader_test \
tests/hlsl/bool-semantics.shader_test \
@@ -78,37 +87,57 @@ vkd3d_shader_tests = \
tests/hlsl/ceil.shader_test \
tests/hlsl/cf-cond-types.shader_test \
tests/hlsl/clamp.shader_test \
tests/hlsl/clip-distance.shader_test \
tests/hlsl/clip-cull-distance.shader_test \
tests/hlsl/clip-planes.shader_test \
tests/hlsl/clip.shader_test \
tests/hlsl/combined-samplers.shader_test \
tests/hlsl/comma.shader_test \
tests/hlsl/compute.shader_test \
tests/hlsl/conditional.shader_test \
tests/hlsl/const.shader_test \
tests/hlsl/constructgswithso.shader_test \
tests/hlsl/coverage.shader_test \
tests/hlsl/cross.shader_test \
tests/hlsl/d3dcolor-to-ubyte4.shader_test \
tests/hlsl/ddxddy.shader_test \
tests/hlsl/default-values.shader_test \
tests/hlsl/depth-bounds.shader_test \
tests/hlsl/depth-out.shader_test \
tests/hlsl/determinant.shader_test \
tests/hlsl/discard.shader_test \
tests/hlsl/distance.shader_test \
tests/hlsl/dot.shader_test \
tests/hlsl/duplicate-modifiers.shader_test \
tests/hlsl/early-depth-stencil.shader_test \
tests/hlsl/effect-annotations-fx_2.shader_test \
tests/hlsl/effect-annotations-fx_4.shader_test \
tests/hlsl/effect-assignments-fx_5.shader_test \
tests/hlsl/effect-compile.shader_test \
tests/hlsl/effect-initial-values-fx_2.shader_test \
tests/hlsl/effect-initial-values-fx_4.shader_test \
tests/hlsl/effect-pass-states-fx_4.shader_test \
tests/hlsl/effect-pass-states-fx_5.shader_test \
tests/hlsl/effect-shader-objects-fx_2.shader_test \
tests/hlsl/effect-shader-objects-fx_5.shader_test \
tests/hlsl/effect-technique-fx_2.shader_test \
tests/hlsl/effect-technique-fx_4.shader_test \
tests/hlsl/effect-technique-fx_5.shader_test \
tests/hlsl/effect-variables-fx_2.shader_test \
tests/hlsl/effect-variables-fx_4.shader_test \
tests/hlsl/effect-variables-fx_4_1.shader_test \
tests/hlsl/effect-variables-fx_5.shader_test \
tests/hlsl/entry-point-semantics.shader_test \
tests/hlsl/eval-attrib.shader_test \
tests/hlsl/exp.shader_test \
tests/hlsl/expr-indexing.shader_test \
tests/hlsl/f16tof32.shader_test \
tests/hlsl/f32tof16.shader_test \
tests/hlsl/faceforward.shader_test \
tests/hlsl/ffp-point-size.shader_test \
tests/hlsl/float-comparison.shader_test \
tests/hlsl/floor.shader_test \
tests/hlsl/fmod.shader_test \
tests/hlsl/fog.shader_test \
tests/hlsl/for.shader_test \
tests/hlsl/frac.shader_test \
tests/hlsl/function-cast.shader_test \
@@ -117,13 +146,17 @@ vkd3d_shader_tests = \
tests/hlsl/function.shader_test \
tests/hlsl/fwidth.shader_test \
tests/hlsl/fxgroup-syntax.shader_test \
tests/hlsl/gather-cmp.shader_test \
tests/hlsl/gather-offset.shader_test \
tests/hlsl/gather.shader_test \
tests/hlsl/geometry-shader-syntax.shader_test \
tests/hlsl/geometry.shader_test \
tests/hlsl/get-sample-pos.shader_test \
tests/hlsl/getdimensions.shader_test \
tests/hlsl/half.shader_test \
tests/hlsl/hard-copy-prop.shader_test \
tests/hlsl/hull-shader-attributes.shader_test \
tests/hlsl/hull-shader-syntax.shader_test \
tests/hlsl/initializer-flatten.shader_test \
tests/hlsl/initializer-implicit-array.shader_test \
tests/hlsl/initializer-invalid-arg-count.shader_test \
@@ -136,13 +169,18 @@ vkd3d_shader_tests = \
tests/hlsl/initializer-static-array.shader_test \
tests/hlsl/initializer-struct.shader_test \
tests/hlsl/instance-id.shader_test \
tests/hlsl/interface-packing.shader_test \
tests/hlsl/intrinsic-override.shader_test \
tests/hlsl/invalid.shader_test \
tests/hlsl/inverse-trig.shader_test \
tests/hlsl/is-front-face.shader_test \
tests/hlsl/isinf.shader_test \
tests/hlsl/ldexp.shader_test \
tests/hlsl/length-property.shader_test \
tests/hlsl/length.shader_test \
tests/hlsl/lerp.shader_test \
tests/hlsl/lhs-cast.shader_test \
tests/hlsl/lhs-partial-assignment.shader_test \
tests/hlsl/lit.shader_test \
tests/hlsl/load-level.shader_test \
tests/hlsl/log.shader_test \
@@ -156,22 +194,31 @@ vkd3d_shader_tests = \
tests/hlsl/matrix-semantics.shader_test \
tests/hlsl/max-min.shader_test \
tests/hlsl/minimum-precision.shader_test \
tests/hlsl/modf.shader_test \
tests/hlsl/mul.shader_test \
tests/hlsl/multiple-rt.shader_test \
tests/hlsl/nested-arrays.shader_test \
tests/hlsl/nointerpolation.shader_test \
tests/hlsl/noise.shader_test \
tests/hlsl/non-const-indexing.shader_test \
tests/hlsl/normalize.shader_test \
tests/hlsl/null.shader_test \
tests/hlsl/numeric-constructor-truncation.shader_test \
tests/hlsl/numeric-types.shader_test \
tests/hlsl/numthreads.shader_test \
tests/hlsl/object-field-offsets.shader_test \
tests/hlsl/object-parameters.shader_test \
tests/hlsl/object-references.shader_test \
tests/hlsl/patch-syntax.shader_test \
tests/hlsl/pixel-position.shader_test \
tests/hlsl/point-sprite.shader_test \
tests/hlsl/pointer-cast.shader_test \
tests/hlsl/pow.shader_test \
tests/hlsl/precise-modifier.shader_test \
tests/hlsl/primitive-id.shader_test \
tests/hlsl/ps1-sampler.shader_test \
tests/hlsl/rasteriser-ordered-views.shader_test \
tests/hlsl/rcp.shader_test \
tests/hlsl/reflect.shader_test \
tests/hlsl/refract.shader_test \
tests/hlsl/register-reservations-numeric.shader_test \
@@ -179,28 +226,39 @@ vkd3d_shader_tests = \
tests/hlsl/register-reservations-resources.shader_test \
tests/hlsl/register-reservations-space.shader_test \
tests/hlsl/return-implicit-conversion.shader_test \
tests/hlsl/return-semantics.shader_test \
tests/hlsl/return.shader_test \
tests/hlsl/round.shader_test \
tests/hlsl/rt-array-index.shader_test \
tests/hlsl/rt-format-mismatch.shader_test \
tests/hlsl/rt-get-sample-info.shader_test \
tests/hlsl/sample-bias.shader_test \
tests/hlsl/sample-cmp.shader_test \
tests/hlsl/sample-grad.shader_test \
tests/hlsl/sample-level.shader_test \
tests/hlsl/sampler-offset.shader_test \
tests/hlsl/sampler-state.shader_test \
tests/hlsl/sampler.shader_test \
tests/hlsl/saturate.shader_test \
tests/hlsl/scope.shader_test \
tests/hlsl/semantic-cascading.shader_test \
tests/hlsl/shade-mode.shader_test \
tests/hlsl/shader-interstage-interface.shader_test \
tests/hlsl/shader-point-size.shader_test \
tests/hlsl/shape.shader_test \
tests/hlsl/side-effects.shader_test \
tests/hlsl/sign.shader_test \
tests/hlsl/single-numeric-initializer.shader_test \
tests/hlsl/sm1-const-allocation.shader_test \
tests/hlsl/sm1-const-folding.shader_test \
tests/hlsl/sm1-interstage-interface.shader_test \
tests/hlsl/sm6-ternary.shader_test \
tests/hlsl/sm6-uav-rwtexture.shader_test \
tests/hlsl/smoothstep.shader_test \
tests/hlsl/sqrt.shader_test \
tests/hlsl/srv-buffers.shader_test \
tests/hlsl/srv-byteaddressbuffer.shader_test \
tests/hlsl/srv-structuredbuffer.shader_test \
tests/hlsl/state-block-function-syntax.shader_test \
tests/hlsl/state-block-syntax.shader_test \
tests/hlsl/static-initializer.shader_test \
@@ -209,12 +267,15 @@ vkd3d_shader_tests = \
tests/hlsl/strings.shader_test \
tests/hlsl/struct-array.shader_test \
tests/hlsl/struct-assignment.shader_test \
tests/hlsl/struct-inheritance.shader_test \
tests/hlsl/struct-semantics.shader_test \
tests/hlsl/struct-syntax.shader_test \
tests/hlsl/switch.shader_test \
tests/hlsl/swizzle-constant-prop.shader_test \
tests/hlsl/swizzle-matrix.shader_test \
tests/hlsl/swizzles.shader_test \
tests/hlsl/ternary.shader_test \
tests/hlsl/tessellation-patch-vars.shader_test \
tests/hlsl/tessellation.shader_test \
tests/hlsl/texture-load-offset.shader_test \
tests/hlsl/texture-load-typed.shader_test \
@@ -236,9 +297,14 @@ vkd3d_shader_tests = \
tests/hlsl/unbounded-array-5.1.shader_test \
tests/hlsl/uniform-parameters.shader_test \
tests/hlsl/uniform-semantics.shader_test \
tests/hlsl/uninitialized-varyings.shader_test \
tests/hlsl/unorm-snorm.shader_test \
tests/hlsl/unroll.shader_test \
tests/hlsl/unsigned.shader_test \
tests/hlsl/vector-indexing-uniform.shader_test \
tests/hlsl/vector-indexing.shader_test \
tests/hlsl/vertex-shader-ops.shader_test \
tests/hlsl/vp-array-index.shader_test \
tests/hlsl/wave-ops-float.shader_test \
tests/hlsl/wave-ops-int.shader_test \
tests/hlsl/wave-ops-uint.shader_test \
@@ -260,18 +326,24 @@ vkd3d_test_headers = \
tests/dxcompiler.h \
tests/shader_runner.h \
tests/utils.h \
tests/vulkan_procs.h
tests/vulkan_procs.h \
tests/vulkan_utils.h
vkd3d_demos = \
demos/vkd3d-gears \
demos/vkd3d-teapot \
demos/vkd3d-triangle
vkd3d_demos_headers = \
demos/demo.h \
demos/demo_d3d12.h \
demos/demo_macos.h \
demos/demo_vkd3d.h \
demos/demo_win32.h \
demos/demo_xcb.h
BUILT_SOURCES = $(widl_headers) \
BUILT_SOURCES = $(objc_headers) $(widl_headers) \
include/private/spirv_grammar.h \
include/private/vkd3d_version.h
noinst_LTLIBRARIES = libvkd3d-common.la
@@ -330,6 +402,7 @@ nodist_libvkd3d_shader_la_SOURCES = $(vkd3d_shader_yyfiles)
libvkd3d_shader_la_SOURCES = \
include/private/list.h \
include/private/rbtree.h \
include/private/spirv_grammar.h \
include/private/vkd3d_common.h \
include/private/vkd3d_memory.h \
include/vkd3d_shader.h \
@@ -345,6 +418,7 @@ libvkd3d_shader_la_SOURCES = \
libs/vkd3d-shader/hlsl_codegen.c \
libs/vkd3d-shader/hlsl_constant_ops.c \
libs/vkd3d-shader/ir.c \
libs/vkd3d-shader/msl.c \
libs/vkd3d-shader/preproc.h \
libs/vkd3d-shader/spirv.c \
libs/vkd3d-shader/tpf.c \
@@ -352,7 +426,7 @@ libvkd3d_shader_la_SOURCES = \
libs/vkd3d-shader/vkd3d_shader_main.c \
libs/vkd3d-shader/vkd3d_shader_private.h
libvkd3d_shader_la_CFLAGS = $(AM_CFLAGS) -DLIBVKD3D_SHADER_SOURCE -I$(srcdir)/libs/vkd3d-shader @SPIRV_TOOLS_CFLAGS@
libvkd3d_shader_la_LDFLAGS = $(AM_LDFLAGS) -version-info 11:0:10
libvkd3d_shader_la_LDFLAGS = $(AM_LDFLAGS) -version-info 16:0:15
libvkd3d_shader_la_LIBADD = libvkd3d-common.la @SPIRV_TOOLS_LIBS@ -lm
if HAVE_LD_VERSION_SCRIPT
libvkd3d_shader_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libs/vkd3d-shader/vkd3d_shader.map
@@ -387,7 +461,7 @@ libvkd3d_la_SOURCES = \
libs/vkd3d/vkd3d_shaders.h \
libs/vkd3d/vulkan_procs.h
libvkd3d_la_CFLAGS = $(AM_CFLAGS) -DLIBVKD3D_SOURCE
libvkd3d_la_LDFLAGS = $(AM_LDFLAGS) -version-info 13:0:12
libvkd3d_la_LDFLAGS = $(AM_LDFLAGS) -version-info 18:0:17
libvkd3d_la_LIBADD = libvkd3d-common.la libvkd3d-shader.la @DL_LIBS@ @PTHREAD_LIBS@
if HAVE_LD_VERSION_SCRIPT
libvkd3d_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libs/vkd3d/vkd3d.map
@@ -400,7 +474,7 @@ libvkd3d_utils_la_SOURCES = \
libs/vkd3d-utils/vkd3d_utils_main.c \
libs/vkd3d-utils/vkd3d_utils_private.h
libvkd3d_utils_la_CFLAGS = $(AM_CFLAGS) -DLIBVKD3D_UTILS_SOURCE
libvkd3d_utils_la_LDFLAGS = $(AM_LDFLAGS) -version-info 6:1:5
libvkd3d_utils_la_LDFLAGS = $(AM_LDFLAGS) -version-info 7:3:6
libvkd3d_utils_la_LIBADD = libvkd3d-common.la libvkd3d-shader.la libvkd3d.la @PTHREAD_LIBS@
if HAVE_LD_VERSION_SCRIPT
libvkd3d_utils_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libs/vkd3d-utils/vkd3d_utils.map
@@ -432,15 +506,20 @@ LDADD = libvkd3d.la libvkd3d-shader.la libvkd3d-utils.la
AM_DEFAULT_SOURCE_EXT = .c
TEST_EXTENSIONS = .shader_test
TEST_CPPFLAGS = -I$(builddir)/tests
if BUILD_TESTS
check_PROGRAMS = $(vkd3d_tests) $(vkd3d_cross_tests) tests/shader_runner
dist_check_SCRIPTS = tests/test-driver.sh
TESTS = $(vkd3d_tests) $(vkd3d_cross_tests) $(vkd3d_shader_tests)
tests_d3d12_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CPPFLAGS)
tests_d3d12_LDADD = $(LDADD) @PTHREAD_LIBS@ @DL_LIBS@
tests_d3d12_invalid_usage_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CPPFLAGS)
tests_d3d12_invalid_usage_LDADD = $(LDADD) @DL_LIBS@
tests_hlsl_d3d12_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CPPFLAGS)
tests_hlsl_d3d12_LDADD = $(LDADD) @DL_LIBS@
tests_shader_runner_CFLAGS = $(AM_CFLAGS) -I$(builddir)/tests @OPENGL_CFLAGS@
tests_shader_runner_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CPPFLAGS)
tests_shader_runner_CFLAGS = $(AM_CFLAGS) @OPENGL_CFLAGS@
tests_shader_runner_LDADD = $(LDADD) @OPENGL_LIBS@ @DL_LIBS@
tests_shader_runner_SOURCES = \
tests/shader_runner.c \
@@ -449,8 +528,18 @@ tests_shader_runner_SOURCES = \
tests/shader_runner_d3d12.c \
tests/shader_runner_gl.c \
tests/shader_runner_vulkan.c
if HAVE_METAL
tests_shader_runner_OBJCFLAGS = $(AM_CFLAGS)
tests_shader_runner_SOURCES += tests/shader_runner_metal.m
tests_shader_runner_LINK = $(OBJCLINK) -framework Foundation -framework Metal
else
tests_shader_runner_LINK = $(LINK)
endif
tests_vkd3d_api_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CPPFLAGS)
tests_vkd3d_api_LDADD = libvkd3d.la @DL_LIBS@
tests_vkd3d_shader_api_LDADD = libvkd3d-shader.la
tests_vkd3d_shader_api_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CPPFLAGS)
tests_vkd3d_shader_api_CFLAGS = $(AM_CFLAGS) @OPENGL_CFLAGS@
tests_vkd3d_shader_api_LDADD = libvkd3d-shader.la @OPENGL_LIBS@ @DL_LIBS@
SHADER_TEST_LOG_COMPILER = tests/shader_runner
SHADER_TEST_LOG_DRIVER = $(srcdir)/tests/test-driver.sh
endif
@@ -458,20 +547,45 @@ endif
EXTRA_DIST += $(vkd3d_shader_tests)
if BUILD_DEMOS
DEMOS_LDADD = $(LDADD) libvkd3d-shader.la @DL_LIBS@ @DEMO_LIBS@
DEMOS_CFLAGS = $(AM_CFLAGS) @DEMO_CFLAGS@
DEMOS_LDADD = $(LDADD) @DL_LIBS@ @DEMO_LIBS@
DEMOS_CFLAGS = $(AM_CFLAGS) @DEMO_CFLAGS@ -I$(srcdir)/demos -Wa,-I$(srcdir)/demos
bin_PROGRAMS += $(vkd3d_demos)
demos_vkd3d_gears_SOURCES = demos/gears.c demos/gears_hlsl.h
demos_vkd3d_gears_SOURCES = demos/gears.c demos/gears.hlsl
demos_vkd3d_gears_CFLAGS = $(DEMOS_CFLAGS)
demos_vkd3d_gears_LDADD = $(DEMOS_LDADD) -lm
demos/vkd3d_gears-gears.$(OBJEXT): demos/gears.hlsl
demos_vkd3d_triangle_SOURCES = demos/triangle.c demos/triangle_hlsl.h
teapot_shaders = \
demos/teapot.hlsl \
demos/text.hlsl
demos_vkd3d_teapot_SOURCES = \
$(teapot_shaders) \
demos/etl16-unicode.h \
demos/teapot.c \
demos/teapot.h
demos_vkd3d_teapot_CFLAGS = $(DEMOS_CFLAGS)
demos_vkd3d_teapot_LDADD = $(DEMOS_LDADD) -lm
demos/vkd3d_teapot-teapot.$(OBJEXT): $(teapot_shaders)
demos_vkd3d_triangle_SOURCES = demos/triangle.c demos/triangle.hlsl
demos_vkd3d_triangle_CFLAGS = $(DEMOS_CFLAGS)
demos_vkd3d_triangle_LDADD = $(DEMOS_LDADD)
demos/vkd3d_triangle-triangle.$(OBJEXT): demos/triangle.hlsl
endif
noinst_HEADERS = $(vkd3d_test_headers) $(vkd3d_demos_headers)
dist_noinst_SCRIPTS = libs/vkd3d-shader/make_spirv demos/make_objc
VKD3D_V_PERL = $(vkd3d_v_perl_@AM_V@)
vkd3d_v_perl_ = $(vkd3d_v_perl_@AM_DEFAULT_V@)
vkd3d_v_perl_0 = @echo " PERL " $@;
vkd3d_v_perl_1 =
CLEANFILES += $(objc_headers)
${objc_headers}: %.h: demos/make_objc %.json
@$(MKDIR_P) $(@D)
$(VKD3D_V_PERL)$(VKD3D_PERL) $^ > $@.tmp && mv $@.tmp $@
VKD3D_V_WIDL = $(vkd3d_v_widl_@AM_V@)
vkd3d_v_widl_ = $(vkd3d_v_widl_@AM_DEFAULT_V@)
@@ -481,7 +595,11 @@ vkd3d_v_widl_1 =
if HAVE_WIDL
CLEANFILES += $(widl_headers)
endif
EXTRA_DIST += $(widl_headers) $(widl_headers:.h=.idl)
EXTRA_DIST += \
$(widl_headers) \
$(widl_headers:.h=.idl) \
$(objc_headers:.h=.json) \
include/private/spirv.core.grammar.json
$(widl_headers): %.h: %.idl
if HAVE_WIDL
$(VKD3D_V_WIDL)$(WIDL) -I$(srcdir)/include -h -o $@ $<
@@ -513,6 +631,10 @@ libvkd3d.pc: $(srcdir)/libs/vkd3d/libvkd3d.pc.in Makefile
-e 's![@]PACKAGE_VERSION[@]!$(PACKAGE_VERSION)!g' \
$< > $@
include/private/spirv_grammar.h: libs/vkd3d-shader/make_spirv include/private/spirv.core.grammar.json
@$(MKDIR_P) $(@D)
$(VKD3D_V_PERL)$(VKD3D_PERL) $^ > $@.tmp && mv $@.tmp $@
include/private/vkd3d_version.h: dummy-vkd3d-version
@$(MKDIR_P) include/private
version=`(GIT_DIR=$(top_srcdir)/.git git rev-parse --short HEAD 2>/dev/null || echo '') \
@@ -521,7 +643,7 @@ include/private/vkd3d_version.h: dummy-vkd3d-version
&& (echo $$version | cmp -s - $@) \
|| echo $$version >$@ || ($(RM) $@ && exit 1)
.SILENT: include/private/vkd3d_version.h
CLEANFILES += include/private/vkd3d_version.h
CLEANFILES += include/private/spirv_grammar.h include/private/vkd3d_version.h
.PHONY: dummy-vkd3d-version
dummy-vkd3d-version:
@@ -529,7 +651,7 @@ dummy-vkd3d-version:
## Cross-compile tests
cross_implibs = crosslibs/d3d12
CROSS_CPPFLAGS = -I$(srcdir)/include -I$(srcdir)/include/private -I$(builddir)/include -I$(builddir)/tests
CROSS_CFLAGS = -g -O2 -Wall -municode ${CROSS_CPPFLAGS} \
CROSS_CFLAGS = -g -O2 -Wall -municode ${CROSS_CPPFLAGS} -Wa,-I$(srcdir)/demos \
-D_WIN32_WINNT=0x0600 -D__USE_MINGW_ANSI_STDIO=0 -DVKD3D_CROSSTEST=1
EXTRA_DIST += $(cross_implibs:=.cross32.def) $(cross_implibs:=.cross64.def)
EXTRA_DIST += tests/driver.c tests/shader_runner_d3d11.c tests/shader_runner_d3d9.c
@@ -553,6 +675,9 @@ CROSS32_EXEFILES += $(vkd3d_cross_tests:=.cross32.exe)
endif
if BUILD_DEMOS
CROSS32_EXEFILES += $(vkd3d_demos:demos/vkd3d-%=demos/%.cross32.exe)
demos/gears.cross32.exe: demos/gears.hlsl
demos/teapot.cross32.exe: $(teapot_shaders)
demos/triangle.cross32.exe: demos/triangle.hlsl
endif
CROSS32_FILES = $(CROSS32_EXEFILES)
@@ -600,6 +725,9 @@ CROSS64_EXEFILES += $(vkd3d_cross_tests:=.cross64.exe)
endif
if BUILD_DEMOS
CROSS64_EXEFILES += $(vkd3d_demos:demos/vkd3d-%=demos/%.cross64.exe)
demos/gears.cross64.exe: demos/gears.hlsl
demos/teapot.cross64.exe: $(teapot_shaders)
demos/triangle.cross64.exe: demos/triangle.hlsl
endif
CROSS64_FILES = $(CROSS64_EXEFILES)

130
README
View File

@@ -9,7 +9,8 @@ similar, but not identical, to Direct3D 12.
Building vkd3d
==============
Vkd3d depends on SPIRV-Headers and Vulkan-Headers (>= 1.3.228).
Vkd3d depends on SPIRV-Headers and Vulkan-Headers (>= 1.3.228), as well as Perl
and libjson-perl.
Vkd3d generates some of its headers from IDL files. If you are using the
release tarballs, then these headers are pre-generated and are included. If
@@ -19,10 +20,20 @@ available or is not recent (>= 3.21), then you can build Wine with `make
tools/widl/widl' to avoid building all of Wine. You can then point vkd3d's
configure at that widl binary with `WIDL="/path/to/widl"'.
For release builds, you may want to define NDEBUG. If you do not need debug log
messages, you may also consider VKD3D_NO_TRACE_MESSAGES and
VKD3D_NO_DEBUG_MESSAGES. For example, you can pass `CPPFLAGS="-DNDEBUG
-DVKD3D_NO_TRACE_MESSAGES"' to configure.
For release builds, you may want to disable debug log messages defining
preprocessor macros VKD3D_NO_TRACE_MESSAGES and VKD3D_NO_DEBUG_MESSAGES.
See the `Preprocessor definitions' section below for more details.
================
Developing vkd3d
================
Development of vkd3d happens on the Wine GitLab instance
(https://gitlab.winehq.org/wine/vkd3d/). Contributors are encouraged
to submit their patches using the merge request tool.
Each merge request is automatically tested with the GitLab CI
system. See gitlab/README in the Git tree for more details.
===========
Using vkd3d
@@ -39,8 +50,8 @@ Environment variables
=====================
Most of the environment variables used by vkd3d are for debugging purposes. The
environment variables are not considered a part of API and might be changed or
removed in the future versions of vkd3d.
environment variables are not considered a stable interface and might be changed
or removed in future versions of vkd3d.
Some of debug variables are lists of elements. Elements must be separated by
commas or semicolons.
@@ -65,6 +76,14 @@ commas or semicolons.
* VKD3D_DISABLE_EXTENSIONS - a list of Vulkan extensions that libvkd3d should
not use even if available.
* VKD3D_CAPS_OVERRIDE - a list of Direct3D 12 capabilities for which the
default value detected by vkd3d should be overridden, in the form
`capability1=value1,capability2=value2'. This doesn't change the vkd3d
behaviour, only the information reported to the application. The following
capabilities can currently be overridden:
* feature_level (allowed values: 11.0, 11.1, 12.0, 12.1, 12.2)
* resource_binding_tier (allowed values: 1, 2, 3)
* VKD3D_SHADER_CONFIG - a list of options that change the behavior of
libvkd3d-shader.
* force_validation - Enable (additional) validation of libvkd3d-shader's
@@ -78,6 +97,10 @@ commas or semicolons.
* VKD3D_TEST_DEBUG - enables additional debug messages in tests. Set to 0, 1
or 2.
* VKD3D_TEST_DETAILED - enables printing detailed output when running the test
suite, reporting specific shader_test lines that trigger XFAIL and SKIP even
on tests that overall PASS. Set to 0, or 1.
* VKD3D_TEST_FILTER - a filter string. Only the tests whose names matches the
filter string will be run, e.g. VKD3D_TEST_FILTER=clear_render_target.
Useful for debugging or developing new tests.
@@ -101,13 +124,90 @@ code for adding DXBC checksums, so the official release should be installed
from:
https://github.com/microsoft/DirectXShaderCompiler/releases
================
Developing vkd3d
================
========================
Preprocessor definitions
========================
Development of vkd3d happens on the Wine GitLab instance
(https://gitlab.winehq.org/wine/vkd3d/). Contributors are encouraged
to submit their patches using the merge request tool.
A number of preprocessor definitions can be used at compilation time to control
the behaviour of the generated binary. You can pass something like
`CPPFLAGS="-DVKD3D_VAR1 -DVKD3D_VAR2"' to the configure script. The preprocessor
variables are not considered a stable interface and might be changed or removed
in future versions of vkd3d.
Each merge request is automatically tested with the GitLab CI
system. See gitlab/README in the Git tree for more details.
* VKD3D_NO_TRACE_MESSAGES - do not emit trace messages in the debug log; this
can be useful in release builds to reduce the size of the binary and make it
slightly faster.
* VKD3D_NO_DEBUG_MESSAGES - do not emit warn and fixme messages in the debug
log; this will further optimise the binary, but may omit messages that could
help debug problems with vkd3d.
* VKD3D_NO_ERROR_MESSAGES - do not emit error messages; this will optimise the
binary even more, but may omit very important messages, so it is not
recommended in most circumstances.
* VKD3D_ABORT_ON_ERR - abort the process as soon as an error message is
emitted; this can be useful for developers to make error conditions as
conspicuous as possible.
* VKD3D_SHADER_UNSUPPORTED_GLSL - enable GLSL (GL Shading Language) support in
vkd3d-shader, which is disabled by default because it is not considered ready
for release yet. Please note that this feature is not currently supported,
and it might change in a non-compatible way before it is released.
* VKD3D_SHADER_UNSUPPORTED_MSL - enable MSL (Metal Shading Language) support in
vkd3d-shader, which is disabled by default because it is not considered ready
for release yet. Please note that this feature is not currently supported,
and it might change in a non-compatible way before it is released.
* VKD3D_SHADER_UNSUPPORTED_SPIRV_PARSER - enable SPIR-V parser support in
vkd3d-shader, which is disabled by default because it is not considered ready
for release yet. Please note that this feature is not currently supported,
and it might change in a non-compatible way before it is released.
============================
Testing with the Agility SDK
============================
Traditionally Microsoft have released the Direct3D 12 development files,
including the debug layer runtime, as part of the larger Windows SDK.
In 2021 the DirectX 12 Agility SDK was introduced, which may be updated
independently of the Windows SDK. If you plan to run the vkd3d
crosstests with Microsoft's debug layer you might want to get it from
the Agility SDK, both because it's probably going to be more up-to-date
and because the Agility SDK is a couple dozens of megabytes versus the
gigabytes of the Windows SDK.
In order to build the vkd3d crosstests with Agility SDK support, follow
these steps:
* The Agility SDK is distributed at [1]: select your preferred
version (likely the most recent one) and note the number in column
D3D12SDKVersion, which you're going to need later.
[1] https://devblogs.microsoft.com/directx/directx12agility/
* You also need to enable the "Graphics Tools" optional feature in Windows.
Open the "Settings" applications, then look for "Apps", "Optional features",
"View features" and install "Graphics Tools".
* Configure vkd3d with something like:
'CROSSCC64="x86_64-w64-mingw32-gcc -DVKD3D_AGILITY_SDK_VERSION=<version>"',
as well as the equivalent CROSSCC32 variable for the 32-bit
crosstests. You'll have to replace '<version>' with the
D3D12SDKVersion number you noted above. Then build the crosstests
with 'make crosstest' as usual.
* Download the Agility SDK NuGet package, which is essentially a ZIP
file with a .nupkg extension. Extract d3d12core.dll and
d3d12sdklayers.dll for your architecture, and put them in the
directory containing the crosstest executables.
* Now you can run the crosstests, possibly with arguments
'--validate' and '--gbv' to enable the debug layers. They will use
the runtime from the Agility SDK.
* It's also possible to use '-DVKD3D_AGILITY_SDK_PATH=/path/to/sdk/' to
specify the directory to load the Agility SDK DLLs from at runtime.
If relative, the path is intended to be relative to the executable
path. If unspecified the path defaults to './'.

View File

@@ -1,13 +1,15 @@
AC_PREREQ([2.69])
AC_INIT([vkd3d],[1.12])
AC_INIT([vkd3d],[1.17])
AC_CONFIG_AUX_DIR([bin])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS(include/config.h)
AC_ARG_VAR([PERL], [The Perl 5 language interpreter])
AC_ARG_VAR([WIDL], [widl IDL compiler])
AC_ARG_VAR([CROSSCC32], [32-bit Windows cross compiler])
AC_ARG_VAR([CROSSCC64], [64-bit Windows cross compiler])
AC_ARG_WITH([metal], AS_HELP_STRING([--with-metal], [Build with the Metal library (default: test)]))
AC_ARG_WITH([ncurses], AS_HELP_STRING([--with-ncurses], [Build with the ncurses library (default: test)]))
AC_ARG_WITH([opengl], AS_HELP_STRING([--with-opengl], [Build with the OpenGL library (default: test)]))
AC_ARG_WITH([spirv-tools], AS_HELP_STRING([--with-spirv-tools],
@@ -31,6 +33,11 @@ AC_PROG_MKDIR_P
VKD3D_PROG_WIDL(3, 21)
AS_IF([test "x$WIDL" = "xno"], [AC_MSG_WARN([widl is required to build header files.])])
AC_CHECK_PROGS([PERL], [perl], [none])
AS_IF([test "$PERL" = "none"], [AC_MSG_ERROR([no suitable perl found. Please install the 'perl-base' package.])])
VKD3D_CHECK_PERL_MODULE([JSON],
[AC_MSG_ERROR([perl module 'JSON' not found. Please install the 'libjson-perl' package.])])
AC_CHECK_PROGS([FLEX], [flex], [none])
AS_IF([test "$FLEX" = "none"], [AC_MSG_ERROR([no suitable flex found. Please install the 'flex' package.])])
AC_ARG_VAR([LFLAGS], [extra flags for flex])
@@ -134,6 +141,16 @@ 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_metal" != "xno"],
[AC_MSG_CHECKING([for Metal])]
[AC_PREPROC_IFELSE([AC_LANG_PROGRAM([#include <Metal/Metal.h>])],
[AC_MSG_RESULT([yes])
AC_PROG_OBJC
AC_DEFINE([HAVE_METAL], [1], [Define to 1 if you have Metal.])
with_metal=yes],
[AC_MSG_RESULT([no])
AM_CONDITIONAL([am__fastdepOBJC], [false])
with_metal=no])])
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],
@@ -162,25 +179,32 @@ VKD3D_CHECK_FUNC([HAVE_SYNC_ADD_AND_FETCH], [__sync_add_and_fetch], [__sync_add_
VKD3D_CHECK_FUNC([HAVE_SYNC_BOOL_COMPARE_AND_SWAP], [__sync_bool_compare_and_swap], [__sync_bool_compare_and_swap((int *)0, 0, 0)])
VKD3D_CHECK_FUNC([HAVE_ATOMIC_EXCHANGE_N], [__atomic_exchange_n], [__atomic_exchange_n((int *)0, 0, 0)])
AC_CHECK_FUNCS([gettid])
AC_CHECK_FUNCS([pthread_threadid_np])
dnl Makefiles
case $host_os in
mingw32*)
AC_SUBST([DEMO_LIBS],["-ld3d12 -ldxgi -lgdi32"])
AC_SUBST([DEMO_LIBS],["-lgdi32"])
AC_SUBST([DEMO_CFLAGS],["-municode"])
;;
darwin*)
AC_SUBST([DEMO_LIBS],["-framework Foundation -framework AppKit -framework QuartzCore"])
AC_SUBST([DEMO_CFLAGS],[""])
;;
*) AS_IF([test "x$enable_demos" = "xyes" -a "x$HAVE_XCB" != "xyes"],
[AC_MSG_ERROR([libxcb is required for demos.])])
AC_SUBST([DEMO_LIBS],[$XCB_LIBS])
AC_SUBST([DEMO_CFLAGS],[$XCB_CFLAGS])
;;
esac
VKD3D_CHECK_CFLAGS([-fno-lto], [DEMO_CFLAGS="$DEMO_CFLAGS -fno-lto"])
AM_CONDITIONAL([BUILD_DEMOS], [test "x$enable_demos" = "xyes"])
AM_CONDITIONAL([BUILD_DOC], [test $DX_FLAG_doc = 1])
AM_CONDITIONAL([BUILD_TESTS], [test "x$enable_tests" != "xno"])
AM_CONDITIONAL([HAVE_WIDL], [test "x$WIDL" != "xno"])
AM_CONDITIONAL([HAVE_CROSSTARGET32], [test "x$CROSSTARGET32" != "xno"])
AM_CONDITIONAL([HAVE_CROSSTARGET64], [test "x$CROSSTARGET64" != "xno"])
AM_CONDITIONAL([HAVE_METAL], [test "${host_os#darwin}" != "$host_os"])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
@@ -197,11 +221,12 @@ AS_ECHO(["
widl: ${WIDL}
Have dxcompiler: ${HAVE_DXCOMPILER}
Have Metal: ${with_metal}
Have ncurses: ${with_ncurses}
Have OpenGL: ${with_opengl}
Have SPIRV-Tools: ${with_spirv_tools}
Have xcb: ${HAVE_XCB}
Have dxcompiler: ${HAVE_DXCOMPILER}
Building demos: ${enable_demos}
Building tests: ${enable_tests}

View File

@@ -38,15 +38,69 @@
#define COBJMACROS
#include <vkd3d_d3d12.h>
#include <inttypes.h>
#include <math.h>
#ifdef __WIN32__
#define DEMO_ASM_PUSHSECTION ".section rdata\n\t"
#define DEMO_ASM_POPSECTION ".text\n\t"
#define DEMO_ASM_OBJECT_TYPE(name)
#elif defined(__APPLE__)
#define DEMO_ASM_PUSHSECTION ".pushsection __TEXT,__const\n\t"
#define DEMO_ASM_POPSECTION ".popsection\n\t"
#define DEMO_ASM_OBJECT_TYPE(name)
#else
#define DEMO_ASM_PUSHSECTION ".pushsection .rodata\n\t"
#define DEMO_ASM_POPSECTION ".popsection\n\t"
#define DEMO_ASM_OBJECT_TYPE(name) ".type "name", @object\n\t"
#endif
#if (defined(__WIN32__) && defined(__i386__)) || defined(__APPLE__)
#define DEMO_ASM_NAME(name) "_"#name
#else
#define DEMO_ASM_NAME(name) #name
#endif
#define DEMO_EMBED_ASM(name, file) \
DEMO_ASM_PUSHSECTION \
".global "name"\n\t" \
DEMO_ASM_OBJECT_TYPE(name) \
".balign 8\n\t" \
name":\n\t" \
".incbin \""file"\"\n\t" \
name"_end:\n\t" \
".global "name"_size\n\t" \
DEMO_ASM_OBJECT_TYPE(name"_size") \
".balign 8\n\t" \
name"_size:\n\t" \
".int "name"_end - "name"\n\t" \
DEMO_ASM_POPSECTION
#define DEMO_EMBED(name, file) \
extern const unsigned int name##_size; \
extern const uint8_t name[]; \
__asm__(DEMO_EMBED_ASM(DEMO_ASM_NAME(name), file))
#if defined(__GNUC__) || defined(__clang__)
# ifdef __MINGW_PRINTF_FORMAT
# define DEMO_PRINTF_FUNC(fmt, args) __attribute__((format(__MINGW_PRINTF_FORMAT, fmt, args)))
# else
# define DEMO_PRINTF_FUNC(fmt, args) __attribute__((format(printf, fmt, args)))
# endif
#else
# define DEMO_PRINTF_FUNC(fmt, args)
#endif
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*x))
#define DEMO_KEY_UNKNOWN 0x0000
#define DEMO_KEY_ESCAPE 0xff1b
#define DEMO_KEY_LEFT 0xff51
#define DEMO_KEY_UP 0xff52
#define DEMO_KEY_RIGHT 0xff53
#define DEMO_KEY_DOWN 0xff54
#define DEMO_KEY_UNKNOWN 0x0000
#define DEMO_KEY_ESCAPE 0xff1b
#define DEMO_KEY_LEFT 0xff51
#define DEMO_KEY_UP 0xff52
#define DEMO_KEY_RIGHT 0xff53
#define DEMO_KEY_DOWN 0xff54
#define DEMO_KEY_KP_ADD 0xffab
#define DEMO_KEY_KP_SUBTRACT 0xffad
#define DEMO_KEY_F1 0xffbe
struct demo_vec3
{
@@ -58,6 +112,26 @@ struct demo_vec4
float x, y, z, w;
};
struct demo_uvec2
{
uint32_t x, y;
};
struct demo_uvec4
{
uint32_t x, y, z, w;
};
struct demo_matrix
{
float m[4][4];
};
struct demo_patch
{
uint16_t p[4][4];
};
struct demo_swapchain_desc
{
unsigned int width;
@@ -75,6 +149,36 @@ static inline void demo_vec3_set(struct demo_vec3 *v, float x, float y, float z)
v->z = z;
}
static inline void demo_vec3_subtract(struct demo_vec3 *v, const struct demo_vec3 *a, const struct demo_vec3 *b)
{
demo_vec3_set(v, a->x - b->x, a->y - b->y, a->z - b->z);
}
static inline float demo_vec3_dot(const struct demo_vec3 *a, const struct demo_vec3 *b)
{
return a->x * b->x + a->y * b->y + a->z * b->z;
}
static inline float demo_vec3_length(const struct demo_vec3 *v)
{
return sqrtf(demo_vec3_dot(v, v));
}
static inline void demo_vec3_scale(struct demo_vec3 *v, const struct demo_vec3 *a, float s)
{
demo_vec3_set(v, a->x * s, a->y * s, a->z *s);
}
static inline void demo_vec3_normalise(struct demo_vec3 *v, const struct demo_vec3 *a)
{
demo_vec3_scale(v, a, 1.0f / demo_vec3_length(a));
}
static inline void demo_vec3_cross(struct demo_vec3 *v, const struct demo_vec3 *a, const struct demo_vec3 *b)
{
demo_vec3_set(v, a->y * b->z - a->z * b->y, a->z * b->x - a->x * b->z, a->x * b->y - a->y * b->x);
}
static inline void demo_vec4_set(struct demo_vec4 *v, float x, float y, float z, float w)
{
v->x = x;
@@ -83,6 +187,60 @@ static inline void demo_vec4_set(struct demo_vec4 *v, float x, float y, float z,
v->w = w;
}
static inline void demo_matrix_look_at_rh(struct demo_matrix *m, const struct demo_vec3 *eye,
const struct demo_vec3 *ref, const struct demo_vec3 *up)
{
struct demo_vec3 f, s, t, u;
demo_vec3_subtract(&f, eye, ref);
demo_vec3_normalise(&f, &f);
demo_vec3_cross(&s, up, &f);
demo_vec3_normalise(&s, &s);
demo_vec3_cross(&u, &f, &s);
demo_vec3_set(&t, demo_vec3_dot(&s, eye), demo_vec3_dot(&u, eye), demo_vec3_dot(&f, eye));
*m = (struct demo_matrix)
{{
{ s.x, u.x, f.x, 0.0f},
{ s.y, u.y, f.y, 0.0f},
{ s.z, u.z, f.z, 0.0f},
{-t.x, -t.y, -t.z, 1.0f},
}};
}
static inline void demo_matrix_multiply(struct demo_matrix *out,
const struct demo_matrix *a, const struct demo_matrix *b)
{
unsigned int i, j;
for (i = 0; i < 4; ++i)
{
for (j = 0; j < 4; ++j)
{
out->m[i][j] = a->m[i][0] * b->m[0][j]
+ a->m[i][1] * b->m[1][j]
+ a->m[i][2] * b->m[2][j]
+ a->m[i][3] * b->m[3][j];
}
}
}
static inline void demo_matrix_perspective_rh(struct demo_matrix *m, float w, float h, float z_near, float z_far)
{
float sx = 2.0 * z_near / w;
float sy = 2.0 * z_near / h;
float sz = z_far / (z_near - z_far);
float d = z_near * sz;
*m = (struct demo_matrix)
{{
{ sx, 0.0f, 0.0f, 0.0f},
{0.0f, sy, 0.0f, 0.0f},
{0.0f, 0.0f, sz, -1.0f},
{0.0f, 0.0f, d, 0.0f},
}};
}
static inline void demo_rasterizer_desc_init_default(D3D12_RASTERIZER_DESC *desc)
{
desc->FillMode = D3D12_FILL_MODE_SOLID;
@@ -138,9 +296,11 @@ static inline HRESULT demo_create_root_signature(ID3D12Device *device,
return hr;
}
#ifdef _WIN32
#include "demo_win32.h"
#ifdef VKD3D_CROSSTEST
#include "demo_d3d12.h"
#else
#define INFINITE VKD3D_INFINITE
#include "demo_xcb.h"
# ifndef _WIN32
# define INFINITE VKD3D_INFINITE
# endif
#include "demo_vkd3d.h"
#endif

261
demos/demo_d3d12.h Normal file
View File

@@ -0,0 +1,261 @@
/*
* Copyright 2016 Józef Kucia for CodeWeavers
* Copyright 2016 Henri Verbeet 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
*/
#include <vkd3d_dxgi1_4.h>
#include <vkd3d_d3dcompiler.h>
#include <stdbool.h>
#include <stdio.h>
struct demo_win32
{
UINT (*GetDpiForSystem)(void);
};
struct demo
{
union
{
struct demo_win32 win32;
} u;
size_t window_count;
void *user_data;
void (*idle_func)(struct demo *demo, void *user_data);
};
struct demo_window
{
struct demo *demo;
void *user_data;
void (*expose_func)(struct demo_window *window, void *user_data);
void (*key_press_func)(struct demo_window *window, demo_key key, void *user_data);
};
static inline bool demo_window_init(struct demo_window *window, struct demo *demo, void *user_data)
{
window->demo = demo;
window->user_data = user_data;
window->expose_func = NULL;
window->key_press_func = NULL;
++demo->window_count;
return true;
}
static inline void demo_window_cleanup(struct demo_window *window)
{
--window->demo->window_count;
}
#include "demo_win32.h"
struct demo_swapchain
{
IDXGISwapChain3 *swapchain;
unsigned int buffer_count;
char device_name[128];
};
static inline void demo_cleanup(struct demo *demo)
{
demo_win32_cleanup(demo);
}
static inline bool demo_init(struct demo *demo, void *user_data)
{
if (!demo_win32_init(&demo->u.win32))
{
fprintf(stderr, "Failed to initialise demo.\n");
return false;
}
demo->window_count = 0;
demo->user_data = user_data;
demo->idle_func = NULL;
return true;
}
static inline void demo_get_dpi(struct demo *demo, double *dpi_x, double *dpi_y)
{
demo_win32_get_dpi(demo, dpi_x, dpi_y);
}
static inline const char *demo_get_platform_name(void)
{
return "Direct3D 12";
}
static inline void demo_process_events(struct demo *demo)
{
demo_win32_process_events(demo);
}
static inline void demo_set_idle_func(struct demo *demo,
void (*idle_func)(struct demo *demo, void *user_data))
{
demo->idle_func = idle_func;
}
static inline void demo_window_destroy(struct demo_window *window)
{
demo_window_win32_destroy(window);
}
static inline struct demo_window *demo_window_create(struct demo *demo, const char *title,
unsigned int width, unsigned int height, void *user_data)
{
return demo_window_win32_create(demo, title, width, height, user_data);
}
static inline void demo_window_set_expose_func(struct demo_window *window,
void (*expose_func)(struct demo_window *window, void *user_data))
{
window->expose_func = expose_func;
}
static inline void demo_window_set_key_press_func(struct demo_window *window,
void (*key_press_func)(struct demo_window *window, demo_key key, void *user_data))
{
window->key_press_func = key_press_func;
}
static inline struct demo_swapchain *demo_swapchain_create(ID3D12CommandQueue *command_queue,
struct demo_window *window, const struct demo_swapchain_desc *desc)
{
struct demo_window_win32 *window_win32 = CONTAINING_RECORD(window, struct demo_window_win32, w);
DXGI_SWAP_CHAIN_DESC1 swapchain_desc;
struct demo_swapchain *swapchain;
DXGI_ADAPTER_DESC adapter_desc;
IDXGISwapChain1 *swapchain1;
IDXGIFactory2 *factory;
IDXGIAdapter *adapter;
ID3D12Device *device;
unsigned int i;
HRESULT hr;
LUID luid;
if (!(swapchain = malloc(sizeof(*swapchain))))
return NULL;
if (FAILED(CreateDXGIFactory1(&IID_IDXGIFactory2, (void **)&factory)))
goto fail;
if (FAILED(ID3D12CommandQueue_GetDevice(command_queue, &IID_ID3D12Device, (void **)&device)))
goto fail;
luid = ID3D12Device_GetAdapterLuid(device);
ID3D12Device_Release(device);
sprintf(swapchain->device_name, "Unknown");
for (i = 0; IDXGIFactory2_EnumAdapters(factory, i, &adapter) == S_OK; ++i)
{
hr = IDXGIAdapter_GetDesc(adapter, &adapter_desc);
IDXGIAdapter_Release(adapter);
if (FAILED(hr))
continue;
if (adapter_desc.AdapterLuid.LowPart == luid.LowPart
&& adapter_desc.AdapterLuid.HighPart == luid.HighPart)
{
snprintf(swapchain->device_name, ARRAY_SIZE(swapchain->device_name), "%ls", adapter_desc.Description);
break;
}
}
memset(&swapchain_desc, 0, sizeof(swapchain_desc));
swapchain_desc.BufferCount = desc->buffer_count;
swapchain_desc.Width = desc->width;
swapchain_desc.Height = desc->height;
swapchain_desc.Format = desc->format;
swapchain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapchain_desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
swapchain_desc.SampleDesc.Count = 1;
hr = IDXGIFactory2_CreateSwapChainForHwnd(factory, (IUnknown *)command_queue,
window_win32->window, &swapchain_desc, NULL, NULL, &swapchain1);
IDXGIFactory2_Release(factory);
if (FAILED(hr))
goto fail;
swapchain->buffer_count = desc->buffer_count;
hr = IDXGISwapChain1_QueryInterface(swapchain1, &IID_IDXGISwapChain3, (void **)&swapchain->swapchain);
IDXGISwapChain1_Release(swapchain1);
if (FAILED(hr))
goto fail;
return swapchain;
fail:
free(swapchain);
return NULL;
}
static inline const char *demo_swapchain_get_device_name(struct demo_swapchain *swapchain)
{
return swapchain->device_name;
}
static inline unsigned int demo_swapchain_get_current_back_buffer_index(struct demo_swapchain *swapchain)
{
return IDXGISwapChain3_GetCurrentBackBufferIndex(swapchain->swapchain);
}
static inline ID3D12Resource *demo_swapchain_get_back_buffer(struct demo_swapchain *swapchain, unsigned int index)
{
ID3D12Resource *buffer;
if (FAILED(IDXGISwapChain3_GetBuffer(swapchain->swapchain, index,
&IID_ID3D12Resource, (void **)&buffer)))
return NULL;
return buffer;
}
static inline unsigned int demo_swapchain_get_back_buffer_count(struct demo_swapchain *swapchain)
{
return swapchain->buffer_count;
}
static inline void demo_swapchain_present(struct demo_swapchain *swapchain)
{
IDXGISwapChain3_Present(swapchain->swapchain, 1, 0);
}
static inline void demo_swapchain_destroy(struct demo_swapchain *swapchain)
{
IDXGISwapChain3_Release(swapchain->swapchain);
free(swapchain);
}
static inline HANDLE demo_create_event(void)
{
return CreateEventA(NULL, FALSE, FALSE, NULL);
}
static inline unsigned int demo_wait_event(HANDLE event, unsigned int ms)
{
return WaitForSingleObject(event, ms);
}
static inline void demo_destroy_event(HANDLE event)
{
CloseHandle(event);
}

324
demos/demo_macos.h Normal file
View File

@@ -0,0 +1,324 @@
/*
* Copyright 2025 Henri Verbeet
*
* 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
*/
typedef long NSInteger;
typedef unsigned long NSUInteger;
typedef struct NSPoint
{
double x, y;
} NSPoint;
typedef struct NSRect
{
double x, y;
double w, h;
} NSRect;
#define BOOL OBJC_BOOL
#include "private/appkit.h"
#include "private/foundation.h"
#include "private/quartzcore.h"
#undef BOOL
extern const id NSDefaultRunLoopMode;
enum NSBackingStoreType
{
NSBackingStoreBuffered = 2,
};
enum NSEventType
{
NSEventTypeKeyDown = 0xa,
NSEventTypeApplicationDefined = 0xf,
};
enum NSWindowStyleMask
{
NSWindowStyleMaskBorderless = 0x0000,
NSWindowStyleMaskTitled = 0x0001,
NSWindowStyleMaskClosable = 0x0002,
NSWindowStyleMaskMiniaturizable = 0x0004,
NSWindowStyleMaskResizable = 0x0008,
NSWindowStyleMaskUtilityWindow = 0x0010,
NSWindowStyleMaskDocModalWindow = 0x0040,
NSWindowStyleMaskNonactivatingPanel = 0x0080,
NSWindowStyleMaskUnifiedTitleAndToolbar = 0x1000,
NSWindowStyleMaskHUDWindow = 0x2000,
NSWindowStyleMaskFullScreen = 0x4000,
NSWindowStyleMaskFullSizeContentView = 0x8000,
};
enum
{
DemoWindowDestroyed,
};
struct demo_window_macos
{
struct demo_window w;
id window;
id layer;
};
static struct demo_window_macos *demo_macos_find_macos_window(struct demo *demo, id window)
{
size_t i;
for (i = 0; i < demo->window_count; ++i)
{
struct demo_window_macos *window_macos = CONTAINING_RECORD(demo->windows[i], struct demo_window_macos, w);
if (window_macos->window == window)
return window_macos;
}
return NULL;
}
static VkSurfaceKHR demo_window_macos_create_vk_surface(struct demo_window *window, VkInstance vk_instance)
{
struct demo_window_macos *window_macos = CONTAINING_RECORD(window, struct demo_window_macos, w);
struct VkMetalSurfaceCreateInfoEXT surface_desc;
VkSurfaceKHR vk_surface;
id l, v;
l = window_macos->layer = CAMetalLayer_layer();
CAMetalLayer_setContentsScale(l, NSScreen_backingScaleFactor(NSScreen_mainScreen()));
v = NSWindow_contentView(window_macos->window);
NSView_setLayer(v, l);
NSView_setWantsLayer(v, true);
surface_desc.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT;
surface_desc.pNext = NULL;
surface_desc.flags = 0;
surface_desc.pLayer = l;
if (vkCreateMetalSurfaceEXT(vk_instance, &surface_desc, NULL, &vk_surface) < 0)
return VK_NULL_HANDLE;
return vk_surface;
}
static void demo_window_macos_destroy(struct demo_window *window)
{
struct demo_window_macos *window_macos = CONTAINING_RECORD(window, struct demo_window_macos, w);
NSWindow_close(window_macos->window);
}
static void demo_window_macos_destroyed(struct demo_window_macos *window_macos)
{
CAMetalLayer_release(window_macos->layer);
NSWindow_release(window_macos->window);
demo_window_cleanup(&window_macos->w);
free(window_macos);
}
static struct demo_window *demo_window_macos_create(struct demo *demo,
const char *title, unsigned int width, unsigned int height, void *user_data)
{
unsigned long style = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable;
struct demo_window_macos *window_macos;
NSRect r = {0, 0, width, height};
double scale;
id w, s;
if (!(window_macos = malloc(sizeof(*window_macos))))
return NULL;
if (!demo_window_init(&window_macos->w, demo, user_data,
demo_window_macos_create_vk_surface, demo_window_macos_destroy))
{
free(window_macos);
return NULL;
}
s = NSScreen_mainScreen();
scale = NSScreen_backingScaleFactor(s);
r.w /= scale;
r.h /= scale;
w = window_macos->window = class_createInstance(objc_getClass("DemoWindow"), 0);
NSWindow_initWithContentRect(w, r, style, NSBackingStoreBuffered, true, s);
NSWindow_setReleasedWhenClosed(w, false);
NSWindow_setDelegate(w, w);
NSWindow_center(w);
NSWindow_setTitle(w, NSString_stringWithUTF8String(title));
NSWindow_makeKeyAndOrderFront(w, nil);
window_macos->layer = nil;
return &window_macos->w;
}
static void demo_macos_get_dpi(struct demo *demo, double *dpi_x, double *dpi_y)
{
*dpi_x = *dpi_y = 96.0 * NSScreen_backingScaleFactor(NSScreen_mainScreen());
}
static demo_key demo_key_from_nsevent(id event)
{
enum vkey
{
kVK_ANSI_A = 0x00,
kVK_ANSI_F = 0x03,
kVK_ANSI_W = 0x0d,
kVK_ANSI_Equal = 0x18,
kVK_ANSI_Minus = 0x1b,
kVK_Escape = 0x35,
kVK_ANSI_KeypadPlus = 0x45,
kVK_ANSI_KeypadMinus = 0x4e,
kVK_F1 = 0x7a,
kVK_LeftArrow = 0x7b,
kVK_RightArrow = 0x7c,
kVK_DownArrow = 0x7d,
kVK_UpArrow = 0x7e,
} vkey;
size_t i;
static const struct
{
enum vkey vkey;
demo_key demo_key;
}
lookup[] =
{
{kVK_ANSI_A, 'a'},
{kVK_ANSI_F, 'f'},
{kVK_ANSI_W, 'w'},
{kVK_ANSI_Equal, '='},
{kVK_ANSI_Minus, '-'},
{kVK_Escape, DEMO_KEY_ESCAPE},
{kVK_ANSI_KeypadPlus, DEMO_KEY_KP_ADD},
{kVK_ANSI_KeypadMinus, DEMO_KEY_KP_SUBTRACT},
{kVK_F1, DEMO_KEY_F1},
{kVK_LeftArrow, DEMO_KEY_LEFT},
{kVK_RightArrow, DEMO_KEY_RIGHT},
{kVK_DownArrow, DEMO_KEY_DOWN},
{kVK_UpArrow, DEMO_KEY_UP},
};
vkey = NSEvent_keyCode(event);
for (i = 0; i < ARRAY_SIZE(lookup); ++i)
{
if (lookup[i].vkey == vkey)
return lookup[i].demo_key;
}
return DEMO_KEY_UNKNOWN;
}
static void demo_macos_process_events(struct demo *demo)
{
struct demo_window_macos *window_macos;
struct demo_window *window;
id a, event;
size_t i;
for (i = 0; i < demo->window_count; ++i)
{
if ((window = demo->windows[i])->expose_func)
window->expose_func(window, window->user_data);
}
a = NSApplication_sharedApplication();
while (demo->window_count)
{
if (!demo->idle_func)
{
if (!(event = NSApplication_nextEventMatchingMask(a, ~(uint64_t)0,
NSDate_distantFuture(), NSDefaultRunLoopMode, true)))
break;
}
else if (!(event = NSApplication_nextEventMatchingMask(a, ~(uint64_t)0, nil, NSDefaultRunLoopMode, true)))
{
demo->idle_func(demo, demo->user_data);
continue;
}
switch (NSEvent_type(event))
{
case NSEventTypeKeyDown:
if (NSMenu_performKeyEquivalent(NSApplication_mainMenu(a), event))
continue;
if (!(window_macos = demo_macos_find_macos_window(demo, NSEvent_window(event)))
|| !window_macos->w.key_press_func)
break;
window_macos->w.key_press_func(&window_macos->w,
demo_key_from_nsevent(event), window_macos->w.user_data);
continue;
case NSEventTypeApplicationDefined:
if (NSEvent_subtype(event) != DemoWindowDestroyed
|| !(window_macos = demo_macos_find_macos_window(demo, NSEvent_window(event))))
break;
demo_window_macos_destroyed(window_macos);
continue;
}
NSApplication_sendEvent(a, event);
}
}
static void DemoWindow_windowWillClose(id window, SEL sel, id notification)
{
id event;
event = NSEvent_otherEventWithType(NSEventTypeApplicationDefined, (NSPoint){0.0, 0.0},
0, 0.0, NSWindow_windowNumber(window), nil, DemoWindowDestroyed, 0, 0);
NSApplication_postEvent(NSApplication_sharedApplication(), event, true);
}
static void demo_macos_cleanup(struct demo *demo)
{
}
static bool demo_macos_init(struct demo_macos *macos)
{
id application, item, menu, submenu;
Class c;
if ((c = objc_allocateClassPair(objc_getClass("NSWindow"), "DemoWindow", 0)))
{
class_addMethod(c, sel_registerName("windowWillClose:"), (IMP)DemoWindow_windowWillClose, "v@:@");
objc_registerClassPair(c);
}
application = NSApplication_sharedApplication();
NSApplication_setActivationPolicy(application, 0);
menu = NSMenu_new();
submenu = NSMenu_new();
NSMenu_addItemWithTitle(submenu, NSString_stringWithUTF8String("Quit"),
sel_registerName("terminate:"), NSString_stringWithUTF8String("q"));
item = NSMenuItem_new();
NSMenuItem_setSubmenu(item, submenu);
NSMenu_release(submenu);
NSMenu_addItem(menu, item);
NSMenuItem_release(item);
NSApplication_setMainMenu(application, menu);
NSMenu_release(menu);
NSApplication_finishLaunching(application);
return true;
}

640
demos/demo_vkd3d.h Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -17,85 +17,108 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <vkd3d_dxgi1_4.h>
#include <vkd3d_d3dcompiler.h>
#include <stdbool.h>
#include <stdio.h>
#define DEMO_WIN32_WINDOW_CLASS_NAME L"demo_wc"
#define DEMO_WINDOW_CLASS_NAME L"demo_wc"
struct demo
struct demo_window_win32
{
size_t window_count;
bool quit;
struct demo_window w;
void *user_data;
void (*idle_func)(struct demo *demo, void *user_data);
};
struct demo_window
{
HINSTANCE instance;
HWND hwnd;
struct demo *demo;
void *user_data;
void (*expose_func)(struct demo_window *window, void *user_data);
void (*key_press_func)(struct demo_window *window, demo_key key, void *user_data);
HWND window;
};
struct demo_swapchain
#ifndef VKD3D_CROSSTEST
static VkSurfaceKHR demo_window_win32_create_vk_surface(struct demo_window *window, VkInstance vk_instance)
{
IDXGISwapChain3 *swapchain;
};
struct demo_window_win32 *window_win32 = CONTAINING_RECORD(window, struct demo_window_win32, w);
struct VkWin32SurfaceCreateInfoKHR surface_desc;
VkSurfaceKHR vk_surface;
static inline struct demo_window *demo_window_create(struct demo *demo, const char *title,
surface_desc.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
surface_desc.pNext = NULL;
surface_desc.flags = 0;
surface_desc.hinstance = window_win32->instance;
surface_desc.hwnd = window_win32->window;
if (vkCreateWin32SurfaceKHR(vk_instance, &surface_desc, NULL, &vk_surface) < 0)
return VK_NULL_HANDLE;
return vk_surface;
}
#endif
static void demo_window_win32_destroy(struct demo_window *window)
{
struct demo_window_win32 *window_win32 = CONTAINING_RECORD(window, struct demo_window_win32, w);
DestroyWindow(window_win32->window);
}
static void demo_window_win32_destroyed(struct demo_window *window)
{
struct demo_window_win32 *window_win32 = CONTAINING_RECORD(window, struct demo_window_win32, w);
demo_window_cleanup(&window_win32->w);
free(window_win32);
}
static struct demo_window *demo_window_win32_create(struct demo *demo, const char *title,
unsigned int width, unsigned int height, void *user_data)
{
struct demo_window_win32 *window_win32;
RECT rect = {0, 0, width, height};
struct demo_window *window;
int title_size;
WCHAR *title_w;
DWORD style;
if (!(window = malloc(sizeof(*window))))
if (!(window_win32 = malloc(sizeof(*window_win32))))
return NULL;
#ifdef VKD3D_CROSSTEST
if (!demo_window_init(&window_win32->w, demo, user_data))
#else
if (!demo_window_init(&window_win32->w, demo, user_data,
demo_window_win32_create_vk_surface, demo_window_win32_destroy))
#endif
{
free(window_win32);
return NULL;
}
title_size = MultiByteToWideChar(CP_UTF8, 0, title, -1, NULL, 0);
if (!(title_w = calloc(title_size, sizeof(*title_w))))
{
free(window);
demo_window_cleanup(&window_win32->w);
free(window_win32);
return NULL;
}
MultiByteToWideChar(CP_UTF8, 0, title, -1, title_w, title_size);
window->instance = GetModuleHandle(NULL);
window->user_data = user_data;
window->expose_func = NULL;
window->key_press_func = NULL;
window_win32->instance = GetModuleHandle(NULL);
style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_VISIBLE;
AdjustWindowRect(&rect, style, FALSE);
window->hwnd = CreateWindowExW(0, DEMO_WINDOW_CLASS_NAME, title_w, style, CW_USEDEFAULT, CW_USEDEFAULT,
rect.right - rect.left, rect.bottom - rect.top, NULL, NULL, window->instance, NULL);
window_win32->window = CreateWindowExW(0, DEMO_WIN32_WINDOW_CLASS_NAME, title_w, style, CW_USEDEFAULT,
CW_USEDEFAULT, rect.right - rect.left, rect.bottom - rect.top, NULL, NULL, window_win32->instance, NULL);
free(title_w);
if (!window->hwnd)
if (!window_win32->window)
{
free(window);
demo_window_cleanup(&window_win32->w);
free(window_win32);
return NULL;
}
SetWindowLongPtrW(window->hwnd, GWLP_USERDATA, (LONG_PTR)window);
window->demo = demo;
++demo->window_count;
SetWindowLongPtrW(window_win32->window, GWLP_USERDATA, (LONG_PTR)window_win32);
return window;
return &window_win32->w;
}
static inline void demo_window_destroy(struct demo_window *window)
static void demo_win32_get_dpi(struct demo *demo, double *dpi_x, double *dpi_y)
{
DestroyWindow(window->hwnd);
struct demo_win32 *win32 = &demo->u.win32;
*dpi_x = *dpi_y = win32->GetDpiForSystem();
}
static inline demo_key demo_key_from_vkey(DWORD vkey)
static demo_key demo_key_from_win32_vkey(DWORD vkey)
{
static const struct
{
@@ -104,18 +127,23 @@ static inline demo_key demo_key_from_vkey(DWORD vkey)
}
lookup[] =
{
{VK_ESCAPE, DEMO_KEY_ESCAPE},
{VK_LEFT, DEMO_KEY_LEFT},
{VK_RIGHT, DEMO_KEY_RIGHT},
{VK_UP, DEMO_KEY_UP},
{VK_DOWN, DEMO_KEY_DOWN},
{VK_OEM_MINUS, '-'},
{VK_OEM_PLUS, '='},
{VK_ESCAPE, DEMO_KEY_ESCAPE},
{VK_LEFT, DEMO_KEY_LEFT},
{VK_UP, DEMO_KEY_UP},
{VK_RIGHT, DEMO_KEY_RIGHT},
{VK_DOWN, DEMO_KEY_DOWN},
{VK_ADD, DEMO_KEY_KP_ADD},
{VK_SUBTRACT, DEMO_KEY_KP_SUBTRACT},
{VK_F1, DEMO_KEY_F1},
};
unsigned int i;
if (vkey >= '0' && vkey <= '9')
return vkey;
if (vkey >= 'A' && vkey <= 'Z')
return vkey;
return vkey + 0x20;
for (i = 0; i < ARRAY_SIZE(lookup); ++i)
{
@@ -126,46 +154,33 @@ static inline demo_key demo_key_from_vkey(DWORD vkey)
return DEMO_KEY_UNKNOWN;
}
static inline LRESULT CALLBACK demo_window_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
static LRESULT CALLBACK demo_win32_window_proc(HWND window, UINT message, WPARAM wparam, LPARAM lparam)
{
struct demo_window *window = (void *)GetWindowLongPtrW(hwnd, GWLP_USERDATA);
struct demo_window_win32 *window_win32 = (void *)GetWindowLongPtrW(window, GWLP_USERDATA);
switch (message)
{
case WM_PAINT:
if (window && window->expose_func)
window->expose_func(window, window->user_data);
if (window_win32 && window_win32->w.expose_func)
window_win32->w.expose_func(&window_win32->w, window_win32->w.user_data);
return 0;
case WM_KEYDOWN:
if (!window->key_press_func)
if (!window_win32->w.key_press_func)
break;
window->key_press_func(window, demo_key_from_vkey(wparam), window->user_data);
window_win32->w.key_press_func(&window_win32->w,
demo_key_from_win32_vkey(wparam), window_win32->w.user_data);
return 0;
case WM_DESTROY:
if (!--window->demo->window_count)
window->demo->quit = true;
free(window);
demo_window_win32_destroyed(&window_win32->w);
return 0;
}
return DefWindowProcW(hwnd, message, wparam, lparam);
return DefWindowProcW(window, message, wparam, lparam);
}
static inline void demo_window_set_key_press_func(struct demo_window *window,
void (*key_press_func)(struct demo_window *window, demo_key key, void *user_data))
{
window->key_press_func = key_press_func;
}
static inline void demo_window_set_expose_func(struct demo_window *window,
void (*expose_func)(struct demo_window *window, void *user_data))
{
window->expose_func = expose_func;
}
static inline void demo_process_events(struct demo *demo)
static void demo_win32_process_events(struct demo *demo)
{
MSG msg = {0};
@@ -186,18 +201,28 @@ static inline void demo_process_events(struct demo *demo)
break;
TranslateMessage(&msg);
DispatchMessageW(&msg);
if (demo->quit)
if (!demo->window_count)
PostQuitMessage(0);
}
}
static inline bool demo_init(struct demo *demo, void *user_data)
static void demo_win32_cleanup(struct demo *demo)
{
UnregisterClassW(DEMO_WIN32_WINDOW_CLASS_NAME, GetModuleHandle(NULL));
}
static inline UINT demo_win32_GetDpiForSystem(void)
{
return 96;
}
static bool demo_win32_init(struct demo_win32 *win32)
{
WNDCLASSEXW wc;
wc.cbSize = sizeof(wc);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = demo_window_proc;
wc.lpfnWndProc = demo_win32_window_proc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = GetModuleHandle(NULL);
@@ -205,110 +230,15 @@ static inline bool demo_init(struct demo *demo, void *user_data)
wc.hCursor = LoadCursorW(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = DEMO_WINDOW_CLASS_NAME;
wc.lpszClassName = DEMO_WIN32_WINDOW_CLASS_NAME;
wc.hIconSm = LoadIconW(NULL, IDI_WINLOGO);
if (!RegisterClassExW(&wc))
return false;
demo->window_count = 0;
demo->quit = false;
demo->user_data = user_data;
demo->idle_func = NULL;
if ((win32->GetDpiForSystem = (void *)GetProcAddress(GetModuleHandleA("user32"), "GetDpiForSystem")))
SetProcessDPIAware();
else
win32->GetDpiForSystem = demo_win32_GetDpiForSystem;
return true;
}
static inline void demo_cleanup(struct demo *demo)
{
UnregisterClassW(DEMO_WINDOW_CLASS_NAME, GetModuleHandle(NULL));
}
static inline void demo_set_idle_func(struct demo *demo,
void (*idle_func)(struct demo *demo, void *user_data))
{
demo->idle_func = idle_func;
}
static inline struct demo_swapchain *demo_swapchain_create(ID3D12CommandQueue *command_queue,
struct demo_window *window, const struct demo_swapchain_desc *desc)
{
DXGI_SWAP_CHAIN_DESC1 swapchain_desc;
struct demo_swapchain *swapchain;
IDXGISwapChain1 *swapchain1;
IDXGIFactory2 *factory;
HRESULT hr;
if (!(swapchain = malloc(sizeof(*swapchain))))
return NULL;
if (FAILED(CreateDXGIFactory1(&IID_IDXGIFactory2, (void **)&factory)))
goto fail;
memset(&swapchain_desc, 0, sizeof(swapchain_desc));
swapchain_desc.BufferCount = desc->buffer_count;
swapchain_desc.Width = desc->width;
swapchain_desc.Height = desc->height;
swapchain_desc.Format = desc->format;
swapchain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapchain_desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
swapchain_desc.SampleDesc.Count = 1;
hr = IDXGIFactory2_CreateSwapChainForHwnd(factory, (IUnknown *)command_queue,
window->hwnd, &swapchain_desc, NULL, NULL, &swapchain1);
IDXGIFactory2_Release(factory);
if (FAILED(hr))
goto fail;
hr = IDXGISwapChain1_QueryInterface(swapchain1, &IID_IDXGISwapChain3, (void **)&swapchain->swapchain);
IDXGISwapChain1_Release(swapchain1);
if (FAILED(hr))
goto fail;
return swapchain;
fail:
free(swapchain);
return NULL;
}
static inline unsigned int demo_swapchain_get_current_back_buffer_index(struct demo_swapchain *swapchain)
{
return IDXGISwapChain3_GetCurrentBackBufferIndex(swapchain->swapchain);
}
static inline ID3D12Resource *demo_swapchain_get_back_buffer(struct demo_swapchain *swapchain, unsigned int index)
{
ID3D12Resource *buffer;
if (FAILED(IDXGISwapChain3_GetBuffer(swapchain->swapchain, index,
&IID_ID3D12Resource, (void **)&buffer)))
return NULL;
return buffer;
}
static inline void demo_swapchain_present(struct demo_swapchain *swapchain)
{
IDXGISwapChain3_Present(swapchain->swapchain, 1, 0);
}
static inline void demo_swapchain_destroy(struct demo_swapchain *swapchain)
{
IDXGISwapChain3_Release(swapchain->swapchain);
free(swapchain);
}
static inline HANDLE demo_create_event(void)
{
return CreateEventA(NULL, FALSE, FALSE, NULL);
}
static inline unsigned int demo_wait_event(HANDLE event, unsigned int ms)
{
return WaitForSingleObject(event, ms);
}
static inline void demo_destroy_event(HANDLE event)
{
CloseHandle(event);
}

File diff suppressed because it is too large Load Diff

145
demos/etl16-unicode.h Normal file
View File

@@ -0,0 +1,145 @@
/*
* Copyright 2025 Henri Verbeet
*
* 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
*/
/* The glyph data is derived from etl16-unicode.bdf as found on
* ftp://ftp.ring.gr.jp/pub/X/opengroup/contrib/fonts/etl-unicode.tar.gz
* with the following license:
*
* Public domain font. Share and enjoy.
*/
/* Each line in etl16_unicode[] below contains the bitmap data for a single
* 8x16 glyph, starting at ASCII 0x20 (space). Each byte corresponds to a
* single line in the glyph.
*
* The BDF bitmap data is essentially the same format we're using here, so we
* could have extracted the glyphs manually, or perhaps using a small script.
* However, bdf2psf can do most of the work for us, by creating a PSF1 font
* from the BDF.
*
* A PSF1 font has a 4 byte header, followed by at least 256 glyphs.
* For a 8x16 font, each glyph consists of 16 bytes, one byte for each row.
*
* We're not interested in control characters or extended ASCII, so we skip
* the first 0x4 (header) + 0x20 (control characters) * 0x10 = 516 bytes, and
* extract the next (0x80 - 0x20) * 0x10 = 1536 bytes:
*
* bdf2psf etl16-unicode.bdf standard.equivalents ascii.set 256 /dev/stdout | xxd -i -c 16 -s 516 -l 1536
*
* and we're done.
*/
static const uint8_t etl16_unicode[] =
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x08, 0x08, 0x00, 0x00,
0x00, 0x00, 0x66, 0x22, 0x22, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x12, 0x12, 0x12, 0x7e, 0x24, 0x24, 0x7e, 0x48, 0x48, 0x48, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x08, 0x3e, 0x49, 0x48, 0x38, 0x0e, 0x09, 0x49, 0x3e, 0x08, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x31, 0x4a, 0x4a, 0x34, 0x08, 0x08, 0x16, 0x29, 0x29, 0x46, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x1c, 0x22, 0x22, 0x22, 0x1c, 0x39, 0x45, 0x42, 0x46, 0x39, 0x00, 0x00,
0x00, 0x00, 0x18, 0x08, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x04, 0x08, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x08, 0x04, 0x00,
0x00, 0x00, 0x00, 0x20, 0x10, 0x10, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x10, 0x10, 0x20, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x49, 0x2a, 0x1c, 0x2a, 0x49, 0x08, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x7f, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x08, 0x08, 0x10,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x04, 0x08, 0x08, 0x10, 0x10, 0x20, 0x40, 0x40, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x18, 0x24, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x24, 0x18, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x08, 0x18, 0x28, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3e, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x42, 0x02, 0x0c, 0x10, 0x20, 0x40, 0x40, 0x7e, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x42, 0x02, 0x1c, 0x02, 0x02, 0x42, 0x42, 0x3c, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x04, 0x0c, 0x14, 0x24, 0x44, 0x44, 0x7e, 0x04, 0x04, 0x04, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x7e, 0x40, 0x40, 0x40, 0x7c, 0x02, 0x02, 0x02, 0x42, 0x3c, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x1c, 0x20, 0x40, 0x40, 0x7c, 0x42, 0x42, 0x42, 0x42, 0x3c, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x7e, 0x02, 0x02, 0x04, 0x04, 0x04, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x42, 0x42, 0x3c, 0x42, 0x42, 0x42, 0x42, 0x3c, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x42, 0x42, 0x3e, 0x02, 0x02, 0x02, 0x04, 0x38, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x08, 0x08, 0x10, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x20, 0x10, 0x08, 0x04, 0x08, 0x10, 0x20, 0x40, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x42, 0x02, 0x04, 0x08, 0x08, 0x00, 0x08, 0x08, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x1c, 0x22, 0x4a, 0x56, 0x52, 0x52, 0x52, 0x4e, 0x20, 0x1e, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x18, 0x24, 0x24, 0x42, 0x42, 0x7e, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x7c, 0x42, 0x42, 0x42, 0x7c, 0x42, 0x42, 0x42, 0x42, 0x7c, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x42, 0x40, 0x40, 0x40, 0x40, 0x42, 0x42, 0x3c, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x78, 0x44, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x44, 0x78, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x7e, 0x40, 0x40, 0x40, 0x7c, 0x40, 0x40, 0x40, 0x40, 0x7e, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x7e, 0x40, 0x40, 0x40, 0x7c, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x42, 0x40, 0x40, 0x4e, 0x42, 0x42, 0x46, 0x3a, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x7e, 0x42, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3e, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3e, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x1f, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x44, 0x44, 0x38, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x42, 0x44, 0x48, 0x50, 0x60, 0x60, 0x50, 0x48, 0x44, 0x42, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7e, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x66, 0x66, 0x5a, 0x5a, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x42, 0x62, 0x62, 0x52, 0x52, 0x4a, 0x4a, 0x46, 0x46, 0x42, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3c, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x7c, 0x42, 0x42, 0x42, 0x7c, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x5a, 0x66, 0x3c, 0x03, 0x00,
0x00, 0x00, 0x00, 0x00, 0x7c, 0x42, 0x42, 0x42, 0x7c, 0x48, 0x44, 0x44, 0x42, 0x42, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x42, 0x40, 0x30, 0x0c, 0x02, 0x42, 0x42, 0x3c, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x7f, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3c, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x41, 0x41, 0x41, 0x22, 0x22, 0x22, 0x14, 0x14, 0x08, 0x08, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x5a, 0x5a, 0x66, 0x66, 0x42, 0x42, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x24, 0x24, 0x18, 0x18, 0x24, 0x24, 0x42, 0x42, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x41, 0x41, 0x22, 0x22, 0x14, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x7e, 0x02, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x40, 0x7e, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0e, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x0e, 0x00,
0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x20, 0x10, 0x10, 0x08, 0x08, 0x04, 0x02, 0x02, 0x00, 0x00,
0x00, 0x00, 0x00, 0x70, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x70, 0x00,
0x00, 0x00, 0x18, 0x24, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00,
0x00, 0x00, 0x18, 0x10, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x02, 0x3e, 0x42, 0x42, 0x46, 0x3a, 0x00, 0x00,
0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x5c, 0x62, 0x42, 0x42, 0x42, 0x42, 0x62, 0x5c, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x40, 0x40, 0x40, 0x40, 0x42, 0x3c, 0x00, 0x00,
0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x3a, 0x46, 0x42, 0x42, 0x42, 0x42, 0x46, 0x3a, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x42, 0x7e, 0x40, 0x40, 0x42, 0x3c, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0c, 0x10, 0x10, 0x10, 0x7c, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x3a, 0x44, 0x44, 0x44, 0x38, 0x20, 0x3c, 0x42, 0x42, 0x3c,
0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x5c, 0x62, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00,
0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x18, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3e, 0x00, 0x00,
0x00, 0x00, 0x00, 0x04, 0x04, 0x00, 0x0c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x48, 0x30,
0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x44, 0x48, 0x50, 0x60, 0x50, 0x48, 0x44, 0x42, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x18, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3e, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5c, 0x62, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3c, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5c, 0x62, 0x42, 0x42, 0x42, 0x42, 0x62, 0x5c, 0x40, 0x40,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3a, 0x46, 0x42, 0x42, 0x42, 0x42, 0x46, 0x3a, 0x02, 0x02,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5c, 0x62, 0x42, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x40, 0x30, 0x0c, 0x02, 0x42, 0x3c, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x7c, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x0c, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x46, 0x3a, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x24, 0x24, 0x24, 0x18, 0x18, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x36, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x42, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x26, 0x1a, 0x02, 0x02, 0x3c,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x7e, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0c, 0x10, 0x10, 0x08, 0x08, 0x10, 0x10, 0x08, 0x08, 0x10, 0x10, 0x0c, 0x00,
0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
0x00, 0x00, 0x00, 0x30, 0x08, 0x08, 0x10, 0x10, 0x08, 0x08, 0x10, 0x10, 0x08, 0x08, 0x30, 0x00,
0x00, 0x00, 0x00, 0x31, 0x49, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xfc, 0x1b, 0x26, 0xef, 0xc8, 0xe0, 0x43, 0x20, 0x89, 0x58, 0x62, 0x5e, 0x79, 0xba, 0xee, 0x7e,
};

View File

@@ -45,10 +45,9 @@
#include <sys/time.h>
#include <assert.h>
#include <stdio.h>
#include <math.h>
#include "demo.h"
#include "gears_hlsl.h"
DEMO_EMBED(gears_hlsl, "gears.hlsl");
struct cxg_fence
{
@@ -59,7 +58,7 @@ struct cxg_fence
struct cxg_cb_data
{
float mvp_matrix[16];
struct demo_matrix mvp_matrix;
float normal_matrix[12];
};
@@ -120,14 +119,17 @@ struct cx_gears
ID3D12Device *device;
ID3D12CommandQueue *command_queue;
struct demo_swapchain *swapchain;
struct
{
ID3D12Resource *render_target;
ID3D12CommandAllocator *command_allocator;
ID3D12GraphicsCommandList *command_list;
} *swapchain_images;
ID3D12DescriptorHeap *rtv_heap, *dsv_heap;
unsigned int rtv_descriptor_size;
ID3D12Resource *render_targets[3];
ID3D12CommandAllocator *command_allocator[3];
ID3D12RootSignature *root_signature;
ID3D12PipelineState *pipeline_state_smooth, *pipeline_state_flat;
ID3D12GraphicsCommandList *command_list[3];
ID3D12Resource *ds, *cb, *vb[2], *ib;
D3D12_VERTEX_BUFFER_VIEW vbv[2];
D3D12_INDEX_BUFFER_VIEW ibv;
@@ -142,7 +144,7 @@ struct cx_gears
static void cxg_populate_command_list(struct cx_gears *cxg, unsigned int rt_idx)
{
ID3D12GraphicsCommandList *command_list = cxg->command_list[rt_idx];
ID3D12GraphicsCommandList *command_list = cxg->swapchain_images[rt_idx].command_list;
static const float clear_colour[] = {0.0f, 0.0f, 0.0f, 1.0f};
D3D12_CPU_DESCRIPTOR_HANDLE rtv_handle, dsv_handle;
@@ -150,10 +152,11 @@ static void cxg_populate_command_list(struct cx_gears *cxg, unsigned int rt_idx)
HRESULT hr;
size_t i;
hr = ID3D12CommandAllocator_Reset(cxg->command_allocator[rt_idx]);
hr = ID3D12CommandAllocator_Reset(cxg->swapchain_images[rt_idx].command_allocator);
assert(SUCCEEDED(hr));
hr = ID3D12GraphicsCommandList_Reset(command_list, cxg->command_allocator[rt_idx], cxg->pipeline_state_flat);
hr = ID3D12GraphicsCommandList_Reset(command_list,
cxg->swapchain_images[rt_idx].command_allocator, cxg->pipeline_state_flat);
assert(SUCCEEDED(hr));
ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, cxg->root_signature);
@@ -165,7 +168,7 @@ static void cxg_populate_command_list(struct cx_gears *cxg, unsigned int rt_idx)
barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
barrier.Transition.pResource = cxg->render_targets[rt_idx];
barrier.Transition.pResource = cxg->swapchain_images[rt_idx].render_target;
barrier.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_PRESENT;
barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_RENDER_TARGET;
@@ -226,44 +229,24 @@ static void cxg_wait_for_previous_frame(struct cx_gears *cxg)
static void cxg_update_mvp(struct cx_gears *cxg)
{
struct demo_matrix projection, world;
float s1 = sinf(cxg->theta);
float c1 = cosf(cxg->theta);
float s2 = sinf(cxg->phi);
float c2 = cosf(cxg->phi);
float z_offset = -40.0f;
float z_max = 60.0f;
float z_min = 5.0f;
float sx = z_min;
float sy = z_min * cxg->aspect_ratio;
float sz = -((z_max + z_min) / (z_max - z_min));
float d = (-2.0f * z_max * z_min) / (z_max - z_min);
unsigned int i, j;
float world[] =
{
c1, s2 * s1, c2 * -s1, 0.0f,
0.0f, c2, s2, 0.0f,
s1, -s2 * c1, c2 * c1, 0.0f,
0.0f, 0.0f, z_offset, 1.0f,
};
float projection[] =
{
sx, 0.0f, 0.0f, 0.0f,
0.0f, sy, 0.0f, 0.0f,
0.0f, 0.0f, sz, -1.0f,
0.0f, 0.0f, d, 0.0f,
};
for (i = 0; i < 4; ++i)
{
for (j = 0; j < 4; ++j)
{
cxg->cb_data->mvp_matrix[i * 4 + j] = projection[j] * world[i * 4]
+ projection[j + 4] * world[i * 4 + 1]
+ projection[j + 8] * world[i * 4 + 2]
+ projection[j + 12] * world[i * 4 + 3];
}
}
memcpy(cxg->cb_data->normal_matrix, world, sizeof(cxg->cb_data->normal_matrix));
world = (struct demo_matrix)
{{
{ c1, s2 * s1, c2 * -s1, 0.0f},
{0.0f, c2, s2, 0.0f},
{ s1, -s2 * c1, c2 * c1, 0.0f},
{0.0f, 0.0f, z_offset, 1.0f},
}};
demo_matrix_perspective_rh(&projection, 2.0f, 2.0f / cxg->aspect_ratio, 5.0f, 60.0f);
demo_matrix_multiply(&cxg->cb_data->mvp_matrix, &world, &projection);
memcpy(cxg->cb_data->normal_matrix, &world, sizeof(cxg->cb_data->normal_matrix));
}
static void cxg_render_frame(struct cx_gears *cxg)
@@ -295,7 +278,7 @@ static void cxg_render_frame(struct cx_gears *cxg)
demo_vec4_set(&cxg->instance_data[2].transform, cosf(a), sinf(a), -3.1f, 4.2f);
ID3D12CommandQueue_ExecuteCommandLists(cxg->command_queue, 1,
(ID3D12CommandList **)&cxg->command_list[cxg->rt_idx]);
(ID3D12CommandList **)&cxg->swapchain_images[cxg->rt_idx].command_list);
demo_swapchain_present(cxg->swapchain);
cxg_wait_for_previous_frame(cxg);
}
@@ -304,16 +287,14 @@ static void cxg_destroy_pipeline(struct cx_gears *cxg)
{
unsigned int i;
for (i = 0; i < ARRAY_SIZE(cxg->command_allocator); ++i)
{
ID3D12CommandAllocator_Release(cxg->command_allocator[i]);
}
for (i = 0; i < ARRAY_SIZE(cxg->render_targets); ++i)
{
ID3D12Resource_Release(cxg->render_targets[i]);
}
ID3D12DescriptorHeap_Release(cxg->dsv_heap);
ID3D12DescriptorHeap_Release(cxg->rtv_heap);
for (i = 0; i < demo_swapchain_get_back_buffer_count(cxg->swapchain); ++i)
{
ID3D12CommandAllocator_Release(cxg->swapchain_images[i].command_allocator);
ID3D12Resource_Release(cxg->swapchain_images[i].render_target);
}
free(cxg->swapchain_images);
demo_swapchain_destroy(cxg->swapchain);
ID3D12CommandQueue_Release(cxg->command_queue);
ID3D12Device_Release(cxg->device);
@@ -325,7 +306,7 @@ static void cxg_load_pipeline(struct cx_gears *cxg)
D3D12_CPU_DESCRIPTOR_HANDLE rtv_handle;
D3D12_DESCRIPTOR_HEAP_DESC heap_desc;
D3D12_COMMAND_QUEUE_DESC queue_desc;
unsigned int i;
unsigned int i, rt_count;
HRESULT hr;
hr = D3D12CreateDevice(NULL, D3D_FEATURE_LEVEL_11_0, &IID_ID3D12Device, (void **)&cxg->device);
@@ -338,16 +319,19 @@ static void cxg_load_pipeline(struct cx_gears *cxg)
&IID_ID3D12CommandQueue, (void **)&cxg->command_queue);
assert(SUCCEEDED(hr));
swapchain_desc.buffer_count = ARRAY_SIZE(cxg->render_targets);
swapchain_desc.buffer_count = 3;
swapchain_desc.format = DXGI_FORMAT_B8G8R8A8_UNORM;
swapchain_desc.width = cxg->width;
swapchain_desc.height = cxg->height;
cxg->swapchain = demo_swapchain_create(cxg->command_queue, cxg->window, &swapchain_desc);
assert(cxg->swapchain);
rt_count = demo_swapchain_get_back_buffer_count(cxg->swapchain);
cxg->swapchain_images = calloc(rt_count, sizeof(*cxg->swapchain_images));
assert(cxg->swapchain_images);
cxg->rt_idx = demo_swapchain_get_current_back_buffer_index(cxg->swapchain);
memset(&heap_desc, 0, sizeof(heap_desc));
heap_desc.NumDescriptors = ARRAY_SIZE(cxg->render_targets);
heap_desc.NumDescriptors = rt_count;
heap_desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV;
heap_desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
hr = ID3D12Device_CreateDescriptorHeap(cxg->device, &heap_desc,
@@ -357,10 +341,10 @@ static void cxg_load_pipeline(struct cx_gears *cxg)
cxg->rtv_descriptor_size = ID3D12Device_GetDescriptorHandleIncrementSize(cxg->device,
D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
rtv_handle = ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(cxg->rtv_heap);
for (i = 0; i < ARRAY_SIZE(cxg->render_targets); ++i)
for (i = 0; i < rt_count; ++i)
{
cxg->render_targets[i] = demo_swapchain_get_back_buffer(cxg->swapchain, i);
ID3D12Device_CreateRenderTargetView(cxg->device, cxg->render_targets[i], NULL, rtv_handle);
cxg->swapchain_images[i].render_target = demo_swapchain_get_back_buffer(cxg->swapchain, i);
ID3D12Device_CreateRenderTargetView(cxg->device, cxg->swapchain_images[i].render_target, NULL, rtv_handle);
rtv_handle.ptr += cxg->rtv_descriptor_size;
}
@@ -371,10 +355,10 @@ static void cxg_load_pipeline(struct cx_gears *cxg)
&IID_ID3D12DescriptorHeap, (void **)&cxg->dsv_heap);
assert(SUCCEEDED(hr));
for (i = 0; i < ARRAY_SIZE(cxg->command_allocator); ++i)
for (i = 0; i < rt_count; ++i)
{
hr = ID3D12Device_CreateCommandAllocator(cxg->device, D3D12_COMMAND_LIST_TYPE_DIRECT,
&IID_ID3D12CommandAllocator, (void **)&cxg->command_allocator[i]);
&IID_ID3D12CommandAllocator, (void **)&cxg->swapchain_images[i].command_allocator);
assert(SUCCEEDED(hr));
}
}
@@ -397,8 +381,8 @@ static void cxg_destroy_assets(struct cx_gears *cxg)
ID3D12Resource_Unmap(cxg->cb, 0, NULL);
ID3D12Resource_Release(cxg->cb);
ID3D12Resource_Release(cxg->ds);
for (i = 0; i < ARRAY_SIZE(cxg->command_list); ++i)
ID3D12GraphicsCommandList_Release(cxg->command_list[i]);
for (i = 0; i < demo_swapchain_get_back_buffer_count(cxg->swapchain); ++i)
ID3D12GraphicsCommandList_Release(cxg->swapchain_images[i].command_list);
ID3D12PipelineState_Release(cxg->pipeline_state_smooth);
ID3D12PipelineState_Release(cxg->pipeline_state_flat);
ID3D12RootSignature_Release(cxg->root_signature);
@@ -681,11 +665,14 @@ static void cxg_load_assets(struct cx_gears *cxg)
hr = demo_create_root_signature(cxg->device, &root_signature_desc, &cxg->root_signature);
assert(SUCCEEDED(hr));
hr = D3DCompile(gears_hlsl, strlen(gears_hlsl), NULL, NULL, NULL, "vs_main", "vs_5_0", 0, 0, &vs, NULL);
hr = D3DCompile(gears_hlsl, gears_hlsl_size, "gears.hlsl",
NULL, NULL, "vs_main", "vs_5_0", 0, 0, &vs, NULL);
assert(SUCCEEDED(hr));
hr = D3DCompile(gears_hlsl, strlen(gears_hlsl), NULL, NULL, NULL, "ps_main_flat", "ps_5_0", 0, 0, &ps_flat, NULL);
hr = D3DCompile(gears_hlsl, gears_hlsl_size, "gears.hlsl",
NULL, NULL, "ps_main_flat", "ps_5_0", 0, 0, &ps_flat, NULL);
assert(SUCCEEDED(hr));
hr = D3DCompile(gears_hlsl, strlen(gears_hlsl), NULL, NULL, NULL, "ps_main_smooth", "ps_5_0", 0, 0, &ps_smooth, NULL);
hr = D3DCompile(gears_hlsl, gears_hlsl_size, "gears.hlsl",
NULL, NULL, "ps_main_smooth", "ps_5_0", 0, 0, &ps_smooth, NULL);
assert(SUCCEEDED(hr));
memset(&pso_desc, 0, sizeof(pso_desc));
@@ -724,13 +711,13 @@ static void cxg_load_assets(struct cx_gears *cxg)
ID3D10Blob_Release(ps_flat);
ID3D10Blob_Release(ps_smooth);
for (i = 0; i < ARRAY_SIZE(cxg->command_list); ++i)
for (i = 0; i < demo_swapchain_get_back_buffer_count(cxg->swapchain); ++i)
{
hr = ID3D12Device_CreateCommandList(cxg->device, 0, D3D12_COMMAND_LIST_TYPE_DIRECT,
cxg->command_allocator[i], cxg->pipeline_state_flat,
&IID_ID3D12GraphicsCommandList, (void **)&cxg->command_list[i]);
cxg->swapchain_images[i].command_allocator, cxg->pipeline_state_flat,
&IID_ID3D12GraphicsCommandList, (void **)&cxg->swapchain_images[i].command_list);
assert(SUCCEEDED(hr));
hr = ID3D12GraphicsCommandList_Close(cxg->command_list[i]);
hr = ID3D12GraphicsCommandList_Close(cxg->swapchain_images[i].command_list);
assert(SUCCEEDED(hr));
}
@@ -805,7 +792,6 @@ static void cxg_key_press(struct demo_window *window, demo_key key, void *user_d
switch (key)
{
case 'a':
case 'A':
cxg->animate = !cxg->animate;
break;
case DEMO_KEY_ESCAPE:
@@ -846,12 +832,17 @@ static int cxg_main(void)
{
unsigned int width = 300, height = 300;
struct cx_gears cxg;
double dpi_x, dpi_y;
size_t i;
memset(&cxg, 0, sizeof(cxg));
if (!demo_init(&cxg.demo, &cxg))
return EXIT_FAILURE;
demo_set_idle_func(&cxg.demo, cxg_idle);
demo_get_dpi(&cxg.demo, &dpi_x, &dpi_y);
width *= dpi_x / 96.0;
height *= dpi_y / 96.0;
cxg.window = demo_window_create(&cxg.demo, "Vkd3d Gears", width, height, &cxg);
demo_window_set_key_press_func(cxg.window, cxg_key_press);
demo_window_set_expose_func(cxg.window, cxg_expose);
@@ -873,10 +864,13 @@ static int cxg_main(void)
cxg_load_pipeline(&cxg);
cxg_load_assets(&cxg);
cxg_populate_command_list(&cxg, 0);
cxg_populate_command_list(&cxg, 1);
cxg_populate_command_list(&cxg, 2);
for (i = 0; i < demo_swapchain_get_back_buffer_count(cxg.swapchain); ++i)
{
cxg_populate_command_list(&cxg, i);
}
printf("vkd3d-gears: Running on \"%s\" using %s.\n",
demo_swapchain_get_device_name(cxg.swapchain), demo_get_platform_name());
demo_process_events(&cxg.demo);
cxg_wait_for_previous_frame(&cxg);

73
demos/gears.hlsl Normal file
View File

@@ -0,0 +1,73 @@
/*
* Copyright 2016 Henri Verbeet 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
*/
cbuffer gear_block : register(b0)
{
float4x4 mvp_matrix;
float3x3 normal_matrix;
};
struct vs_in
{
float4 position : POSITION;
float3 normal : NORMAL;
float3 diffuse : DIFFUSE;
float4 transform : TRANSFORM;
};
struct vs_out
{
float4 position : SV_POSITION;
float4 colour : COLOR;
};
struct vs_out vs_main(struct vs_in i)
{
const float3 l_pos = float3(5.0, 5.0, 10.0);
float3 dir, normal;
float4 position;
struct vs_out o;
float att;
position.x = i.transform.x * i.position.x - i.transform.y * i.position.y + i.transform.z;
position.y = i.transform.x * i.position.y + i.transform.y * i.position.x + i.transform.w;
position.zw = i.position.zw;
o.position = mul(mvp_matrix, position);
dir = normalize(l_pos - o.position.xyz / o.position.w);
normal.x = i.transform.x * i.normal.x - i.transform.y * i.normal.y;
normal.y = i.transform.x * i.normal.y + i.transform.y * i.normal.x;
normal.z = i.normal.z;
att = 0.2 + dot(dir, normalize(mul(normal_matrix, normal)));
o.colour.xyz = i.diffuse.xyz * att;
o.colour.w = 1.0;
return o;
}
float4 ps_main_smooth(float4 position : SV_POSITION, float4 colour : COLOR) : SV_TARGET
{
return colour;
}
float4 ps_main_flat(float4 position : SV_POSITION, nointerpolation float4 colour : COLOR) : SV_TARGET
{
return colour;
}

View File

@@ -1,56 +0,0 @@
static const char gears_hlsl[] =
"cbuffer gear_block : register(b0)\n"
"{\n"
" float4x4 mvp_matrix;\n"
" float3x3 normal_matrix;\n"
"};\n"
"\n"
"struct vs_in\n"
"{\n"
" float4 position : POSITION;\n"
" float3 normal : NORMAL;\n"
" float3 diffuse : DIFFUSE;\n"
" float4 transform : TRANSFORM;\n"
"};\n"
"\n"
"struct vs_out\n"
"{\n"
" float4 position : SV_POSITION;\n"
" float4 colour : COLOR;\n"
"};\n"
"\n"
"struct vs_out vs_main(struct vs_in i)\n"
"{\n"
" const float3 l_pos = float3(5.0, 5.0, 10.0);\n"
" float3 dir, normal;\n"
" float4 position;\n"
" struct vs_out o;\n"
" float att;\n"
"\n"
" position.x = i.transform.x * i.position.x - i.transform.y * i.position.y + i.transform.z;\n"
" position.y = i.transform.x * i.position.y + i.transform.y * i.position.x + i.transform.w;\n"
" position.zw = i.position.zw;\n"
"\n"
" o.position = mul(mvp_matrix, position);\n"
" dir = normalize(l_pos - o.position.xyz / o.position.w);\n"
"\n"
" normal.x = i.transform.x * i.normal.x - i.transform.y * i.normal.y;\n"
" normal.y = i.transform.x * i.normal.y + i.transform.y * i.normal.x;\n"
" normal.z = i.normal.z;\n"
" att = 0.2 + dot(dir, normalize(mul(normal_matrix, normal)));\n"
"\n"
" o.colour.xyz = i.diffuse.xyz * att;\n"
" o.colour.w = 1.0;\n"
"\n"
" return o;\n"
"}\n"
"\n"
"float4 ps_main_smooth(float4 position : SV_POSITION, float4 colour : COLOR) : SV_TARGET\n"
"{\n"
" return colour;\n"
"}\n"
"\n"
"float4 ps_main_flat(float4 position : SV_POSITION, nointerpolation float4 colour : COLOR) : SV_TARGET\n"
"{\n"
" return colour;\n"
"}\n";

151
demos/make_objc Executable file
View File

@@ -0,0 +1,151 @@
#!/usr/bin/perl -w
#
# Copyright 2025 Henri Verbeet
#
# 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
use strict;
use warnings;
use JSON;
use open ':utf8';
binmode STDOUT, ':utf8';
sub method_name($)
{
shift->{selector} =~ s/(:.*)//r;
}
sub method_parameters($$)
{
my ($method, $method_type) = @_;
my $parameters = join ", ", $method_type eq "class" ? () : "id self",
map {"$_->{type} $_->{name}"} @{$method->{parameters}};
length $parameters ? $parameters : "void";
}
sub send_function($)
{
shift->{'return-float'} ? "vkd3d_objc_msgSend_fpret" : "objc_msgSend";
}
sub invocation_type($$)
{
my ($method, $method_type) = @_;
"$method->{'return-type'} (*)(" . join(", ", $method_type eq "class" ? "Class" : "id", "SEL",
map {$_->{type}} @{$method->{parameters}}) . ")";
}
sub invocation_parameters($$$)
{
my ($method, $interface_name, $method_type) = @_;
join ", ", $method_type eq "class" ? "objc_getClass(\"$interface_name\")" : "self",
"sel_registerName(\"$method->{selector}\")", map {$_->{name}} @{$method->{parameters}};
}
sub invocation($$$)
{
my ($method, $interface_name, $method_type) = @_;
($method->{'return-type'} eq "void" ? "" : "return ")
. "((${\invocation_type $method, $method_type})f)"
. "(${\invocation_parameters $method, $interface_name, $method_type});";
}
sub print_method($$$)
{
my ($method, $interface_name, $method_type) = @_;
print "static inline $method->{'return-type'} "
. "${interface_name}_${\method_name $method}(${\method_parameters $method, $method_type})\n";
print "{\n";
print " void *f = ${\send_function $method};\n";
print " ${\invocation $method, $interface_name, $method_type}\n";
print "}\n\n";
}
sub print_property($$)
{
my ($property, $interface_name) = @_;
my $method =
{
'return-type' => $property->{type},
'return-float' => $property->{float},
selector => $property->{getter} // $property->{name},
};
my $method_type = $property->{class} ? "class" : "instance";
print_method $method, $interface_name, $method_type;
if (!$property->{readonly})
{
$method->{'return-type'} = "void";
$method->{'return-float'} = 0;
$method->{selector} = "set${\ucfirst $property->{name}}:";
$method->{parameters} = [$property];
print_method $method, $interface_name, $method_type;
}
}
sub print_interface(_)
{
my ($interface) = @_;
print_method $_, $interface->{name}, "class" foreach (@{$interface->{'class-methods'}});
print_method $_, $interface->{name}, "instance" foreach (@{$interface->{'instance-methods'}});
print_property $_, $interface->{name} foreach (@{$interface->{properties}});
}
sub print_header($)
{
my ($grammar) = @_;
my $guard = "__VKD3D_${\uc $grammar->{name}}_H__";
print "/*\n";
print " * This file is automatically generated.\n";
print " * The original source is covered by the following license:\n";
print " *\n";
print map {" * $_" =~ s/ +$//r . "\n"} @{$grammar->{copyright}};
print " */\n\n";
print "#ifndef $guard\n";
print "#define $guard\n\n";
print "#include <objc/objc-runtime.h>\n\n";
print "#ifdef __arm64__\n";
print "# define vkd3d_objc_msgSend_fpret objc_msgSend\n";
print "#else\n";
print "# define vkd3d_objc_msgSend_fpret objc_msgSend_fpret\n";
print "#endif /* __arm64__ */\n\n";
print_interface foreach (@{$grammar->{interfaces}});
print "#undef vkd3d_objc_msgSend_fpret\n\n";
print "#endif /* $guard */\n";
}
die "No input file specified.\n" unless @ARGV;
print_header do
{
local $/;
open my $fh, '<', $ARGV[0] or die $!;
decode_json <$fh>;
};

Some files were not shown because too many files have changed in this diff Show More