Skip to content

Commit 58a2de1

Browse files
committed
polish a bit
1 parent 5ea7106 commit 58a2de1

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

source/ShaderCompilerContext.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Types;
88
using Unmanaged;
99
using Vortice.ShaderCompiler;
10+
using Vortice.SPIRV;
1011
using Vortice.SpirvCross;
1112
using static Vortice.SpirvCross.SpirvCrossApi;
1213
using Result = Vortice.SpirvCross.Result;
@@ -199,20 +200,20 @@ public readonly void ReadStorageBuffers(List<ShaderStorageBuffer> list)
199200
for (int i = 0; i < resourcesSpan.Length; i++)
200201
{
201202
spvc_reflected_resource resource = resourcesSpan[i];
202-
uint set = spvc_compiler_get_decoration(compiler, resource.id, Vortice.SPIRV.SpvDecoration.DescriptorSet);
203-
uint binding = spvc_compiler_get_decoration(compiler, resource.id, Vortice.SPIRV.SpvDecoration.Binding);
203+
uint set = spvc_compiler_get_decoration(compiler, resource.id, SpvDecoration.DescriptorSet);
204+
uint binding = spvc_compiler_get_decoration(compiler, resource.id, SpvDecoration.Binding);
204205
string name = spvc_compiler_get_name(compiler, resource.id) ?? string.Empty;
205206
spvc_type typeHandle = spvc_compiler_get_type_handle(compiler, resource.type_id);
206207
Basetype baseType = spvc_type_get_basetype(typeHandle);
207208
if (baseType == Basetype.Struct)
208209
{
209210
ShaderStorageBuffer.Flags flags = default;
210-
if (spvc_compiler_has_decoration(compiler, resource.id, Vortice.SPIRV.SpvDecoration.NonWritable))
211+
if (spvc_compiler_has_decoration(compiler, resource.id, SpvDecoration.NonWritable))
211212
{
212213
flags |= ShaderStorageBuffer.Flags.ReadOnly;
213214
}
214215

215-
if (spvc_compiler_has_decoration(compiler, resource.id, Vortice.SPIRV.SpvDecoration.NonReadable))
216+
if (spvc_compiler_has_decoration(compiler, resource.id, SpvDecoration.NonReadable))
216217
{
217218
flags |= ShaderStorageBuffer.Flags.WriteOnly;
218219
}
@@ -248,8 +249,8 @@ public readonly void ReadUniformProperties(List<ShaderUniformProperty> list, Lis
248249
int startIndex = list.Count;
249250
foreach (spvc_reflected_resource resource in resourcesSpan)
250251
{
251-
uint set = spvc_compiler_get_decoration(compiler, resource.id, Vortice.SPIRV.SpvDecoration.DescriptorSet);
252-
uint binding = spvc_compiler_get_decoration(compiler, resource.id, Vortice.SPIRV.SpvDecoration.Binding);
252+
uint set = spvc_compiler_get_decoration(compiler, resource.id, SpvDecoration.DescriptorSet);
253+
uint binding = spvc_compiler_get_decoration(compiler, resource.id, SpvDecoration.Binding);
253254
//uint location = spvc_compiler_get_decoration(compiler, resource.id, Vortice.SPIRV.SpvDecoration.Location);
254255
//uint offset = spvc_compiler_get_decoration(compiler, resource.id, Vortice.SPIRV.SpvDecoration.Offset);
255256
ASCIIText256 nameText = spvc_compiler_get_name(compiler, resource.id) ?? string.Empty;
@@ -322,9 +323,9 @@ public readonly void ReadVertexInputAttributes(List<ShaderVertexInputAttribute>
322323
uint offset = 0;
323324
foreach (spvc_reflected_resource resource in resourcesSpan)
324325
{
325-
uint location = spvc_compiler_get_decoration(compiler, resource.id, Vortice.SPIRV.SpvDecoration.Location);
326+
uint location = spvc_compiler_get_decoration(compiler, resource.id, SpvDecoration.Location);
326327
//uint offset = spvc_compiler_get_decoration(compiler, resource.id, Vortice.SPIRV.SpvDecoration.Offset); //gives 0
327-
uint binding = spvc_compiler_get_decoration(compiler, resource.id, Vortice.SPIRV.SpvDecoration.Binding);
328+
uint binding = spvc_compiler_get_decoration(compiler, resource.id, SpvDecoration.Binding);
328329
spvc_type type = spvc_compiler_get_type_handle(compiler, resource.type_id);
329330
uint vectorSize = spvc_type_get_vector_size(type);
330331
string name = new(spvc_compiler_get_name(compiler, resource.id));
@@ -342,8 +343,8 @@ public readonly void ReadTextureProperties(List<ShaderSamplerProperty> list)
342343
for (int i = 0; i < resourcesSpan.Length; i++)
343344
{
344345
spvc_reflected_resource resource = resourcesSpan[i];
345-
uint set = spvc_compiler_get_decoration(compiler, resource.id, Vortice.SPIRV.SpvDecoration.DescriptorSet);
346-
uint binding = spvc_compiler_get_decoration(compiler, resource.id, Vortice.SPIRV.SpvDecoration.Binding);
346+
uint set = spvc_compiler_get_decoration(compiler, resource.id, SpvDecoration.DescriptorSet);
347+
uint binding = spvc_compiler_get_decoration(compiler, resource.id, SpvDecoration.Binding);
347348
string name = spvc_compiler_get_name(compiler, resource.id) ?? string.Empty;
348349
spvc_type type = spvc_compiler_get_type_handle(compiler, resource.type_id);
349350
Basetype baseType = spvc_type_get_basetype(type);

tests/ImportTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,15 @@ void main()
159159
Assert.That(storageBuffers.Length, Is.EqualTo(2));
160160

161161
ShaderStorageBuffer instanceData = storageBuffers[0];
162-
Assert.That(instanceData.name.ToString(), Is.EqualTo("instanceData"));
162+
Assert.That(instanceData.label.ToString(), Is.EqualTo("instanceData"));
163163
Assert.That(instanceData.typeName.ToString(), Is.EqualTo("InstanceData"));
164164
Assert.That(instanceData.binding, Is.EqualTo(2));
165165
Assert.That(instanceData.set, Is.EqualTo(1));
166166
Assert.That(instanceData.byteLength, Is.EqualTo(8));
167167
Assert.That(instanceData.flags, Is.EqualTo(ShaderStorageBuffer.Flags.ReadWrite));
168168

169169
ShaderStorageBuffer lotsOfData = storageBuffers[1];
170-
Assert.That(lotsOfData.name.ToString(), Is.EqualTo("lotsOfData"));
170+
Assert.That(lotsOfData.label.ToString(), Is.EqualTo("lotsOfData"));
171171
Assert.That(lotsOfData.typeName.ToString(), Is.EqualTo("LotsOfData"));
172172
Assert.That(lotsOfData.binding, Is.EqualTo(3));
173173
Assert.That(lotsOfData.set, Is.EqualTo(3));

0 commit comments

Comments
 (0)