Skip to content

Commit 79a2a44

Browse files
authored
[0018] Update SPIR-V resource representation (#372)
1 parent fae15b8 commit 79a2a44

File tree

1 file changed

+32
-21
lines changed

1 file changed

+32
-21
lines changed

proposals/0018-spirv-resource-representation.md

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -145,39 +145,50 @@ it is used.
145145

146146
### Structured Buffers
147147

148-
The handle for structured buffers will be
149-
150-
| HLSL Resource Type | Handle Type |
151-
| ------------------------------------ | ------------------------------------ |
152-
| StructuredBuffer<T> | spirv.VulkanBuffer(T, StorageBuffer, |
153-
: : false) :
154-
| RWStructuredBuffer<T> | spirv.VulkanBuffer(T, StorageBuffer, |
155-
: : true) :
156-
| RasterizerOrderedStructuredBuffer<T> | TODO |
157-
| AppendStructuredBuffer<T> | spirv.VulkanBuffer(T, StorageBuffer, |
158-
: : true) :
159-
| ConsumeStructuredBuffer<T> | spirv.VulkanBuffer(T, StorageBuffer, |
160-
: : true) :
148+
The handle for structured buffers will be:
149+
150+
| HLSL Resource Type | Handle Type |
151+
| ------------------------------------ | ------------------------------------- |
152+
| StructuredBuffer<T> | target("spirv.VulkanBuffer", [0 x T], |
153+
: : StorageBuffer, false) :
154+
| RWStructuredBuffer<T> | target("spirv.VulkanBuffer", [0 x T], |
155+
: : StorageBuffer, true) :
156+
| RasterizerOrderedStructuredBuffer<T> | TODO |
157+
| AppendStructuredBuffer<T> | target("spirv.VulkanBuffer", [0 x T], |
158+
: : StorageBuffer, true) :
159+
| ConsumeStructuredBuffer<T> | target("spirv.VulkanBuffer", [0 x T], |
160+
: : StorageBuffer, true) :
161161

162162
### Texture buffers
163163

164164
Texture buffers are implemented in SPIR-V as storage buffers. From a SPIR-V
165-
perspective, this makes it the same as a `StructureBuffer`, and will be
165+
perspective, this makes it the same as a `StructuredBuffer`, and will be
166166
represented the same way:
167167

168-
```
169-
spirv.VulkanBuffer(T, StorageBuffer, false)
168+
```llvm-ir
169+
target("spirv.VulkanBuffer", LayoutStruct, StorageBuffer, false)
170170
```
171171

172172
### Constant buffers
173173

174-
In SPIR-V, constant buffers are implemented as uniform buffers. The only
175-
difference between a uniform buffer and storage buffer is the storage class.
176-
Uniform buffers use the `Uniform` storage class. The handle type will be:
174+
Our design for constant buffers is in line with proposal
175+
[0016 constant buffers](0016-constant-buffers.md) and proposal
176+
[0034 explicit padding](0034-explicit-padding.md).
177177

178+
The constant buffer will be represented by a `spirv.VulkanBuffer` target type
179+
where the element type is a struct representing the buffer layout. This layout
180+
struct uses `spirv.Padding` to ensure all members are at their correct offsets
181+
according to HLSL packing rules.
182+
183+
The handle type will be:
184+
185+
```llvm-ir
186+
target("spirv.VulkanBuffer", LayoutStruct, Uniform, false)
178187
```
179-
spirv.VulkanBuffer(T, Uniform, false, false)
180-
```
188+
189+
`LayoutStruct` is the explicit layout struct created by the
190+
`HLSLBufferLayoutBuilder`. `Uniform` is the SPIR-V storage class for constant
191+
buffers. `false` indicates that the buffer is not writable.
181192

182193
### Samplers
183194

0 commit comments

Comments
 (0)