HLSL: phase 2b: add l-value operator[] for RWTexture/RWBuffer

This commit adds l-value support for RW texture and buffer objects.
Supported are:

- pre and post inc/decrement
- function out parameters
- op-assignments, such as *=, +-, etc.
- result values from op-assignments.  e.g, val=(MyRwTex[loc] *= 2);

Not supported are:
- Function inout parameters
- multiple post-inc/decrement operators.  E.g, MyRWTex[loc]++++;
This commit is contained in:
steve-lunarg
2016-10-07 19:35:40 -06:00
parent 6b43d274e7
commit 90707966ea
6 changed files with 2766 additions and 586 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -35,6 +35,10 @@ uniform int2 o2;
uniform int3 o3;
uniform int4 o4;
uniform float4 uf4;
uniform int4 ui4;
uniform uint4 uu4;
int4 Fn1(in int4 x) { return x; }
uint4 Fn1(in uint4 x) { return x; }
float4 Fn1(in float4 x) { return x; }
@@ -43,19 +47,19 @@ void Fn2(out int4 x) { x = int4(0); }
void Fn2(out uint4 x) { x = uint4(0); }
void Fn2(out float4 x) { x = float4(0); }
float4 SomeValue() { return c4; }
PS_OUTPUT main()
{
PS_OUTPUT psout;
// Test as R-values
// 1D
g_tTex1df4[c1];
float4 r00 = g_tTex1df4[c1];
int4 r01 = g_tTex1di4[c1];
uint4 r02 = g_tTex1du4[c1];
// 2D
float4 r10 = g_tTex2df4[c2];
int4 r11 = g_tTex2di4[c2];
@@ -66,47 +70,66 @@ PS_OUTPUT main()
int4 r21 = g_tTex3di4[c3];
uint4 r22 = g_tTex3du4[c3];
// // Test as L-values
// // 1D
// g_tTex1df4[c1] = float4(1,2,3,4);
// g_tTex1di4[c1] = int4(1,2,3,4);
// g_tTex1du4[c1] = uint4(1,2,3,4);
float4 lf4 = uf4;
// Test as L-values
// 1D
g_tTex1df4[c1] = SomeValue(); // complex L-value
g_tTex1df4[c1] = lf4;
g_tTex1di4[c1] = int4(2,2,3,4);
g_tTex1du4[c1] = uint4(3,2,3,4);
// Test some operator= things, which need to do both a load and a store.
float4 val1 = (g_tTex1df4[c1] *= 2.0);
g_tTex1df4[c1] -= 3.0;
g_tTex1df4[c1] += 4.0;
// // 2D
// g_tTex2df4[c2] = float4(1,2,3,4);
// g_tTex2di4[c2] = int4(1,2,3,4);
// g_tTex2du4[c2] = uint4(1,2,3,4);
g_tTex1di4[c1] /= 2;
g_tTex1di4[c1] %= 2;
g_tTex1di4[c1] &= 0xffff;
g_tTex1di4[c1] |= 0xf0f0;
g_tTex1di4[c1] <<= 2;
g_tTex1di4[c1] >>= 2;
// 2D
g_tTex2df4[c2] = SomeValue(); // complex L-value
g_tTex2df4[c2] = lf4;
g_tTex2di4[c2] = int4(5,2,3,4);
g_tTex2du4[c2] = uint4(6,2,3,4);
// // 3D
// g_tTex3df4[c3] = float4(1,2,3,4);
// g_tTex3di4[c3] = int4(1,2,3,4);
// g_tTex3du4[c3] = uint4(1,2,3,4);
// 3D
g_tTex3df4[c3] = SomeValue(); // complex L-value
g_tTex3df4[c3] = lf4;
g_tTex3di4[c3] = int4(8,6,7,8);
g_tTex3du4[c3] = uint4(9,2,3,4);
// // Test function calling
Fn1(g_tTex1df4[c1]); // in
Fn1(g_tTex1di4[c1]); // in
Fn1(g_tTex1du4[c1]); // in
// Fn2(g_tTex1df4[c1]); // out
// Fn2(g_tTex1di4[c1]); // out
// Fn2(g_tTex1du4[c1]); // out
Fn2(g_tTex1df4[c1]); // out
Fn2(g_tTex1di4[c1]); // out
Fn2(g_tTex1du4[c1]); // out
// // Test increment operators
// g_tTex1df4[c1]++;
// g_tTex1di4[c1]++;
// g_tTex1du4[c1]++;
// Test increment operators
// pre-ops
++g_tTex1df4[c1];
++g_tTex1di4[c1];
++g_tTex1du4[c1];
// g_tTex1df4[c1]--;
// g_tTex1di4[c1]--;
// g_tTex1du4[c1]--;
--g_tTex1df4[c1];
--g_tTex1di4[c1];
--g_tTex1du4[c1];
// ++g_tTex1df4[c1];
// ++g_tTex1di4[c1];
// ++g_tTex1du4[c1];
// post-ops
g_tTex1df4[c1]++;
g_tTex1du4[c1]--;
g_tTex1di4[c1]++;
// --g_tTex1df4[c1];
// --g_tTex1di4[c1];
// --g_tTex1du4[c1];
g_tTex1df4[c1]--;
g_tTex1di4[c1]++;
g_tTex1du4[c1]--;
psout.Color = 1.0;