Commit Graph

178 Commits

Author SHA1 Message Date
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
47fcbc335b vkd3d-shader/d3dbc: Avoid D3DXSHADER_CONSTANTTABLE. 2024-10-16 21:07:53 +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
Elizabeth Figura
6ee17cf77e vkd3d-shader/spirv: Implement shader point size. 2024-10-10 22:14:45 +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
53e35f2d76 vkd3d-shader/d3dbc: Do not emit indices for DEPTHOUT registers. 2024-10-02 22:11:48 +02:00
Giovanni Mascellani
5f20103518 vkd3d-shader/d3dbc: Trace the program when validation fails after parsing. 2024-09-30 20:48:43 +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
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
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
Henri Verbeet
d4bc51b850 vkd3d-shader/d3dbc: Introduce enum vkd3d_sm1_rastout_register. 2024-09-19 14:38:03 +02:00
Henri Verbeet
6cae2d006c vkd3d-shader/d3dbc: Introduce enum vkd3d_sm1_misc_register. 2024-09-18 15:04:10 +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
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
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
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
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
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
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
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
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
Francisco Casas
094e298c1c vkd3d-shader/hlsl: Parse string default values. 2024-08-13 21:19:01 +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
91e88fac2e vkd3d-shader/hlsl: Add parser support for BlendState type. 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
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
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
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
bcffcb4a29 vkd3d-shader: Replace assert() with VKD3D_ASSERT() in d3dbc.c 2024-07-30 16:32:59 +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
8724cbe5d5 vkd3d-shader/d3dbc: Implement HLSL_OP3_MAD for SM1. 2024-07-16 18:56:44 +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