diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2018-08-21 08:40:25 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-08-21 08:40:25 -0700 |
| commit | 0ce1131ba12f777fbaa40004e0e3e7af89ccf4f0 (patch) | |
| tree | 053d94527cab22111060087c53f18c4bd066ecd2 /source/slang/hlsl.meta.slang | |
| parent | 56d8a752d84e984afab20de5980edf10fe6c06f5 (diff) | |
Add support for more RasterizerOrdered types (#628)
Fixes #627
The front-end has support for `RasterizerOrderedBuffer` and `RasterizerOrderedTexture*`, but left out support for:
* `RasterizerOrderedByteAddressBuffer`
* `RasterizerOrderedStructuredBuffer`
[Nitpick: these tyeps are all amazingly annoying to type. It is easy to want to write `RasterOrdered` instead of the bulkier `RasterizerOrdered`, and almost everybody does in casual speech. There's already the issue of wanting to type `StructureBuffer` (a buffer of structures) instead of `StructuredBuffer` (a buffer that is... structured?). Then you have `ByteAddressBuffer` which is just adding to the confusion because it is nominally a "byte addressable" buffer (so that `ByteAddressedBuffer` would actually make sense), but then actually *isn't* byte addressable in practice.]
There were a few `TODO` comments related to this already, and this change was mostly a matter of doing a find-in-files for `RWByteAddressBuffer` and `RWStructuredBuffer` and adding matching `RasterizerOrdered` cases.
The test I added just checks that these types make it through the front-end, and doesn't do any actual confirmation that they work as intended. It is worth noting that the handling of ordering in GLSL/VK is different from in HLSL ("pixel shader interlock" instead of "rasterizer ordered views"), so coming up with a cross-compilation story would need to be a later step.
Diffstat (limited to 'source/slang/hlsl.meta.slang')
| -rw-r--r-- | source/slang/hlsl.meta.slang | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang index 10665915d..bf6c12788 100644 --- a/source/slang/hlsl.meta.slang +++ b/source/slang/hlsl.meta.slang @@ -77,9 +77,21 @@ struct OutputPatch __subscript(uint index) -> T; }; -__magic_type(HLSLRWByteAddressBufferType) -__intrinsic_type($(kIROp_HLSLRWByteAddressBufferType)) -struct RWByteAddressBuffer +${{{{ +static const struct { + IROp op; + char const* name; +} kMutableByteAddressBufferCases[] = +{ + { kIROp_HLSLRWByteAddressBufferType, "RWByteAddressBuffer" }, + { kIROp_HLSLRasterizerOrderedByteAddressBufferType, "RasterizerOrderedByteAddressBuffer" }, +}; +for(auto item : kMutableByteAddressBufferCases) { +}}}} + +__magic_type(HLSL$(item.name)Type) +__intrinsic_type($(item.op)) +struct $(item.name) { // Note(tfoley): supports alll operations from `ByteAddressBuffer` // TODO(tfoley): can this be made a sub-type? @@ -192,10 +204,27 @@ struct RWByteAddressBuffer uint4 value); }; +${{{{ +} +}}}} + +${{{{ +static const struct { + IROp op; + char const* name; +} kMutableStructuredBufferCases[] = +{ + { kIROp_HLSLRWStructuredBufferType, "RWStructuredBuffer" }, + { kIROp_HLSLRasterizerOrderedStructuredBufferType, "RasterizerOrderedStructuredBuffer" }, +}; +for(auto item : kMutableStructuredBufferCases) { +}}}} + + __generic<T> -__magic_type(HLSLRWStructuredBufferType) -__intrinsic_type($(kIROp_HLSLRWStructuredBufferType)) -struct RWStructuredBuffer +__magic_type(HLSL$(item.name)Type) +__intrinsic_type($(item.op)) +struct $(item.name) { uint DecrementCounter(); @@ -215,6 +244,10 @@ struct RWStructuredBuffer } }; +${{{{ +} +}}}} + __generic<T> __magic_type(HLSLPointStreamType) __intrinsic_type($(kIROp_HLSLPointStreamType)) |
