Commit Graph

2398 Commits

Author SHA1 Message Date
a9aaa59df0 vkd3d-shader/sm4: Store parsed instructions in an array. 2023-01-24 18:11:08 +01:00
007f894b94 vkd3d-shader/sm1: Store parsed instructions in an array. 2023-01-24 18:11:06 +01:00
6b82ba9488 vkd3d-shader/hlsl: Fold swizzle chains. 2023-01-24 18:10:53 +01:00
b7d34e8307 vkd3d-shader/hlsl: Apply copy propagation to swizzled loads. 2023-01-24 18:10:50 +01:00
18adf0d726 vkd3d-shader/hlsl: Use aoffimmis when writing gather resource loads.
If the offset of a gather resource load can be represented as an
aoffimmi (vectori of ints from -8 to 7), use one.
This is of particular importance for 4.0 profiles, where this is the only
valid way of representing offsets for this operation.
2023-01-24 18:10:49 +01:00
c2a7a40d3a vkd3d-shader/hlsl: Replace loads with constants in copy prop.
If a hlsl_ir_load loads a variable whose components are stored from different
instructions, copy propagation doesn't replace it.

But if all these instructions are constants (which currently is the case
for value constructors), the load could be replaced with a constant value.
Which is expected in some other instructions, e.g. texel_offsets when
using aoffimmi modifiers.

For instance, this shader:

```
sampler s;
Texture2D t;

float4 main() : sv_target
{
    return t.Gather(s, float2(0.6, 0.6), int2(0, 0));
}
```

results in the following IR before applying the patch:
```
  float | 6.00000024e-01
  float | 6.00000024e-01
   uint | 0
        | = (<constructor-2>[@4].x @2)
   uint | 1
        | = (<constructor-2>[@6].x @3)
 float2 | <constructor-2>
    int | 0
    int | 0
   uint | 0
        | = (<constructor-5>[@11].x @9)
   uint | 1
        | = (<constructor-5>[@13].x @10)
   int2 | <constructor-5>
 float4 | gather_red(resource = t, sampler = s, coords = @8, offset = @15)
        | return
        | = (<output-sv_target0> @16)
```

and this IR afterwards:
```
 float2 | {6.00000024e-01 6.00000024e-01 }
   int2 | {0 0 }
 float4 | gather_red(resource = t, sampler = s, coords = @2, offset = @3)
        | return
        | = (<output-sv_target0> @4)
```
2023-01-24 18:10:45 +01:00
8c2b8ff245 vkd3d-shader/hlsl: Synthesize the swizzle and replace the instruction inside of copy_propagation_compute_replacement().
Rename it to copy_propagation_replace_with_single_instr() accordingly.

The idea is to introduce a constant vector replacement pass which will do the
same thing.
2023-01-24 18:10:41 +01:00
5d34790402 vkd3d-shader/hlsl: Call copy_propagation_get_value() directly in copy_propagation_transform_object_load().
copy_propagation_compute_replacement() is not doing very much for us, and
conceptually is a bit of an odd fit anyway, since it's meant to deal with
multi-component types.
2023-01-24 18:10:40 +01:00
8fd30aa87d vkd3d-shader/hlsl: Add some swizzle manipulation definitions. 2023-01-24 18:10:39 +01:00
cf17882189 vkd3d-shader/hlsl: Support offset argument for the texture Load() method. 2023-01-24 18:10:36 +01:00
9c817e5e6d vkd3d-shader/hlsl: Forbid recursive calls. 2023-01-19 19:16:27 +01:00
521f22e57a vkd3d-shader/hlsl: Store a non-constant hlsl_ir_function_decl pointer in struct hlsl_ir_call. 2023-01-19 19:16:25 +01:00
447463e590 vkd3d-shader/hlsl: Remove the unused "intrinsic" argument from hlsl_add_function(). 2023-01-19 19:16:24 +01:00
6c2472ce16 vkd3d-shader/hlsl: Remove some unnecessary YYABORTs from the func_prototype_no_attrs rule. 2023-01-19 19:16:22 +01:00
13c8e8b856 vkd3d-shader/hlsl: Parse step() intrinsic. 2023-01-19 19:16:17 +01:00
6fbf2b3e75 vkd3d-shader/hlsl: Parse sqrt() intrinsic. 2023-01-19 19:16:16 +01:00
8d5f16d803 vkd3d-shader/hlsl: Support cos() intrinsic. 2023-01-19 19:16:15 +01:00
3239ea5ff1 vkd3d-shader/hlsl: Support sin() intrinsic. 2023-01-19 19:16:14 +01:00
2b1ec0cfe5 vkd3d-shader/hlsl: Add field-level documentation to struct hlsl_scope. 2023-01-19 19:16:08 +01:00
eabd742f3e vkd3d-shader/hlsl: Add field-level documentation to function structs. 2023-01-19 19:16:07 +01:00
c68d0ecfe0 vkd3d-shader/hlsl: Add field-level documentation to struct hlsl_buffer. 2023-01-19 19:16:06 +01:00
ba56833bb5 vkd3d-shader/hlsl: Add documentation to small hlsl.h structs. 2023-01-19 19:16:04 +01:00
06b52c0343 vkd3d-shader/hlsl: Add field-level documentation to struct hlsl_deref. 2023-01-19 19:15:59 +01:00
f33d433621 vkd3d-shader/hlsl: Add documentation to struct hlsl_reg. 2023-01-19 19:15:57 +01:00
aab9886021 vkd3d-shader/hlsl: Allow uninitialized static objects.
validate_static_object_references() validates that uninitialized static
objects are not referenced in the shader.

In case a static variable contains both numeric and object types, the
"Static variables cannot have both numeric and resource components."
error should preempt uninitialized numeric values to reach further
compilation steps.
2023-01-19 12:29:41 +01:00