Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: tests/SkSLMemoryLayoutTest.cpp

Issue 2187433003: added support for push_constant layout (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: this is right. If it disagrees with the spec, the spec is wrong. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« src/sksl/SkSLMemoryLayout.h ('K') | « tests/SkSLGLSLTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "SkSLContext.h"
9 #include "SkSLMemoryLayout.h"
10
11 #include "Test.h"
12
13 #if SK_SUPPORT_GPU
14
15 DEF_TEST(SkSLMemoryLayout140Test, r) {
16 SkSL::Context context;
17 SkSL::MemoryLayout layout(SkSL::MemoryLayout::k140_Standard);
18
19 // basic types
20 REPORTER_ASSERT(r, layout.size(*context.fFloat_Type) == 4);
21 REPORTER_ASSERT(r, layout.size(*context.fVec2_Type) == 8);
22 REPORTER_ASSERT(r, layout.size(*context.fVec3_Type) == 12);
23 REPORTER_ASSERT(r, layout.size(*context.fVec4_Type) == 16);
24 REPORTER_ASSERT(r, layout.size(*context.fInt_Type) == 4);
25 REPORTER_ASSERT(r, layout.size(*context.fIVec2_Type) == 8);
26 REPORTER_ASSERT(r, layout.size(*context.fIVec3_Type) == 12);
27 REPORTER_ASSERT(r, layout.size(*context.fIVec4_Type) == 16);
egdaniel 2016/11/15 15:31:18 Add mats to this
28 REPORTER_ASSERT(r, layout.size(*context.fBool_Type) == 1);
29 REPORTER_ASSERT(r, layout.size(*context.fBVec2_Type) == 2);
30 REPORTER_ASSERT(r, layout.size(*context.fBVec3_Type) == 3);
31 REPORTER_ASSERT(r, layout.size(*context.fBVec4_Type) == 4);
32 REPORTER_ASSERT(r, layout.alignment(*context.fFloat_Type) == 4);
33 REPORTER_ASSERT(r, layout.alignment(*context.fVec2_Type) == 8);
34 REPORTER_ASSERT(r, layout.alignment(*context.fVec3_Type) == 16);
35 REPORTER_ASSERT(r, layout.alignment(*context.fVec4_Type) == 16);
36 REPORTER_ASSERT(r, layout.alignment(*context.fInt_Type) == 4);
37 REPORTER_ASSERT(r, layout.alignment(*context.fIVec2_Type) == 8);
38 REPORTER_ASSERT(r, layout.alignment(*context.fIVec3_Type) == 16);
39 REPORTER_ASSERT(r, layout.alignment(*context.fIVec4_Type) == 16);
40 REPORTER_ASSERT(r, layout.alignment(*context.fBool_Type) == 1);
41 REPORTER_ASSERT(r, layout.alignment(*context.fBVec2_Type) == 2);
42 REPORTER_ASSERT(r, layout.alignment(*context.fBVec3_Type) == 4);
43 REPORTER_ASSERT(r, layout.alignment(*context.fBVec4_Type) == 4);
44
45 // struct 1
46 std::vector<SkSL::Type::Field> fields1;
47 fields1.emplace_back(SkSL::Modifiers(), "a", context.fVec3_Type.get());
48 SkSL::Type s1("s1", fields1);
49 REPORTER_ASSERT(r, layout.size(s1) == 16);
50 REPORTER_ASSERT(r, layout.alignment(s1) == 16);
51
52 fields1.emplace_back(SkSL::Modifiers(), "b", context.fFloat_Type.get());
53 SkSL::Type s2("s2", fields1);
54 REPORTER_ASSERT(r, layout.size(s2) == 16);
55 REPORTER_ASSERT(r, layout.alignment(s2) == 16);
56
57 fields1.emplace_back(SkSL::Modifiers(), "c", context.fBool_Type.get());
58 SkSL::Type s3("s3", fields1);
59 REPORTER_ASSERT(r, layout.size(s3) == 32);
60 REPORTER_ASSERT(r, layout.alignment(s3) == 16);
61
62 // struct 2
63 std::vector<SkSL::Type::Field> fields2;
64 fields2.emplace_back(SkSL::Modifiers(), "a", context.fInt_Type.get());
65 SkSL::Type s4("s4", fields2);
66 REPORTER_ASSERT(r, layout.size(s4) == 16);
67 REPORTER_ASSERT(r, layout.alignment(s4) == 16);
68
69 fields2.emplace_back(SkSL::Modifiers(), "b", context.fVec3_Type.get());
70 SkSL::Type s5("s5", fields2);
71 REPORTER_ASSERT(r, layout.size(s5) == 32);
72 REPORTER_ASSERT(r, layout.alignment(s5) == 16);
73
74 // arrays
75 SkSL::Type array1("float[4]", SkSL::Type::kArray_Kind, *context.fFloat_Type, 4);
76 REPORTER_ASSERT(r, layout.size(array1) == 64);
77 REPORTER_ASSERT(r, layout.alignment(array1) == 16);
78 REPORTER_ASSERT(r, layout.stride(array1) == 16);
79
80 SkSL::Type array2("vec4[4]", SkSL::Type::kArray_Kind, *context.fVec4_Type, 4 );
81 REPORTER_ASSERT(r, layout.size(array2) == 64);
82 REPORTER_ASSERT(r, layout.alignment(array2) == 16);
83 REPORTER_ASSERT(r, layout.stride(array2) == 16);
84 }
85
86 DEF_TEST(SkSLMemoryLayout430Test, r) {
87 SkSL::Context context;
88 SkSL::MemoryLayout layout(SkSL::MemoryLayout::k430_Standard);
89
90 // basic types
91 REPORTER_ASSERT(r, layout.size(*context.fFloat_Type) == 4);
92 REPORTER_ASSERT(r, layout.size(*context.fVec2_Type) == 8);
93 REPORTER_ASSERT(r, layout.size(*context.fVec3_Type) == 12);
94 REPORTER_ASSERT(r, layout.size(*context.fVec4_Type) == 16);
95 REPORTER_ASSERT(r, layout.size(*context.fInt_Type) == 4);
96 REPORTER_ASSERT(r, layout.size(*context.fIVec2_Type) == 8);
97 REPORTER_ASSERT(r, layout.size(*context.fIVec3_Type) == 12);
98 REPORTER_ASSERT(r, layout.size(*context.fIVec4_Type) == 16);
99 REPORTER_ASSERT(r, layout.size(*context.fBool_Type) == 1);
100 REPORTER_ASSERT(r, layout.size(*context.fBVec2_Type) == 2);
101 REPORTER_ASSERT(r, layout.size(*context.fBVec3_Type) == 3);
102 REPORTER_ASSERT(r, layout.size(*context.fBVec4_Type) == 4);
103 REPORTER_ASSERT(r, layout.alignment(*context.fFloat_Type) == 4);
104 REPORTER_ASSERT(r, layout.alignment(*context.fVec2_Type) == 8);
105 REPORTER_ASSERT(r, layout.alignment(*context.fVec3_Type) == 16);
106 REPORTER_ASSERT(r, layout.alignment(*context.fVec4_Type) == 16);
107 REPORTER_ASSERT(r, layout.alignment(*context.fInt_Type) == 4);
108 REPORTER_ASSERT(r, layout.alignment(*context.fIVec2_Type) == 8);
109 REPORTER_ASSERT(r, layout.alignment(*context.fIVec3_Type) == 16);
110 REPORTER_ASSERT(r, layout.alignment(*context.fIVec4_Type) == 16);
111 REPORTER_ASSERT(r, layout.alignment(*context.fBool_Type) == 1);
112 REPORTER_ASSERT(r, layout.alignment(*context.fBVec2_Type) == 2);
113 REPORTER_ASSERT(r, layout.alignment(*context.fBVec3_Type) == 4);
114 REPORTER_ASSERT(r, layout.alignment(*context.fBVec4_Type) == 4);
115
116 // struct 1
117 std::vector<SkSL::Type::Field> fields1;
118 fields1.emplace_back(SkSL::Modifiers(), "a", context.fVec3_Type.get());
119 SkSL::Type s1("s1", fields1);
120 REPORTER_ASSERT(r, layout.size(s1) == 16);
121 REPORTER_ASSERT(r, layout.alignment(s1) == 16);
122
123 fields1.emplace_back(SkSL::Modifiers(), "b", context.fFloat_Type.get());
124 SkSL::Type s2("s2", fields1);
125 REPORTER_ASSERT(r, layout.size(s2) == 16);
126 REPORTER_ASSERT(r, layout.alignment(s2) == 16);
127
128 fields1.emplace_back(SkSL::Modifiers(), "c", context.fBool_Type.get());
129 SkSL::Type s3("s3", fields1);
130 REPORTER_ASSERT(r, layout.size(s3) == 32);
131 REPORTER_ASSERT(r, layout.alignment(s3) == 16);
132
133 // struct 2
134 std::vector<SkSL::Type::Field> fields2;
135 fields2.emplace_back(SkSL::Modifiers(), "a", context.fInt_Type.get());
136 SkSL::Type s4("s4", fields2);
137 REPORTER_ASSERT(r, layout.size(s4) == 4);
138 REPORTER_ASSERT(r, layout.alignment(s4) == 4);
139
140 fields2.emplace_back(SkSL::Modifiers(), "b", context.fVec3_Type.get());
141 SkSL::Type s5("s5", fields2);
142 REPORTER_ASSERT(r, layout.size(s5) == 32);
143 REPORTER_ASSERT(r, layout.alignment(s5) == 16);
144
145 // arrays
146 SkSL::Type array1("float[4]", SkSL::Type::kArray_Kind, *context.fFloat_Type, 4);
147 REPORTER_ASSERT(r, layout.size(array1) == 16);
148 REPORTER_ASSERT(r, layout.alignment(array1) == 4);
149 REPORTER_ASSERT(r, layout.stride(array1) == 4);
150
151 SkSL::Type array2("vec4[4]", SkSL::Type::kArray_Kind, *context.fVec4_Type, 4 );
152 REPORTER_ASSERT(r, layout.size(array2) == 64);
153 REPORTER_ASSERT(r, layout.alignment(array2) == 16);
154 REPORTER_ASSERT(r, layout.stride(array2) == 16);
155 }
156 #endif
OLDNEW
« src/sksl/SkSLMemoryLayout.h ('K') | « tests/SkSLGLSLTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698