Module: vkd3d Branch: master Commit: 61a17643a2b27336f997a34642c853b6c3b44f52 URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/61a17643a2b27336f997a34642c853...
Author: Francisco Casas fcasas@codeweavers.com Date: Tue Oct 3 16:47:13 2023 -0300
vkd3d-shader/hlsl: Split deref-offset into a node and a constant uint.
This uint will be used for the following:
- Since SM4's relative addressing (the capability of passing a register as an index to another register) only has whole-register granularity, we will need to make the offset node express the offset in whole-registers and specify the register component in this uint, otherwise we would have to add additional / and % operations in the output binary.
- If, after we apply constant folding and copy propagation, we determine that the offset is a single constant node, we can store all the offset in this uint constant, and remove the offset src.
This allows DCE to remove a good bunch of the nodes previously required only for the offset constants, which makes the output more liteweight and readable, and simplifies the implementation of relative addressing when writing tpf in the following patches.
In dump_deref(), we use "c" to indicate components instead of whole registers. Since now both the offset node and the offset uint are in components a lowered deref would look like:
var[@42c + 2c]
But, once we express the offset node in whole registers we will remove the "c" from the node part:
var[@22 + 3c]
---
libs/vkd3d-shader/hlsl.c | 33 ++++++++++++++----- libs/vkd3d-shader/hlsl.h | 12 ++++--- libs/vkd3d-shader/hlsl_codegen.c | 68 ++++++++++++++++++++++++---------------- 3 files changed, 74 insertions(+), 39 deletions(-)