Shaun Ren
59b87c769a
vkd3d-shader/hlsl: Flatten conditional blocks containing discard_neg instructions.
...
For any `discard_neg c` instruction in a conditional block, we replace c with
cond ? c : 0 in a then block,
and
cond ? 0 : c in an else block.
2025-10-30 17:46:12 +01:00
Shaun Ren
787d49d6d8
vkd3d-shader/hlsl: Flatten conditional blocks containing discard_nz instructions.
...
For any `discard_nz c` instruction in a conditional block, we replace c with
(cond && c) in a then block,
and
(!cond && c) in an else block.
2025-10-30 17:46:12 +01:00
Shaun Ren
4d5a1528ab
vkd3d-shader/hlsl: Flatten conditional branches containing stores.
...
For an if block
if (cond)
{
<then_block>
}
else
{
<else_block>
}
We flatten it by first replacing any store instruction `v[[k]] = x`
in the then_block with the following:
1: load(v[[k]])
2: cond ? x : @1
3: v[[k]] = @2
Similarly, we replace any store instruction `v[[k]] = x` in the
else_block with the following:
1: load(v[[k]])
2: cond ? @1 : x
3: v[[k]] = @2
Then we can concatenate <then_block> and <else_block> together and
get rid of the if block.
2025-10-30 17:46:12 +01:00
Shaun Ren
200e66ba4f
vkd3d-shader/hlsl: Store the flatten type in struct hlsl_ir_if.
2025-10-30 17:46:12 +01:00
Shaun Ren
cf688f87f1
vkd3d-shader/hlsl: Cast discard_neg conditions to vec4 for d3dbc target profiles.
2025-10-30 17:46:12 +01:00
Elizabeth Figura
94c9595196
vkd3d-shader/hlsl: Use replace_ir() for fold_conditional_identities().
2025-10-28 16:30:49 +01:00
Elizabeth Figura
1f40222a0d
vkd3d-shader/hlsl: Use replace_ir() for hlsl_fold_constant_exprs().
2025-10-28 16:30:49 +01:00
Elizabeth Figura
6e8eeb8f7a
vkd3d-shader/hlsl: Use replace_ir() for hlsl_fold_constant_identities().
2025-10-28 16:30:49 +01:00
Elizabeth Figura
bdb31a4983
vkd3d-shader/hlsl: Use replace_ir() for hlsl_fold_constant_swizzles().
2025-10-28 16:30:49 +01:00
Elizabeth Figura
deb7a67d67
vkd3d-shader/hlsl: Introduce hlsl_block_add_constant().
2025-10-28 16:30:49 +01:00
Elizabeth Figura
937b80f3f2
vkd3d-shader: Remove the no longer used flat_constant_count field from struct vsir_program.
2025-10-13 18:40:25 +02:00
Elizabeth Figura
db41ba557b
vkd3d-shader/hlsl: Create vsir descriptor info in hlsl_parse().
2025-10-13 18:25:05 +02:00
Elizabeth Figura
0bfed6587a
vkd3d-shader/hlsl: Use replace_ir() for fold_redundant_casts().
2025-10-09 13:21:47 +02:00
Elizabeth Figura
adc8d5cfad
vkd3d-shader/hlsl: Use replace_ir() for fold_trivial_swizzles().
2025-10-09 13:21:47 +02:00
Elizabeth Figura
2a4ac90ad2
vkd3d-shader/hlsl: Use replace_ir() for fold_swizzle_chains().
2025-10-09 13:21:47 +02:00
Elizabeth Figura
f3522eae2e
vkd3d-shader/hlsl: Rename lower_ir() to replace_ir().
...
We want to use it for folding passes as well, but describing these as "lowering"
is not very accurate. Use the more generic term "replace".
2025-10-09 13:21:47 +02:00
Elizabeth Figura
be31842197
vkd3d-shader/hlsl: Return a node from lower_ir().
...
This allows us to use the same function for "folding" passes, which usually
replace with a node other than the last one added in a block.
2025-10-09 13:20:46 +02:00
Shaun Ren
d5770cd347
vkd3d-shader/hlsl: Add support for the centroid interpolation mode in SM1.
2025-10-06 15:18:50 +02:00
Shaun Ren
cc53965ea9
vkd3d-shader/hlsl: Reject SM1 programs with interpolation modifiers.
2025-10-06 14:39:47 +02:00
Elizabeth Figura
c7529028eb
vkd3d-shader/hlsl: Use unique IDs for descriptors before 5.1.
2025-10-06 14:22:58 +02:00
Elizabeth Figura
62b7c5b5e6
vkd3d-shader/hlsl: Use the semantic.resource_type field for texture DCL instructions.
...
ins->resource_type is intended for VKD3D_SM5_MODIFIER_RESOURCE_TYPE, which is
not used for DCL instructions. At the same time, the validator checks
semantic.resource_type, and would break on HLSL shaders.
2025-10-06 14:22:58 +02:00
Petrichor Park
e35604dbf0
vkd3d-shader/hlsl: Implement the firstbitlow() intrinsic.
2025-09-22 11:26:42 +02:00
Petrichor Park
e6d840170d
vkd3d-shader/hlsl: Implement the firstbithigh() intrinsic.
2025-09-22 11:26:42 +02:00
Petrichor Park
e49beca0d5
vkd3d-shader/hlsl: Implement the countbits() intrinsic.
2025-09-22 11:26:42 +02:00
Henri Verbeet
47f2ec1a08
vkd3d-shader/ir: Require default swizzles on vec4 immediate constants.
...
The SPIR-V, GLSL and MSL backends implicitly handle swizzles on
immediate constants, but the TPF and d3d-asm backends assume a default
swizzle. In principle there's no reason those couldn't support swizzles
on immediate constants, but they're a little pointless.
2025-09-18 11:35:05 +02:00