Commit Graph

2963 Commits

Author SHA1 Message Date
Francisco Casas
d4a49d788a vkd3d-shader/hlsl: Simplify computation of allocation size. 2023-08-15 21:51:32 +02:00
Francisco Casas
37cfbe47d7 vkd3d-shader/hlsl: Sort synthetic separated samplers first for SM4. 2023-08-15 21:51:31 +02:00
Francisco Casas
81afe43569 vkd3d-shader/tpf: Put the actual bind count in the RDEF table. 2023-08-15 21:51:29 +02:00
Francisco Casas
7eba063136 vkd3d-shader/hlsl: Rename hlsl_reg.bind_count to hlsl_reg.allocation_size.
We have to distinguish between the "bind count" and the "allocation size"
of variables.

The "allocation size" affects the starting register id for the resource to
be allocated next, while the "bind count" is determined by the last field
actually used. The former may be larger than the latter.

What we are currently calling hlsl_reg.bind_count is actually the
"allocation size", so a rename is in order.

The real "bind count", which will be introduced in following patches,
is important because it is what should be shown in the RDEF table and
some resource allocation rules depend on it.

For instance, for this shader:

    texture2D texs[3];
    texture2D tex;

    float4 main() : sv_target
    {
        return texs[0].Load(int3(0, 0, 0)) + tex.Load(int3(0, 0, 0));
    }

the variable "texs" has a "bind count" of 1, but an "allocation size" of
3:

    // Resource Bindings:
    //
    // Name                                 Type  Format         Dim      HLSL Bind  Count
    // ------------------------------ ---------- ------- ----------- -------------- ------
    // texs                              texture  float4          2d             t0      1
    // tex                               texture  float4          2d             t3      1
2023-08-15 21:51:27 +02:00
Nikolay Sivov
98f63c46f8 vkd3d-shader/hlsl: Use type width in fold_rcp().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-08-14 18:38:21 +02:00
Nikolay Sivov
932c5e36dc vkd3d-shader/hlsl: Add constant folding for 'log2'.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-08-14 18:38:20 +02:00
Nikolay Sivov
58bc61e48d vkd3d-shader/hlsl: Add constant folding for 'sqrt'.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-08-14 18:38:18 +02:00
Nikolay Sivov
7e99188dc7 vkd3d-shader: Add constant folding for 'dp2add' operation.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-08-14 18:38:15 +02:00
Nikolay Sivov
25ff56769b vkd3d-shader: Add constant folding for the 'dot' operation.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-08-14 18:38:15 +02:00
Zebediah Figura
983d01df8c vkd3d-shader: Get rid of the uav_ranges array.
This is now redundant; the register ID is encoded into the scan descriptors.
2023-08-14 18:38:11 +02:00
Zebediah Figura
7d02922541 vkd3d-shader: Add register ID to struct vkd3d_shader_descriptor_info1. 2023-08-14 18:38:11 +02:00
Zebediah Figura
4e9798f6f7 vkd3d-shader: Introduce struct vkd3d_shader_scan_descriptor_info1. 2023-08-14 18:38:11 +02:00
Zebediah Figura
fd4a820c4b vkd3d-shader: Centralize cleanup on error in scan_with_parser(). 2023-08-14 18:38:11 +02:00
Zebediah Figura
9c5cb2de18 vkd3d-shader: Factor more code into vkd3d_shader_scan_get_uav_descriptor_info(). 2023-08-14 18:38:11 +02:00
Francisco Casas
8484bd59a6 vkd3d-shader/tpf: Separate dst register write function. 2023-08-14 18:38:08 +02:00
Francisco Casas
d1c45fe2f0 vkd3d-shader/tpf: Separate src register write function. 2023-08-14 18:38:07 +02:00
Francisco Casas
2258e9d0f3 vkd3d-shader/tpf: Make register_type_table an array of structs with lookup tables. 2023-08-14 18:38:06 +02:00
Francisco Casas
c77e5f1c1f vkd3d-shader/tpf: Introduce struct tpf_writer to group sm4 write arguments.
We will add register information lookup tables on this struct later.
They will be used by sm4_encode_register(), and thus, they will be
required by write_sm4_instruction().
2023-08-14 18:38:05 +02:00
Francisco Casas
a584499c8a vkd3d-shader/tpf: Use struct vkd3d_shader_register_index in sm4_register.idx[]. 2023-08-14 18:38:04 +02:00
Francisco Casas
fc589add49 vkd3d-shader/tpf: Allow passing NULL register type on hlsl_sm4_register_from_semantic(). 2023-08-14 18:38:03 +02:00
Francisco Casas
8a6a620ee2 vkd3d-shader/tpf: Use enum vkd3d_shader_register_type in sm4_register.type. 2023-08-14 18:38:01 +02:00
Zebediah Figura
cf6bc95a3d vkd3d-shader/hlsl: Use hlsl_block_add_instr() in clone_block(). 2023-08-08 21:15:16 +09:00
Zebediah Figura
4ae00cea43 vkd3d-shader/hlsl: Clean up the static_initializers block when the context is destroyed (Valgrind).
This is currently leaked if we fail parsing before reaching codegen.
2023-08-08 21:15:13 +09:00
Zebediah Figura
b22e2113a6 vkd3d-shader/hlsl: Pass a hlsl_block pointer to dump_instr_list(). 2023-08-08 21:15:10 +09:00
Zebediah Figura
0652bb1950 vkd3d-shader/hlsl: Store the "instrs" field of struct hlsl_attribute as a hlsl_block. 2023-08-08 21:15:08 +09:00
Zebediah Figura
372ddd1f29 vkd3d-shader/hlsl: Pass an hlsl_block pointer to add_load_component(). 2023-08-08 21:15:05 +09:00
Zebediah Figura
f649db23a5 vkd3d-shader: Introduce a function to build a varying map between sm1 stages. 2023-08-03 21:20:44 +09:00
Zebediah Figura
d932fba7c3 vkd3d-shader/spirv: Make output varyings not consumed by the next stage private variables. 2023-08-03 21:20:42 +09:00
Zebediah Figura
11475ef62a vkd3d-shader: Implement remapping shader output registers to match the next shader's semantics. 2023-08-03 21:20:42 +09:00
Zebediah Figura
cb96482500 vkd3d-shader: Add a separate field for the target location of a signature element.
We want to be able to remap input signatures based on the signature index, but
signature normalization both reorders the signature, and requires the old
register index, so add a new field for this.
2023-08-03 21:20:39 +09:00
Zebediah Figura
bad72d1874 vkd3d-shader/d3dbc: Make sure all inter-stage varyings have a unique register index.
spirv will need this.
2023-08-03 21:20:22 +09:00
Zebediah Figura
b4bb3931c5 vkd3d-shader/preproc: Append spaces between tokens in macro invocations. 2023-08-02 20:19:21 +09:00
Zebediah Figura
250a24bd3f vkd3d-shader/preproc: Strip whitespace when stringifying. 2023-08-02 20:19:20 +09:00
Zebediah Figura
6fc3ae2b5c vkd3d-shader/preproc: Stringify text immediately in macro invocations. 2023-08-02 20:19:19 +09:00
Zebediah Figura
cbb1d84069 vkd3d-shader/preproc: Separate a preproc_stringify() helper. 2023-08-02 20:19:18 +09:00
Zebediah Figura
3a235b57f6 vkd3d-shader/preproc: Expand macro arguments in macro invocations.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55361
2023-08-02 20:19:17 +09:00
Zebediah Figura
9b98489155 vkd3d-shader/preproc: Parse hash marks as two separate tokens when not in stringification contexts. 2023-08-02 20:19:15 +09:00
Zebediah Figura
9a80ff28e4 vkd3d-shader/tpf: Check buffer->status in add_section(). 2023-08-02 20:19:00 +09:00
Zebediah Figura
71afb78126 vkd3d-shader/d3dbc: Return ctx->result from hlsl_sm1_write(). 2023-08-02 20:18:59 +09:00
Zebediah Figura
6e370777b4 vkd3d-shader/d3dbc: Free vkd3d_bytecode_buffer data on failure. 2023-08-02 20:18:58 +09:00
Zebediah Figura
1bd873fb2b vkd3d-shader/d3dbc: Skip generic sampler declarations.
Instead of asserting.
2023-08-02 20:18:56 +09:00
Conor McCarthy
c2e09e4c4f vkd3d: Implement ID3D12Fence1. 2023-08-02 20:18:37 +09:00
Conor McCarthy
0d1bc77b2a vkd3d: Implement ID3D12GraphicsCommandList3 with a stub. 2023-07-31 21:08:02 +09:00
Conor McCarthy
4433dacb4f vkd3d: Implement ID3D12Device::GetResourceTiling() for textures. 2023-07-31 21:07:58 +09:00
Conor McCarthy
71a9feac8e vkd3d: Implement ID3D12Device::GetResourceTiling() for buffers. 2023-07-31 21:07:57 +09:00
Nikolay Sivov
bfdd5c142d vkd3d-shader/tpf: Add support for writing 'resinfo' instruction.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-07-31 21:07:50 +09:00
Nikolay Sivov
78719dc814 vkd3d-shader/tpf: Add support for writing 'sampleinfo' instruction.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-07-31 21:07:49 +09:00
Nikolay Sivov
d50b5fe767 vkd3d-shader/hlsl: Parse GetDimensions() method.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-07-31 21:07:48 +09:00
Conor McCarthy
3d49b59a68 vkd3d: Handle the case where a descriptor is null and is concurrently written non-null.
If view is null and the comparison (view == src->s.u.object) is false,
vkd3d_view_decref will be called on null.
2023-07-27 17:17:55 +09:00
Zebediah Figura
819c5f1943 vkd3d-shader/hlsl: Pass an hlsl_block pointer to add_expr(). 2023-07-27 17:17:48 +09:00
Zebediah Figura
9d94506313 vkd3d-shader/hlsl: Pass an hlsl_block pointer to add_cast(). 2023-07-27 17:17:47 +09:00
Zebediah Figura
fe70ee2158 vkd3d-shader/hlsl: Pass an hlsl_block pointer to add_implicit_conversion(). 2023-07-27 17:17:46 +09:00
Zebediah Figura
21d5ee4df2 vkd3d-shader/hlsl: Pass an hlsl_block pointer to add_array_access(). 2023-07-27 17:17:41 +09:00
Zebediah Figura
c861a937e8 vkd3d-shader/hlsl: Pass an hlsl_block pointer to add_method_call(). 2023-07-27 17:17:37 +09:00
Zebediah Figura
f95ab2a5e8 vkd3d-shader/hlsl: Pass an hlsl_block pointer to add_assignment(). 2023-07-24 22:41:16 +02:00
Zebediah Figura
7e7a6d3691 vkd3d-shader/hlsl: Pass a hlsl_block pointer to hlsl_add_conditional(). 2023-07-24 22:41:15 +02:00
Zebediah Figura
80b9f52010 vkd3d-shader/hlsl: Use a hlsl_block to build replacement instructions in lower_discard_neg(). 2023-07-24 22:41:14 +02:00
Zebediah Figura
3a07df8476 vkd3d-shader/hlsl: Use a hlsl_block to build replacement instructions in lower_float_modulus(). 2023-07-24 22:41:13 +02:00
Zebediah Figura
0dee96ead6 vkd3d-shader/hlsl: Use a hlsl_block to build replacement instructions in lower_int_modulus(). 2023-07-24 22:41:12 +02:00
Nikolay Sivov
bd3d4a6c06 vkd3d-shader: Add compiler option to specify matrix majority.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-07-24 22:41:09 +02:00
Conor McCarthy
acc68aef94 vkd3d: Add a pending execution count to struct d3d12_command_signature.
Buffering of command list commands will depend upon command signatures
persisting until the buffer is flushed.
2023-07-24 22:41:07 +02:00
Conor McCarthy
95bad60281 vkd3d: Store the command buffer in the allocator upon creation.
For correct function it cannot be freed until the command allocator
is reset, and d3d12_command_allocator_free_command_buffer() normally
does not free it.
2023-07-24 22:40:53 +02:00
Conor McCarthy
9187a41733 vkd3d: Move descriptor heap tracking to d3d12_command_list_set_descriptor_table().
This is the simplest way to gather this information when command lists
are executed later.
2023-07-24 22:40:52 +02:00
Conor McCarthy
42d46d2513 vkd3d: Do not create Vulkan descriptor sets for non-shader-visible heaps. 2023-07-20 22:33:17 +02:00
Conor McCarthy
9014183100 vkd3d: Return a null handle from GetGPUDescriptorHandleForHeapStart() for non-shader-visible heaps. 2023-07-20 22:33:17 +02:00
Conor McCarthy
0a98d09145 vkd3d: Enable Vulkan-backed heaps for each heap instead of per device.
Provides a simple way to disable Vulkan writes for non-shader-visible
heaps. Also there is a chance of avoiding access to the d3d12_device
object which helps memory cache performance.
2023-07-20 22:33:05 +02:00
Zebediah Figura
d52eb8595f vkd3d-shader/hlsl: Use a hlsl_block to build replacement instructions in lower_int_division(). 2023-07-20 22:33:01 +02:00
Zebediah Figura
cdabe172cb vkd3d-shader/hlsl: Return a hlsl_block from the "declaration" and "struct_declaration" rules. 2023-07-20 22:33:00 +02:00
Zebediah Figura
54bd6f7b4b vkd3d-shader/hlsl: Return a hlsl_block from the "declaration_statement" rule. 2023-07-20 22:32:59 +02:00
Zebediah Figura
77e1c5893e vkd3d-shader/hlsl: Return a hlsl_block from the "primary_expr" rule. 2023-07-20 22:32:57 +02:00
Conor McCarthy
c0a2bb1095 vkd3d-shader/dxil: Emit undefined constants. 2023-07-20 22:32:53 +02:00
Conor McCarthy
402c93fa68 vkd3d-shader/spirv: Introduce an undefined register type. 2023-07-20 22:32:52 +02:00
Conor McCarthy
3e553aaaa7 vkd3d-shader/dxil: Emit the shader instructions.
Sufficient for compiling a no-op pixel shader.
2023-07-20 22:32:51 +02:00
Conor McCarthy
f26d47585f vkd3d-shader/spirv: Do not normalise Shader Model 6 shaders. 2023-07-20 22:32:50 +02:00
Conor McCarthy
8fe6d2eeac vkd3d-shader/dxil: Return an error from sm6_parser_globals_init() on invalid operand count. 2023-07-20 22:32:48 +02:00
Zebediah Figura
e0e261eac3 vkd3d-shader/spirv: Emit variables for flat constant buffers. 2023-07-17 22:56:47 +02:00
Zebediah Figura
25cf6a720b vkd3d-shader/ir: Normalise sm1-style constants. 2023-07-17 22:56:45 +02:00
Zebediah Figura
e9fb067d4c vkd3d-shader/ir: Move normalization code from spirv.c to ir.c.
It is not spirv-specific and will (presumably) be used for GLSL as well.
2023-07-17 22:56:43 +02:00
Zebediah Figura
d077562f79 vkd3d-shader/d3dbc: Scan descriptors for constant register sets. 2023-07-17 22:56:39 +02:00
Zebediah Figura
44bf5556ae vkd3d-shader/hlsl: Free the constant defs array in hlsl_ctx_cleanup().
Spotted by Francisco Casas.
2023-07-17 22:56:19 +02:00
Nikolay Sivov
63631a8fd4 vkd3d-shader/tpf: Support some of the UAV types when writing RDEF records.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-07-17 22:56:05 +02:00
Francisco Casas
3bafd036bb vkd3d-shader/hlsl: Don't allocate all texture registers for synthetic separated samplers. 2023-07-17 22:55:53 +02:00
Zebediah Figura
a55973d695 vkd3d-shader/hlsl: Lower combined samplers to separate sampler and texture objects for SM4.
Co-authored-by: Francisco Casas <fcasas@codeweavers.com>
2023-07-17 22:55:51 +02:00
Francisco Casas
15ea5ff9db vkd3d-shader/hlsl: Separate tracking of sampler_dim and usage for object components. 2023-07-17 22:55:48 +02:00
Francisco Casas
c4f074d25d vkd3d-shader/hlsl: Introduce hlsl_new_synthetic_var_named(). 2023-07-17 22:55:46 +02:00
Francisco Casas
866c5d9531 vkd3d-shader/hlsl: Check is_uniform instead of HLSL_STORAGE_UNIFORM when validating object refs.
We are using the hlsl_ir_var.is_uniform flag to indicate when an object
is a uniform copy created from a variable with the HLSL_STORAGE_UNIFORM
modifier.

We should be checking for this instead of the HLSL_STORAGE_UNIFORM flag
which is also set to 1 for the original variables, and there should be
no reason to use this flag instead of "is_uniform" after the uniform
copies and combined/separated samplers are created.
2023-07-17 22:55:43 +02:00
Francisco Casas
c58d666d1b vkd3d-shader/hlsl: Handle resource components individually for SM 5.0. 2023-07-17 22:55:40 +02:00
Francisco Casas
8f8c7a02ee vkd3d-shader/tpf: Introduce struct extern_resource.
This struct is required for handling both whole-variable resources for
SM < 5 and single-component resources for SM 5 in the same way, when
writting the RDEF block and resource declarations within the shader.
2023-07-17 22:55:39 +02:00
Francisco Casas
ae6bc398d6 vkd3d-shader/hlsl: Allow derefs to provide the data_type.
After lowering the derefs path to a single offset node, there was no way
of knowing the type of the referenced part of the variable. This little
modification allows to avoid having to pass the data type everywhere and
it is required for supporting instructions that reference objects
components within struct types.

Since deref->data_type allows us to retrieve the type of the deref,
deref->offset_regset is no longer necessary.
2023-07-17 22:55:36 +02:00
Zebediah Figura
d4b5e79c8b vkd3d-shader/hlsl: Skip unallocated variables when looking for reservation conflicts. 2023-07-13 23:00:03 +02:00
Zebediah Figura
aec9ea085e vkd3d-shader/hlsl: Return a hlsl_block from the "postfix_expr" rule. 2023-07-11 22:44:15 +02:00
Zebediah Figura
e222a786a1 vkd3d-shader/hlsl: Return a hlsl_block from binary and ternary expression rules. 2023-07-11 22:44:12 +02:00
Zebediah Figura
3079c874e3 vkd3d-shader/hlsl: Return a hlsl_block from the "unary_expr" rule. 2023-07-11 22:44:10 +02:00
Zebediah Figura
28dff58fb5 vkd3d-shader/hlsl: Return a hlsl_block from the "initializer_expr" rule. 2023-07-11 22:44:09 +02:00
Zebediah Figura
53d5ea639c vkd3d-shader/hlsl: Return a hlsl_block from the "assignment_expr" rule. 2023-07-11 22:44:06 +02:00
Conor McCarthy
1ec112e3d7 vkd3d-shader/dxil: Read function bodies. 2023-07-11 22:43:58 +02:00
Conor McCarthy
5d33fb4633 vkd3d-shader/dxil: Read numeric constants. 2023-07-11 22:43:57 +02:00
Conor McCarthy
c96143abdc vkd3d-shader/dxil: Read global function declarations. 2023-07-11 22:43:55 +02:00
Conor McCarthy
22157c3da3 vkd3d-shader/dxil: Validate the module format version. 2023-07-11 22:43:53 +02:00
Conor McCarthy
eca4b62c7e vkd3d-shader/dxil: Read the value symbol table. 2023-07-11 22:43:49 +02:00