Commit Graph

155 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
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
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
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
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