diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2017-07-11 13:04:58 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-07-11 13:04:58 -0700 |
| commit | fa48d2d59abb7e2e5f92ab1477e0700cb8a76680 (patch) | |
| tree | 19b3ceca7f7f83c1fd32351679521cf348bd1d0d | |
| parent | a60dd57e5ac0d3cc43fddf62dbf72677d377121f (diff) | |
| parent | 0cd5602383d1ae85276eacec69d51a15a9e975f4 (diff) | |
Merge pull request #73 from tfoleyNV/image-type-reflection
Improve reporting of GLSL `image*` types
| -rw-r--r-- | source/slang/slang-stdlib.cpp | 14 | ||||
| -rw-r--r-- | tests/reflection/image-types.glsl | 10 | ||||
| -rw-r--r-- | tests/reflection/image-types.glsl.expected | 27 |
3 files changed, 46 insertions, 5 deletions
diff --git a/source/slang/slang-stdlib.cpp b/source/slang/slang-stdlib.cpp index b3a48adea..09958ddab 100644 --- a/source/slang/slang-stdlib.cpp +++ b/source/slang/slang-stdlib.cpp @@ -1940,7 +1940,8 @@ namespace Slang for (int isMultisample = 0; isMultisample < 2; ++isMultisample) { - auto access = SLANG_RESOURCE_ACCESS_READ; + auto readAccess = SLANG_RESOURCE_ACCESS_READ; + auto readWriteAccess = SLANG_RESOURCE_ACCESS_READ_WRITE; // TODO: any constraints to enforce on what gets to be multisampled? @@ -1950,7 +1951,10 @@ namespace Slang if (isMultisample) flavor |= TextureType::MultisampleFlag; // if (isShadow) flavor |= TextureType::ShadowFlag; - flavor |= (access << 8); + + + unsigned readFlavor = flavor | (readAccess << 8); + unsigned readWriteFlavor = flavor | (readWriteAccess << 8); StringBuilder nameBuilder; nameBuilder << shapeName; @@ -1959,17 +1963,17 @@ namespace Slang auto name = nameBuilder.ProduceString(); sb << "__generic<T> "; - sb << "__magic_type(TextureSampler," << int(flavor) << ") struct "; + sb << "__magic_type(TextureSampler," << int(readFlavor) << ") struct "; sb << "__sampler" << name; sb << " {};\n"; sb << "__generic<T> "; - sb << "__magic_type(Texture," << int(flavor) << ") struct "; + sb << "__magic_type(Texture," << int(readFlavor) << ") struct "; sb << "__texture" << name; sb << " {};\n"; sb << "__generic<T> "; - sb << "__magic_type(GLSLImageType," << int(flavor) << ") struct "; + sb << "__magic_type(GLSLImageType," << int(readWriteFlavor) << ") struct "; sb << "__image" << name; sb << " {};\n"; diff --git a/tests/reflection/image-types.glsl b/tests/reflection/image-types.glsl new file mode 100644 index 000000000..21cd2b629 --- /dev/null +++ b/tests/reflection/image-types.glsl @@ -0,0 +1,10 @@ +//TEST(smoke):SIMPLE:-profile ps_4_0 -target reflection-json + +// Confirm that we expose GLSL `image` types through reflection + +uniform imageBuffer iBuffer; + +uniform image2D i2D; + +void main() +{} diff --git a/tests/reflection/image-types.glsl.expected b/tests/reflection/image-types.glsl.expected new file mode 100644 index 000000000..19d28f329 --- /dev/null +++ b/tests/reflection/image-types.glsl.expected @@ -0,0 +1,27 @@ +result code = 0 +standard error = { +} +standard output = { +{ + "parameters": [ + { + "name": "iBuffer", + "binding": {"kind": "descriptorTableSlot", "index": 0}, + "type": { + "kind": "resource", + "baseShape": "textureBuffer", + "access": "readWrite" + } + }, + { + "name": "i2D", + "binding": {"kind": "descriptorTableSlot", "index": 1}, + "type": { + "kind": "resource", + "baseShape": "texture2D", + "access": "readWrite" + } + } + ] +} +} |
