summaryrefslogtreecommitdiffstats
path: root/tests/vkray
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2018-12-14 11:00:02 -0800
committerGitHub <noreply@github.com>2018-12-14 11:00:02 -0800
commitec745c032a8dc16c3e689458c20541a4e7aa64d6 (patch)
tree69b4455cbaedf0ab4c887798aada1929962a7a53 /tests/vkray
parent11793edf25a4907fe396d69fd3cdddaee3d421d5 (diff)
Represent global shader parameters explicitly in the IR (#756)
Before this change, global shader parameters were represented in the IR as just being ordinary global variables. The only indication that a particular global represented a parameter was when it got a layotu attached to it (as part of back-end processing), and we've had a number of bugs related to layouts being dropped so that what should have been a shader parameter turned into an ordinary global variable in the output. This change is more strongly motivated by the fact that making shader parameters look like globals means that we cannot easily reason about their value when doing IR transformations. If we see two `load`s from the same global variable can we assume they yield the same value? In the general case we cannot, and this means that any transformation that wants to rely on the fact that an input `Texture2D` shader parameter can't actually change over the life of the program needs to do extra work. The fix here is to introduce a new kind of IR instruction that represents a global shader parameter directly (not a pointer to it as a global would), at which point there isn't even such a notion as a "load" from the parameter, since it represents the value directly. In several cases logic that used to apply to global variables in case they were shader parameters (by looking for a layout) is now moved to apply to these global parameters. The biggest source of issues in this change was that switching from pointers to plain values to represent these shader parameters stresses different cases in type legalization. I also had to deal with the case of legalization for GLSL where we actually *do* need global shader parameters that are writable (since varying output goes in the global scope), but in that case I borrowed the use of pointer-like `Out<...>` and `InOut<...>` types to represent that intent, which we were already using for function parameters representing outputs. A few tests started failing because the changes lead to a slightly different order of code emission, which in some HLSL tests resulted in a function parameter named `s` getting emitted before a global parameter named `s`, leading to the latter getting the name `s_1` instead of `s_0`. A few SPIR-V tests started failing because the new approach means that we no longer end up performing a load from all varying input parameters at the start of `main` and instead reference the varying inputs directly. The resulting code is more idomatic, but it differed from the baselines for those tests.
Diffstat (limited to 'tests/vkray')
-rw-r--r--tests/vkray/anyhit.slang.glsl4
-rw-r--r--tests/vkray/closesthit.slang.glsl19
2 files changed, 9 insertions, 14 deletions
diff --git a/tests/vkray/anyhit.slang.glsl b/tests/vkray/anyhit.slang.glsl
index 07789cdbd..622080399 100644
--- a/tests/vkray/anyhit.slang.glsl
+++ b/tests/vkray/anyhit.slang.glsl
@@ -33,13 +33,11 @@ rayPayloadInNV ShadowRay_0 _S3;
void main()
{
- SphereHitAttributes_0 _S4 = _S2;
-
if(bool(gParams_0._data.mode_0))
{
float val_0 = textureLod(
sampler2D(gParams_alphaMap_0, gParams_sampler_0),
- _S4.normal_0.xy,
+ _S2.normal_0.xy,
float(0)).x;
diff --git a/tests/vkray/closesthit.slang.glsl b/tests/vkray/closesthit.slang.glsl
index 79fd3afbe..46c5ea636 100644
--- a/tests/vkray/closesthit.slang.glsl
+++ b/tests/vkray/closesthit.slang.glsl
@@ -6,15 +6,14 @@
#define tmp_colors _S2
#define tmp_hitattrs _S3
#define tmp_payload _S4
-#define tmp_localattrs _S5
-#define tmp_customidx _S6
-#define tmp_instanceid _S7
-#define tmp_add_0 _S8
-#define tmp_primid _S9
-#define tmp_add_1 _S10
-#define tmp_hitkind _S11
-#define tmp_hitt _S12
-#define tmp_tmin _S13
+#define tmp_customidx _S5
+#define tmp_instanceid _S6
+#define tmp_add_0 _S7
+#define tmp_primid _S8
+#define tmp_add_1 _S9
+#define tmp_hitkind _S10
+#define tmp_hitt _S11
+#define tmp_tmin _S12
struct SLANG_ParameterGroup_ShaderRecord_0
{
@@ -49,8 +48,6 @@ rayPayloadInNV ReflectionRay_0 tmp_payload;
void main()
{
- BuiltInTriangleIntersectionAttributes_0 tmp_localattrs = tmp_hitattrs;
-
uint tmp_customidx = gl_InstanceCustomIndexNV;
uint tmp_instanceid = gl_InstanceID;