summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2023-05-03 20:16:58 -0400
committerGitHub <noreply@github.com>2023-05-03 20:16:58 -0400
commitc9ef8d58a135061262fd321a82061d27dc733cf5 (patch)
tree888bee92d8519fe80ec9d5dbb95c2dc8da985865 /tests
parentbf2b05528d6edbbf1beb87552f447d29f92eee47 (diff)
HLSL->Vulkan binding support (#2865)
* WIP around VK shift binding. * Refactor around options parsing. * Remove needless passing around of sink. * Some more tidying around OptionsParser. * Handle vulkan shift parsing. * Fix small issue around vk binding and "all". * Fixing some small issues. Missing break. * Split out VulkanLayoutOptions * WIP binding taking into account HLSL->Vulkan options. * First attempt at making binding work with HLSLVulkanOptions. * VulkanLayoutOptions -> HLSLToVulkanLayoutOptions * WIP with HLSL-Vulkan binding. * Some more testing around vk-shift. * Improvements around global binding. More tests. * Improve test coverage. Improve checking for requirements around default space. * Update command line options. * Small fixes. * Small fix in options reporting. * Fix warning issue. * Some fixes for isDefault for HLSLToVulkanLayoutOptions. * Update hlsl-to-vulkan-shift output. The difference was due to default handling if shift isn't specified, and not being specified was not correctly tracked.
Diffstat (limited to 'tests')
-rw-r--r--tests/bindings/hlsl-to-vulkan-combined.hlsl9
-rw-r--r--tests/bindings/hlsl-to-vulkan-combined.hlsl.expected54
-rw-r--r--tests/bindings/hlsl-to-vulkan-global.hlsl12
-rw-r--r--tests/bindings/hlsl-to-vulkan-global.hlsl.expected77
-rw-r--r--tests/bindings/hlsl-to-vulkan-shift.hlsl21
-rw-r--r--tests/bindings/hlsl-to-vulkan-shift.hlsl.expected178
6 files changed, 351 insertions, 0 deletions
diff --git a/tests/bindings/hlsl-to-vulkan-combined.hlsl b/tests/bindings/hlsl-to-vulkan-combined.hlsl
new file mode 100644
index 000000000..20668b01b
--- /dev/null
+++ b/tests/bindings/hlsl-to-vulkan-combined.hlsl
@@ -0,0 +1,9 @@
+//TEST:REFLECTION:-target glsl -profile ps_4_0 -entry main -fvk-t-shift 5 all -fvk-t-shift 7 2 -fvk-s-shift -3 0 -fvk-b-shift 1 2
+
+Sampler2D<float> t0 : register(t2);
+Sampler2D<float4> t1 : register(t7, space2);
+
+float4 main() : SV_TARGET
+{
+ return float4(1, 1, 1, 0);
+} \ No newline at end of file
diff --git a/tests/bindings/hlsl-to-vulkan-combined.hlsl.expected b/tests/bindings/hlsl-to-vulkan-combined.hlsl.expected
new file mode 100644
index 000000000..127d0fe4c
--- /dev/null
+++ b/tests/bindings/hlsl-to-vulkan-combined.hlsl.expected
@@ -0,0 +1,54 @@
+result code = 0
+standard error = {
+}
+standard output = {
+{
+ "parameters": [
+ {
+ "name": "t0",
+ "binding": {"kind": "descriptorTableSlot", "index": 7},
+ "type": {
+ "kind": "resource",
+ "baseShape": "texture2D"
+ }
+ },
+ {
+ "name": "t1",
+ "binding": {"kind": "descriptorTableSlot", "space": 2, "index": 14},
+ "type": {
+ "kind": "resource",
+ "baseShape": "texture2D"
+ }
+ }
+ ],
+ "entryPoints": [
+ {
+ "name": "main",
+ "stage:": "fragment",
+ "result:": {
+ "stage": "fragment",
+ "binding": {"kind": "varyingOutput", "index": 0},
+ "semanticName": "SV_TARGET",
+ "type": {
+ "kind": "vector",
+ "elementCount": 4,
+ "elementType": {
+ "kind": "scalar",
+ "scalarType": "float32"
+ }
+ }
+ },
+ "bindings": [
+ {
+ "name": "t0",
+ "binding": {"kind": "descriptorTableSlot", "index": 7}
+ },
+ {
+ "name": "t1",
+ "binding": {"kind": "descriptorTableSlot", "space": 2, "index": 14}
+ }
+ ]
+ }
+ ]
+}
+}
diff --git a/tests/bindings/hlsl-to-vulkan-global.hlsl b/tests/bindings/hlsl-to-vulkan-global.hlsl
new file mode 100644
index 000000000..aceec02ba
--- /dev/null
+++ b/tests/bindings/hlsl-to-vulkan-global.hlsl
@@ -0,0 +1,12 @@
+//TEST:REFLECTION:-target glsl -profile ps_4_0 -entry main -fvk-bind-globals 5 9
+
+uniform int a;
+uniform float b;
+
+Texture2D t;
+SamplerState sampler;
+
+float4 main() : SV_TARGET
+{
+ return t.SampleLevel(sampler, float2(a,b), 0) + float4(a, b, 1, 0);
+} \ No newline at end of file
diff --git a/tests/bindings/hlsl-to-vulkan-global.hlsl.expected b/tests/bindings/hlsl-to-vulkan-global.hlsl.expected
new file mode 100644
index 000000000..b0b8f6a17
--- /dev/null
+++ b/tests/bindings/hlsl-to-vulkan-global.hlsl.expected
@@ -0,0 +1,77 @@
+result code = 0
+standard error = {
+}
+standard output = {
+{
+ "parameters": [
+ {
+ "name": "a",
+ "binding": {"kind": "uniform", "offset": 0, "size": 4},
+ "type": {
+ "kind": "scalar",
+ "scalarType": "int32"
+ }
+ },
+ {
+ "name": "b",
+ "binding": {"kind": "uniform", "offset": 4, "size": 4},
+ "type": {
+ "kind": "scalar",
+ "scalarType": "float32"
+ }
+ },
+ {
+ "name": "t",
+ "binding": {"kind": "descriptorTableSlot", "index": 0},
+ "type": {
+ "kind": "resource",
+ "baseShape": "texture2D"
+ }
+ },
+ {
+ "name": "sampler",
+ "binding": {"kind": "descriptorTableSlot", "index": 1},
+ "type": {
+ "kind": "samplerState"
+ }
+ }
+ ],
+ "entryPoints": [
+ {
+ "name": "main",
+ "stage:": "fragment",
+ "result:": {
+ "stage": "fragment",
+ "binding": {"kind": "varyingOutput", "index": 0},
+ "semanticName": "SV_TARGET",
+ "type": {
+ "kind": "vector",
+ "elementCount": 4,
+ "elementType": {
+ "kind": "scalar",
+ "scalarType": "float32"
+ }
+ }
+ },
+ "bindings": [
+ {
+ "name": "a",
+ "binding": {"kind": "uniform", "offset": 0, "size": 4}
+ },
+ {
+ "name": "b",
+ "binding": {"kind": "uniform", "offset": 4, "size": 4}
+ },
+ {
+ "name": "t",
+ "binding": {"kind": "descriptorTableSlot", "index": 0}
+ },
+ {
+ "name": "sampler",
+ "binding": {"kind": "descriptorTableSlot", "index": 1}
+ }
+ ]
+ }
+ ]
+}
+}
diff --git a/tests/bindings/hlsl-to-vulkan-shift.hlsl b/tests/bindings/hlsl-to-vulkan-shift.hlsl
new file mode 100644
index 000000000..8981b6be6
--- /dev/null
+++ b/tests/bindings/hlsl-to-vulkan-shift.hlsl
@@ -0,0 +1,21 @@
+//TEST:REFLECTION:-target glsl -profile ps_4_0 -entry main -fvk-t-shift 5 all -fvk-t-shift 7 2 -fvk-s-shift -3 0 -fvk-b-shift 1 2
+
+struct Data
+{
+ float a;
+ int b;
+};
+
+Texture2D t : register(t0);
+SamplerState s : register(s4);
+ConstantBuffer<Data> c : register(b2);
+
+Texture2D t2 : register(t0, space2);
+
+RWStructuredBuffer<Data> u : register(u11);
+RWStructuredBuffer<int> u2 : register(u3, space2);
+
+float4 main() : SV_TARGET
+{
+ return float4(1, 1, 1, 0);
+} \ No newline at end of file
diff --git a/tests/bindings/hlsl-to-vulkan-shift.hlsl.expected b/tests/bindings/hlsl-to-vulkan-shift.hlsl.expected
new file mode 100644
index 000000000..b0d8ace6f
--- /dev/null
+++ b/tests/bindings/hlsl-to-vulkan-shift.hlsl.expected
@@ -0,0 +1,178 @@
+result code = 0
+standard error = {
+}
+standard output = {
+{
+ "parameters": [
+ {
+ "name": "t",
+ "binding": {"kind": "descriptorTableSlot", "index": 5},
+ "type": {
+ "kind": "resource",
+ "baseShape": "texture2D"
+ }
+ },
+ {
+ "name": "s",
+ "binding": {"kind": "descriptorTableSlot", "index": 1},
+ "type": {
+ "kind": "samplerState"
+ }
+ },
+ {
+ "name": "c",
+ "binding": {"kind": "descriptorTableSlot", "index": 0},
+ "type": {
+ "kind": "constantBuffer",
+ "elementType": {
+ "kind": "struct",
+ "name": "Data",
+ "fields": [
+ {
+ "name": "a",
+ "type": {
+ "kind": "scalar",
+ "scalarType": "float32"
+ },
+ "binding": {"kind": "uniform", "offset": 0, "size": 4}
+ },
+ {
+ "name": "b",
+ "type": {
+ "kind": "scalar",
+ "scalarType": "int32"
+ },
+ "binding": {"kind": "uniform", "offset": 4, "size": 4}
+ }
+ ]
+ },
+ "containerVarLayout": {
+ "binding": {"kind": "descriptorTableSlot", "index": 0}
+ },
+ "elementVarLayout": {
+ "type": {
+ "kind": "struct",
+ "name": "Data",
+ "fields": [
+ {
+ "name": "a",
+ "type": {
+ "kind": "scalar",
+ "scalarType": "float32"
+ },
+ "binding": {"kind": "uniform", "offset": 0, "size": 4}
+ },
+ {
+ "name": "b",
+ "type": {
+ "kind": "scalar",
+ "scalarType": "int32"
+ },
+ "binding": {"kind": "uniform", "offset": 4, "size": 4}
+ }
+ ]
+ },
+ "binding": {"kind": "uniform", "offset": 0, "size": 16}
+ }
+ }
+ },
+ {
+ "name": "t2",
+ "binding": {"kind": "descriptorTableSlot", "space": 2, "index": 7},
+ "type": {
+ "kind": "resource",
+ "baseShape": "texture2D"
+ }
+ },
+ {
+ "name": "u",
+ "binding": {"kind": "descriptorTableSlot", "index": 2},
+ "type": {
+ "kind": "resource",
+ "baseShape": "structuredBuffer",
+ "access": "readWrite",
+ "resultType": {
+ "kind": "struct",
+ "name": "Data",
+ "fields": [
+ {
+ "name": "a",
+ "type": {
+ "kind": "scalar",
+ "scalarType": "float32"
+ },
+ "binding": {"kind": "uniform", "offset": 0, "size": 4}
+ },
+ {
+ "name": "b",
+ "type": {
+ "kind": "scalar",
+ "scalarType": "int32"
+ },
+ "binding": {"kind": "uniform", "offset": 4, "size": 4}
+ }
+ ]
+ }
+ }
+ },
+ {
+ "name": "u2",
+ "binding": {"kind": "descriptorTableSlot", "space": 2, "index": 4},
+ "type": {
+ "kind": "resource",
+ "baseShape": "structuredBuffer",
+ "access": "readWrite",
+ "resultType": {
+ "kind": "scalar",
+ "scalarType": "int32"
+ }
+ }
+ }
+ ],
+ "entryPoints": [
+ {
+ "name": "main",
+ "stage:": "fragment",
+ "result:": {
+ "stage": "fragment",
+ "binding": {"kind": "varyingOutput", "index": 0},
+ "semanticName": "SV_TARGET",
+ "type": {
+ "kind": "vector",
+ "elementCount": 4,
+ "elementType": {
+ "kind": "scalar",
+ "scalarType": "float32"
+ }
+ }
+ },
+ "bindings": [
+ {
+ "name": "t",
+ "binding": {"kind": "descriptorTableSlot", "index": 5}
+ },
+ {
+ "name": "s",
+ "binding": {"kind": "descriptorTableSlot", "index": 1}
+ },
+ {
+ "name": "c",
+ "binding": {"kind": "descriptorTableSlot", "index": 0}
+ },
+ {
+ "name": "t2",
+ "binding": {"kind": "descriptorTableSlot", "space": 2, "index": 7}
+ },
+ {
+ "name": "u",
+ "binding": {"kind": "descriptorTableSlot", "index": 2}
+ },
+ {
+ "name": "u2",
+ "binding": {"kind": "descriptorTableSlot", "space": 2, "index": 4}
+ }
+ ]
+ }
+ ]
+}
+}