summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDarren Wihandi <65404740+fairywreath@users.noreply.github.com>2024-12-20 01:00:20 -0500
committerGitHub <noreply@github.com>2024-12-19 22:00:20 -0800
commita00db74d1afa717dd90dfcf3170c63d0d1c0d3d7 (patch)
tree0e286826852990c9fb5b4e531a5b3eeb1da48f96 /tests
parent2e9605e79c64315ecad7ae8297d996ae2ed4687b (diff)
Add base vertex and base instance system values (#5918)
* Add base vertex and base instance system values * Fixed incorrect stage in tests
Diffstat (limited to 'tests')
-rw-r--r--tests/glsl-intrinsic/system-values-draw-parameters.slang19
-rw-r--r--tests/hlsl-intrinsic/system-values-draw-parameters.slang34
2 files changed, 53 insertions, 0 deletions
diff --git a/tests/glsl-intrinsic/system-values-draw-parameters.slang b/tests/glsl-intrinsic/system-values-draw-parameters.slang
new file mode 100644
index 000000000..a58305c13
--- /dev/null
+++ b/tests/glsl-intrinsic/system-values-draw-parameters.slang
@@ -0,0 +1,19 @@
+//TEST:SIMPLE(filecheck=CHECK_SPIRV): -entry main -stage vertex -target spirv
+//TEST:SIMPLE(filecheck=CHECK_GLSL): -entry main -stage vertex -target glsl
+//TEST:SIMPLE(filecheck=CHECK_HLSL): -entry main -stage vertex -target hlsl
+//TEST:SIMPLE(filecheck=CHECK_METAL): -entry main -stage vertex -target metal
+
+#version 460
+
+void main()
+{
+ float x = float(gl_VertexIndex + gl_BaseVertex) * 0.1f;
+ float y = float(gl_InstanceIndex + gl_BaseInstance) * 0.2f;
+ gl_Position = vec4(x, y, 0.0f, 1.0f); // Output 2D position with z=0 and w=1.
+
+ // CHECK_SPIRV: BuiltIn BaseInstance
+ // CHECK_GLSL: gl_BaseInstance
+ // CHECK_HLSL: SV_StartInstanceLocation
+ // CHECK_METAL: base_instance
+}
+
diff --git a/tests/hlsl-intrinsic/system-values-draw-parameters.slang b/tests/hlsl-intrinsic/system-values-draw-parameters.slang
new file mode 100644
index 000000000..ea84ac116
--- /dev/null
+++ b/tests/hlsl-intrinsic/system-values-draw-parameters.slang
@@ -0,0 +1,34 @@
+//TEST:SIMPLE(filecheck=CHECK_SPIRV): -entry main -stage vertex -target spirv
+//TEST:SIMPLE(filecheck=CHECK_GLSL): -entry main -stage vertex -target glsl
+//TEST:SIMPLE(filecheck=CHECK_HLSL): -entry main -stage vertex -target hlsl
+//TEST:SIMPLE(filecheck=CHECK_METAL): -entry main -stage vertex -target metal
+
+struct VSInput
+{
+ uint vertexID : SV_VertexID;
+ uint instanceID : SV_InstanceID;
+};
+
+struct VSOutput
+{
+ float4 position : SV_POSITION;
+};
+
+VSOutput main(VSInput input,
+ uint startVertexLocation : SV_StartVertexLocation,
+ uint startInstanceLocation : SV_StartInstanceLocation)
+{
+ VSOutput output;
+
+ float x = (float)(input.vertexID + startVertexLocation) * 0.1f;
+ float y = (float)(input.instanceID + startInstanceLocation) * 0.2f;
+ output.position = float4(x, y, 0.0f, 1.0f);
+
+ // CHECK_SPIRV: BuiltIn BaseInstance
+ // CHECK_GLSL: gl_BaseInstance
+ // CHECK_HLSL: SV_StartInstanceLocation
+ // CHECK_METAL: base_instance
+
+ return output;
+}
+