vkd3d-shader/hlsl: Implement struct single inheritance.

Here, we implement single inheritance by inserting a field at the
beginning of the derived struct with name "$super".

For the following struct declarations

  struct a
  {
      float4 aa;
      float4 bb;
  };

  struct b : a
  {
      float4 cc;
  };

  struct c : b
  {
      float4 bb;
  };

this commit generates the following:

  struct a
  {
      float4 aa;
      float4 bb;
  };

  struct b
  {
      struct a $super;
      float4 cc;
  };

  struct c
  {
      struct b $super;
      float4 bb;
  };
This commit is contained in:
Shaun Ren
2024-10-15 16:50:08 -04:00
committed by Henri Verbeet
parent 013e354b46
commit 069b8aac64
Notes: Henri Verbeet 2024-10-16 21:47:12 +02:00
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1157
2 changed files with 68 additions and 19 deletions

View File

@@ -1,4 +1,4 @@
[pixel shader todo(sm<6)]
[pixel shader]
struct a
{
@@ -28,12 +28,12 @@ uniform 0 float4 1 0 0 0
uniform 4 float4 0 2 0 0
uniform 8 float4 0 0 3 0
uniform 12 float4 0 0 0 4
todo(sm<6) draw quad
draw quad
probe (0, 0) rgba (1, 0, 3, 4)
% Test writing to a field derived from a base class.
[pixel shader todo(sm<6)]
[pixel shader]
struct a
{
@@ -66,7 +66,7 @@ uniform 0 float4 1 0 0 0
uniform 4 float4 0 2 0 0
uniform 8 float4 0 0 3 0
uniform 12 float4 0 0 0 4
todo(sm<6) draw quad
draw quad
probe (0, 0) rgba (-1, 0, 3, -4)