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
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
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
ea177a7750
vkd3d-shader/hlsl: Handle "unsigned int" type.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-05-30 19:56:29 +02:00
Henri Verbeet
36c123c005
Release 1.12.
2024-05-29 22:05:28 +02:00
Nikolay Sivov
308d735923
vkd3d-shader/ir: Set texture register dimension as VEC4 when normalising combined samplers.
...
Thanks, Giovanni.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-05-27 21:07:51 +02:00
Nikolay Sivov
f090d1e80d
vkd3d-shader: Remove explicit newlines from hlsl_fixme() messages.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-05-23 23:12:10 +02:00
Henri Verbeet
b5ac6ac636
vkd3d-shader: Use a separate allocation for the "semantic_name" field of shader signature elements.
...
For tpf shader this would previously be a pointer into the original
shader code, and for d3dbc shaders we'd use static strings.
Unfortunately the dxil parser creates shader signatures where these
are pointers to metadata strings, and those go away when we call
sm6_parser_cleanup().
We could conceivably store a flag in the shader signature to indicate
whether shader_signature_cleanup()/vkd3d_shader_free_shader_signature()
should free the "semantic_name" field. It'd be a little ugly, and seems
unlikely to be worth it, but I'd be willing to be convinced.
2024-05-23 23:12:06 +02:00
Victor Chiletto
105ef28273
vkd3d-shader/preproc: Treat CR as whitespace.
2024-05-23 23:11:58 +02:00
Victor Chiletto
fa5708d3b5
vkd3d-shader/hlsl: Fix XOR assign operator lexing.
2024-05-22 22:15:20 +02:00
Nikolay Sivov
9c83caeda6
vkd3d-shader/fx: Use correct type name when reusing types.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-05-16 21:49:50 +02:00
Nikolay Sivov
a913ac7844
vkd3d-shader/fx: Implement writing shared buffers.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-05-16 21:49:48 +02:00
Henri Verbeet
ce6f8a6a30
vkd3d-shader/dxil: Parse the shader into a vsir program in vkd3d_shader_sm6_parser_create().
2024-05-16 21:49:40 +02:00
Henri Verbeet
6474e8cc7b
vkd3d-shader/tpf: Parse the shader into a vsir program in vkd3d_shader_sm4_parser_create().
2024-05-16 21:49:39 +02:00
Henri Verbeet
402b96ef3b
vkd3d-shader/d3dbc: Parse the shader into a vsir program in vkd3d_shader_sm1_parser_create().
2024-05-16 21:49:38 +02:00
Henri Verbeet
efe9dfd73a
vkd3d-shader/ir: Do not store the vkd3d-shader configuration flags in struct vkd3d_shader_parser.
2024-05-16 21:49:37 +02:00
Henri Verbeet
19b552ce1b
vkd3d-shader/ir: Pass an initialised vsir_program structure to vkd3d_shader_parser_init().
2024-05-16 21:49:36 +02:00
Henri Verbeet
9e4a790de1
vkd3d-shader/ir: Use a separate allocation for the vsir program in struct vkd3d_shader_parser.
2024-05-16 21:49:34 +02:00
Francisco Casas
061dc39036
vkd3d-shader/hlsl: Also lower matrix swizzles and index loads in const passes.
2024-05-15 21:17:51 +02:00
Francisco Casas
0d252f894a
vkd3d-shader/hlsl: Run more constant passes on static expressions eval.
2024-05-15 21:17:50 +02:00
Francisco Casas
4f60c7167e
vkd3d-shader/hlsl: Run constant passes in a separate function.
2024-05-15 21:17:49 +02:00
Conor McCarthy
9e57039fce
vkd3d-shader/dxil: Handle SV_ClipDistance and SV_CullDistance.
2024-05-14 20:44:22 +02:00
Conor McCarthy
4f50af4c83
vkd3d-shader/dxil: Handle SV_Coverage out.
2024-05-14 20:44:18 +02:00
Conor McCarthy
e1c774bfeb
vkd3d-shader/spirv: Implement the WAVE_READ_LANE_FIRST instruction.
2024-05-14 20:44:10 +02:00
Conor McCarthy
47f0483267
vkd3d-shader/dxil: Implement DX intrinsic WaveReadLaneFirst.
2024-05-14 20:44:06 +02:00
Conor McCarthy
936d8e4f61
vkd3d-shader/spirv: Implement the WAVE_READ_LANE_AT instruction.
2024-05-14 20:44:04 +02:00
Conor McCarthy
e41643ab8f
vkd3d-shader/dxil: Implement DX intrinsic WaveReadLaneAt.
2024-05-14 20:44:02 +02:00
Victor Chiletto
c9af34ab28
vkd3d-shader/hlsl: Avoid a null pointer dereference in hlsl_block_cleanup (UBSan).
...
destroy_block() is called with a NULL block from:
* create_loop, through the loop rules for while and do-while loops.
* The selection_statement rule, in the case $6.else_block is NULL.
* free_parse_initializer.
2024-05-14 20:43:48 +02:00
Conor McCarthy
98f73ca2e5
vkd3d-shader/ir: Allow all DCL instructions to occur outside hull shader phases.
2024-05-13 22:27:13 +02:00
Conor McCarthy
def87539de
vkd3d-shader/dxil: Delete bool not-equal-to-false comparison instructions.
2024-05-13 22:27:13 +02:00
Conor McCarthy
f47ac703ab
vkd3d-shader/spirv: Emit a trace instead of a warning message for ignored alignment.
2024-05-13 22:27:13 +02:00
Conor McCarthy
e340855122
vkd3d-shader/spirv: Do not warn if no global flags are unhandled.
2024-05-13 22:27:13 +02:00
Conor McCarthy
ea5624e5e8
vkd3d-shader/dxil: Emit bool inputs and outputs as uint.
...
DXIL reads/writes uint for these.
2024-05-13 22:27:13 +02:00
Francisco Casas
5b7191280b
vkd3d-shader: Return a valid pointer when count=0 in param allocator (ubsan).
...
After compiling and linking with '-fsanitize=undefined' the following
error pops up in many tests:
vkd3d_shader_main.c:2024:12: runtime error: member access within null pointer of type 'struct vkd3d_shader_param_node'
This happens in the scenario where shader_param_allocator_get() gets
called with 'count = 0' but no allocation has been made yet, so
allocator->current is NULL.
In this case the result of the function, given by:
params = &allocator->current->param[allocator->index * allocator->stride];
is an invalid non-NULL pointer.
Functions like shader_sm4_read_instruction() may call
vsir_program_get_src_params() or vsir_program_get_dst_params() with 0
counts for various DCL_ instructions, as well as things like NOP,
ELSE, and SYNC.
We could avoid calling the functions in question with 0 counts, but it
doesn't seem worth the effort.
Alternatively, we could just return NULL on 'count == 0', but this is
also complicated because NULL is interpreted as a memory allocation
failure on the callers.
So we force allocation of the next node even if 'count = 0' when
allocator->current is NULL.
2024-05-13 22:27:13 +02:00
Francisco Casas
28d267b7c0
vkd3d-shader/hlsl: Allocate SM1 numeric uniforms in decreasing bind count.
2024-05-13 22:26:21 +02:00
Francisco Casas
e7450ce539
vkd3d-shader/d3dbc: Write used bind count for numeric uniforms.
2024-05-13 22:26:13 +02:00
Francisco Casas
f548644222
vkd3d-shader/hlsl: Only allocate numeric bind count for SM1 numeric uniforms.
...
Unless they have register reservations, in which case the whole
variable is still reserved.
2024-05-13 22:26:08 +02:00
Francisco Casas
573d511344
vkd3d-shader/hlsl: Track bind count according to usage for uniforms.
...
Where bind count means the number of registers required to include all
dereferences to the variable within the shader as in
hlsl_ir_var.bind_count[].
2024-05-13 22:26:07 +02:00
Francisco Casas
e0a801e796
vkd3d-shader/hlsl: Improve tracking of used components running DCE before.
...
track_object_components_usage() had to be improved to also
register derefs on resource stores.
It was not doing it because it assumed that for every resource store
there was a resource load already, which was true, before calling DCE.
2024-05-13 22:26:05 +02:00
Francisco Casas
657e460d11
vkd3d-shader/hlsl: Allocate unused variables with register reservations on SM1.
2024-05-13 22:26:03 +02:00
Conor McCarthy
77259da1ad
vkd3d-shader/spirv: Implement the WAVE_PREFIX_BIT_COUNT instruction.
2024-05-13 11:50:23 +02:00
Conor McCarthy
2810edf45b
vkd3d-shader/dxil: Implement DX intrinsic WavePrefixBitCount.
2024-05-13 11:50:22 +02:00
Conor McCarthy
065ef0c5e4
vkd3d-shader/spirv: Implement the WAVE_IS_FIRST_LANE instruction.
2024-05-13 11:50:21 +02:00
Conor McCarthy
c30976e5c2
vkd3d-shader/dxil: Implement DX intrinsic WaveIsFirstLane.
2024-05-13 11:50:20 +02:00
Conor McCarthy
feef2577ef
vkd3d-shader/spirv: Implement the WAVE_ALL_BIT_COUNT instruction.
2024-05-13 11:50:19 +02:00
Conor McCarthy
cb5163f9a4
vkd3d-shader/dxil: Implement DX intrinsic WaveAllBitCount.
2024-05-13 11:50:17 +02:00
Conor McCarthy
962096f179
vkd3d-shader/dxil: Implement DX intrinsics EmitStream, CutStream and EmitThenCutStream.
2024-05-08 21:08:16 +02:00
Conor McCarthy
cc49f26af1
vkd3d-shader/ir: Validate geometry shader properties.
2024-05-08 21:08:15 +02:00
Conor McCarthy
4fd2d5aa77
vkd3d-shader/dxil: Load geometry shader properties.
2024-05-08 21:08:14 +02:00
Nikolay Sivov
0053cc52b7
vkd3d-shader/fx: Initial support for writing sample state objects.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-05-08 21:08:05 +02:00
Nikolay Sivov
3c6470e3b2
vkd3d-shader/fx: Set UAV count in the header.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-05-08 21:08:04 +02:00
Nikolay Sivov
1a79d1e945
vkd3d-shader/fx: Filter out unsupported object types.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-05-08 21:08:03 +02:00
Nikolay Sivov
9bbed14987
vkd3d-shader/fx: Fix shader counter in the header.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-05-08 21:08:02 +02:00
Nikolay Sivov
cb1a271151
vkd3d-shader/fx: Set texture count in the header.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-05-08 21:08:01 +02:00
Nikolay Sivov
162d8760be
vkd3d-shader/fx: Set RTV counter in the header.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-05-08 21:08:00 +02:00
Nikolay Sivov
a879ac5536
vkd3d-shader/fx: Write depth stencil view object variables.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-05-08 21:07:59 +02:00
Zebediah Figura
c2eb563e50
vkd3d-shader/fx: Skip uniform copy logic for global variables.
2024-05-08 21:07:58 +02:00
Francisco Casas
68483d070f
vkd3d-shader/hlsl: Turn hlsl_state_block_entry arguments into hlsl_src.
...
This allows to apply passes that replace instructions in
hlsl_state_block_entry.instrs.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-05-08 21:07:57 +02:00
Zebediah Figura
7b3c47ba2e
vkd3d-shader/tpf: Write the field offset in bytes.
2024-05-06 22:12:48 +02:00
Zebediah Figura
2480eec98b
vkd3d-shader/hlsl: Move the "base_type" member to the class-specific union.
2024-05-06 22:12:41 +02:00
Zebediah Figura
4fd3f46109
vkd3d-shader/hlsl: Use a switch in hlsl_types_are_equal().
2024-05-06 22:12:39 +02:00
Zebediah Figura
d9f7a88329
vkd3d-shader/hlsl: Make HLSL_TYPE_PIXELSHADER into a separate class.
2024-05-06 22:12:37 +02:00
Zebediah Figura
874937dab4
vkd3d-shader/hlsl: Make HLSL_TYPE_VERTEXSHADER into a separate class.
2024-05-06 22:12:34 +02:00
Zebediah Figura
e904b4596a
vkd3d-shader/hlsl: Ensure that the type is numeric before calling expr_common_base_type().
2024-05-06 22:12:33 +02:00
Conor McCarthy
cfcc789b42
vkd3d-shader/spirv: Implement the WAVE_OP_* instructions.
2024-05-06 22:12:27 +02:00
Conor McCarthy
c71751edc9
vkd3d-shader/dxil: Implement DX intrinsics WaveActiveOp and WavePrefixOp.
2024-05-06 22:12:25 +02:00
Conor McCarthy
fef5760af0
vkd3d-shader/spirv: Implement the WAVE_ACTIVE_BIT_* instructions.
2024-05-06 22:12:24 +02:00
Conor McCarthy
af208135f3
vkd3d-shader/dxil: Implement DX intrinsic WaveActiveBit.
2024-05-06 22:12:22 +02:00
Conor McCarthy
1c49b3a779
vkd3d-shader/spirv: Implement the WAVE_ACTIVE_BALLOT instruction.
2024-05-06 22:12:21 +02:00
Conor McCarthy
174a692a17
vkd3d-shader/dxil: Implement DX intrinsic WaveActiveBallot.
2024-05-06 22:12:19 +02:00
Henri Verbeet
592e902d47
vkd3d-shader: Pass a struct vsir_program to vkd3d_shader_parser_compile().
2024-05-02 22:19:18 +02:00
Henri Verbeet
fa7b623eac
vkd3d-shader: Pass a struct vsir_program to scan_with_parser().
2024-05-02 22:19:18 +02:00
Henri Verbeet
f948520504
vkd3d-shader/spirv: Pass a struct vsir_program to spirv_compile().
2024-05-02 22:19:17 +02:00
Henri Verbeet
e21215f466
vkd3d-shader/spirv: Pass a struct vsir_program to spirv_compiler_generate_spirv().
2024-05-02 22:19:16 +02:00
Conor McCarthy
95489899be
vkd3d-shader/spirv: Handle the WAVE_ANY_TRUE instruction.
2024-05-02 22:19:02 +02:00
Conor McCarthy
fb5eb3159d
vkd3d-shader/dxil: Implement DX intrinsic WaveAnyTrue.
2024-05-02 22:19:00 +02:00
Conor McCarthy
77ec2a5caa
vkd3d-shader/spirv: Handle the WAVE_ALL_TRUE instruction.
2024-05-02 22:18:59 +02:00
Conor McCarthy
8e2b351538
vkd3d-shader/dxil: Implement DX intrinsic WaveAllTrue.
2024-05-02 22:18:58 +02:00
Conor McCarthy
78f2d2936d
vkd3d-shader/spirv: Handle the WAVE_ACTIVE_ALL_EQUAL instruction.
2024-05-02 22:18:57 +02:00
Conor McCarthy
9aa9b112e6
vkd3d-shader/dxil: Implement DX intrinsic WaveActiveAllEqual.
2024-05-02 22:18:55 +02:00
Conor McCarthy
c770efc530
vkd3d-shader/spirv: Handle the WAVELANEINDEX register.
2024-05-02 22:18:54 +02:00
Conor McCarthy
a130c970a6
vkd3d-shader/spirv: Handle the WAVELANECOUNT register.
2024-05-02 22:18:49 +02:00
Conor McCarthy
6a56b4e5d8
vkd3d-shader/dxil: Implement DX intrinsics WaveGetLaneCount and WaveGetLaneIndex.
2024-05-02 22:18:48 +02:00
Conor McCarthy
127bcf90e4
vkd3d-shader/dxil: Implement DX intrinsic Coverage.
2024-04-30 16:32:10 +02:00
Conor McCarthy
36c76e1557
vkd3d-shader/dxil: Handle SV_PrimitiveId.
2024-04-30 16:32:10 +02:00
Conor McCarthy
eef0f7c29e
vkd3d-shader/dxil: Handle SV_InstanceId.
2024-04-30 16:32:10 +02:00