summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTim Foley <tfoley@nvidia.com>2017-07-07 08:48:45 -0700
committerTim Foley <tfoley@nvidia.com>2017-07-07 08:48:45 -0700
commitd35b4d4bc62beebaa56b949a1ac59470192b5dfc (patch)
tree09c8ef6014eb49fe9a173600a5b8639d4695c34e /tests
parentd644ddcc643be8b30e70b7585a1d32c958e990a4 (diff)
Fix support for `std430` layout
Fixes #57 There were a bunch of issues in how `std430` was being implemented, largely due to just stubbing it in without any test cases. This commit adds a reasonably good test case to ensure that we've got things basically working.
Diffstat (limited to 'tests')
-rw-r--r--tests/reflection/std430-layout.glsl49
-rw-r--r--tests/reflection/std430-layout.glsl.expected107
2 files changed, 156 insertions, 0 deletions
diff --git a/tests/reflection/std430-layout.glsl b/tests/reflection/std430-layout.glsl
new file mode 100644
index 000000000..5d4dee88f
--- /dev/null
+++ b/tests/reflection/std430-layout.glsl
@@ -0,0 +1,49 @@
+//TEST(smoke):SIMPLE:-profile ps_4_0 -target reflection-json
+
+// Confirm fix for GitHub issue #55
+
+struct Foo
+{
+ vec2 f;
+};
+
+layout(set = 0, binding = 0)
+buffer SomeBuffer
+{
+ // offset: 0, size: 4, alignment: 4
+ float a;
+
+ // offset: 16, size: 12, alignment: 16
+ //
+ // Note that it can't immediately follow `a`
+ // bcause of its alignment
+ vec3 b;
+
+ // offset: 28, size: 16, alignment: 4, stride: 4
+ //
+ // This array can be densely packed and 4-byte aligned under `std430` rules
+ float c[4];
+
+ // offset: 48, size: 8, alignment: 8
+ //
+ // This nees to be bumped up to a 8-byte aligned boundary
+ vec2 d;
+
+ // offset: 56, size: 8, alignment: 8
+ //
+ // This can come right after `d`, because `struct` types no longer
+ // get an artificial padding out to 16-byte alignment
+ Foo e;
+
+ // offset: 64, size: 12: alignment: 16
+ vec3 g;
+
+ // offset: 76, size: 4, alignment: 4
+ //
+ // This can fit in the empty space after `g` because we allow
+ // the size of a `vec3` to be smaller than its alignment
+ float h;
+};
+
+void main()
+{}
diff --git a/tests/reflection/std430-layout.glsl.expected b/tests/reflection/std430-layout.glsl.expected
new file mode 100644
index 000000000..701a36909
--- /dev/null
+++ b/tests/reflection/std430-layout.glsl.expected
@@ -0,0 +1,107 @@
+result code = 0
+standard error = {
+}
+standard output = {
+{
+ "parameters": [
+ {
+ "name": "SomeBuffer",
+ "binding": {"kind": "descriptorTableSlot", "index": 0},
+ "type": {
+ "kind": "shaderStorageBuffer",
+ "elementType": {
+ "kind": "struct",
+ "fields": [
+ {
+ "name": "a",
+ "type": {
+ "kind": "scalar",
+ "scalarType": "float32"
+ },
+ "binding": {"kind": "uniform", "offset": 0, "size": 4}
+ },
+ {
+ "name": "b",
+ "type": {
+ "kind": "vector",
+ "elementCount": 3,
+ "elementType": {
+ "kind": "scalar",
+ "scalarType": "float32"
+ }
+ },
+ "binding": {"kind": "uniform", "offset": 16, "size": 12}
+ },
+ {
+ "name": "c",
+ "type": {
+ "kind": "array",
+ "elementCount": 4,
+ "elementType": {
+ "kind": "scalar",
+ "scalarType": "float32"
+ },
+ "uniformStride": 4
+ },
+ "binding": {"kind": "uniform", "offset": 28, "size": 16}
+ },
+ {
+ "name": "d",
+ "type": {
+ "kind": "vector",
+ "elementCount": 2,
+ "elementType": {
+ "kind": "scalar",
+ "scalarType": "float32"
+ }
+ },
+ "binding": {"kind": "uniform", "offset": 48, "size": 8}
+ },
+ {
+ "name": "e",
+ "type": {
+ "kind": "struct",
+ "fields": [
+ {
+ "name": "f",
+ "type": {
+ "kind": "vector",
+ "elementCount": 2,
+ "elementType": {
+ "kind": "scalar",
+ "scalarType": "float32"
+ }
+ },
+ "binding": {"kind": "uniform", "offset": 0, "size": 8}
+ }
+ ]
+ },
+ "binding": {"kind": "uniform", "offset": 56, "size": 8}
+ },
+ {
+ "name": "g",
+ "type": {
+ "kind": "vector",
+ "elementCount": 3,
+ "elementType": {
+ "kind": "scalar",
+ "scalarType": "float32"
+ }
+ },
+ "binding": {"kind": "uniform", "offset": 64, "size": 12}
+ },
+ {
+ "name": "h",
+ "type": {
+ "kind": "scalar",
+ "scalarType": "float32"
+ },
+ "binding": {"kind": "uniform", "offset": 76, "size": 4}
+ }
+ ]
+ }
+ }
+ }
+ ]
+}
+}