File tree Expand file tree Collapse file tree 2 files changed +63
-1
lines changed Expand file tree Collapse file tree 2 files changed +63
-1
lines changed Original file line number Diff line number Diff line change
1
+ using System . IO ;
2
+ using System . Text ;
3
+ using Xunit ;
4
+
5
+ namespace Veldrid . SPIRV . Tests
6
+ {
7
+ public class SerializationTests
8
+ {
9
+ [ Fact ]
10
+ public void SpirvReflection_DeserializeFromString ( )
11
+ {
12
+ const string SerializedJson =
13
+ @"{
14
+ ""VertexElements"": [],
15
+ ""ResourceLayouts"": [
16
+ {
17
+ ""Elements"": [
18
+ {
19
+ ""Name"": ""vdspv_0_0"",
20
+ ""Kind"": ""TextureReadOnly"",
21
+ ""Stages"": ""Fragment"",
22
+ ""Options"": ""None""
23
+ },
24
+ {
25
+ ""Name"": ""vdspv_0_1"",
26
+ ""Kind"": ""Sampler"",
27
+ ""Stages"": ""Fragment"",
28
+ ""Options"": ""None""
29
+ }
30
+ ]
31
+ },
32
+ {
33
+ ""Elements"": [
34
+ {
35
+ ""Name"": ""vdspv_1_0"",
36
+ ""Kind"": ""UniformBuffer"",
37
+ ""Stages"": ""Fragment"",
38
+ ""Options"": ""None""
39
+ }
40
+ ]
41
+ }
42
+ ]
43
+ }" ;
44
+ byte [ ] bytes = Encoding . UTF8 . GetBytes ( SerializedJson ) ;
45
+ using ( MemoryStream ms = new MemoryStream ( bytes ) )
46
+ {
47
+ SpirvReflection refl = SpirvReflection . LoadFromJson ( ms ) ;
48
+ Assert . Empty ( refl . VertexElements ) ;
49
+ Assert . Equal ( 2 , refl . ResourceLayouts . Length ) ;
50
+ Assert . Equal ( 2 , refl . ResourceLayouts [ 0 ] . Elements . Length ) ;
51
+ Assert . Single ( refl . ResourceLayouts [ 1 ] . Elements ) ;
52
+ }
53
+ }
54
+ }
55
+ }
Original file line number Diff line number Diff line change @@ -25,7 +25,14 @@ public class SpirvReflection
25
25
/// </summary>
26
26
public ResourceLayoutDescription [ ] ResourceLayouts { get ; }
27
27
28
- internal SpirvReflection (
28
+ /// <summary>
29
+ /// Constructs a new <see cref="SpirvReflection"/> instance.
30
+ /// </summary>
31
+ /// <param name="vertexElements">/// An array containing a description of each vertex element that is used by
32
+ /// the compiled shader set.</param>
33
+ /// <param name="resourceLayouts">An array containing a description of each set of resources used by the
34
+ /// compiled shader set.</param>
35
+ public SpirvReflection (
29
36
VertexElementDescription [ ] vertexElements ,
30
37
ResourceLayoutDescription [ ] resourceLayouts )
31
38
{
You can’t perform that action at this time.
0 commit comments