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

Side by Side Diff: src/sksl/ir/SkSLType.h

Issue 2300023002: minor SkSL changes to avoid compiler errors in Chromium (Closed)
Patch Set: Created 4 years, 3 months 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
« no previous file with comments | « src/sksl/ir/SkSLSymbolTable.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
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SKIASL_TYPE 8 #ifndef SKIASL_TYPE
9 #define SKIASL_TYPE 9 #define SKIASL_TYPE
10 10
11 #include "SkSLModifiers.h" 11 #include "SkSLModifiers.h"
12 #include "SkSLSymbol.h" 12 #include "SkSLSymbol.h"
13 #include "../SkSLPosition.h" 13 #include "../SkSLPosition.h"
14 #include "../SkSLUtil.h" 14 #include "../SkSLUtil.h"
15 #include "../spirv.h" 15 #include "../spirv.h"
16 #include <vector> 16 #include <vector>
17 #include <memory> 17 #include <memory>
18 18
19 namespace SkSL { 19 namespace SkSL {
20 20
21 class Context; 21 class Context;
22 22
23 /** 23 /**
24 * Represents a type, such as int or vec4. 24 * Represents a type, such as int or vec4.
25 */ 25 */
26 class Type : public Symbol { 26 class Type : public Symbol {
27 public: 27 public:
28 struct Field { 28 struct Field {
29 Field(Modifiers modifiers, std::string name, const Type& type) 29 Field(Modifiers modifiers, std::string name, const Type* type)
30 : fModifiers(modifiers) 30 : fModifiers(modifiers)
31 , fName(std::move(name)) 31 , fName(std::move(name))
32 , fType(std::move(type)) {} 32 , fType(std::move(type)) {}
33 33
34 const std::string description() const { 34 const std::string description() const {
35 return fType.description() + " " + fName + ";"; 35 return fType->description() + " " + fName + ";";
36 } 36 }
37 37
38 const Modifiers fModifiers; 38 Modifiers fModifiers;
39 const std::string fName; 39 std::string fName;
40 const Type& fType; 40 const Type* fType;
41 }; 41 };
42 42
43 enum Kind { 43 enum Kind {
44 kScalar_Kind, 44 kScalar_Kind,
45 kVector_Kind, 45 kVector_Kind,
46 kMatrix_Kind, 46 kMatrix_Kind,
47 kArray_Kind, 47 kArray_Kind,
48 kStruct_Kind, 48 kStruct_Kind,
49 kGeneric_Kind, 49 kGeneric_Kind,
50 kSampler_Kind, 50 kSampler_Kind,
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 case kVector_Kind: 252 case kVector_Kind:
253 return vector_alignment(fComponentType->size(), fColumns); 253 return vector_alignment(fComponentType->size(), fColumns);
254 case kMatrix_Kind: 254 case kMatrix_Kind:
255 return (vector_alignment(fComponentType->size(), fRows) + 15) & ~15; 255 return (vector_alignment(fComponentType->size(), fRows) + 15) & ~15;
256 case kArray_Kind: 256 case kArray_Kind:
257 // round up to next multiple of 16 257 // round up to next multiple of 16
258 return (fComponentType->alignment() + 15) & ~15; 258 return (fComponentType->alignment() + 15) & ~15;
259 case kStruct_Kind: { 259 case kStruct_Kind: {
260 size_t result = 16; 260 size_t result = 16;
261 for (size_t i = 0; i < fFields.size(); i++) { 261 for (size_t i = 0; i < fFields.size(); i++) {
262 size_t alignment = fFields[i].fType.alignment(); 262 size_t alignment = fFields[i].fType->alignment();
263 if (alignment > result) { 263 if (alignment > result) {
264 result = alignment; 264 result = alignment;
265 } 265 }
266 } 266 }
267 } 267 }
268 default: 268 default:
269 ABORT(("cannot determine size of type " + fName).c_str()); 269 ABORT(("cannot determine size of type " + fName).c_str());
270 } 270 }
271 } 271 }
272 272
(...skipping 22 matching lines...) Expand all
295 return 4; 295 return 4;
296 case kVector_Kind: 296 case kVector_Kind:
297 return fColumns * fComponentType->size(); 297 return fColumns * fComponentType->size();
298 case kMatrix_Kind: 298 case kMatrix_Kind:
299 return vector_alignment(fComponentType->size(), fRows) * fColumn s; 299 return vector_alignment(fComponentType->size(), fRows) * fColumn s;
300 case kArray_Kind: 300 case kArray_Kind:
301 return fColumns * this->stride(); 301 return fColumns * this->stride();
302 case kStruct_Kind: { 302 case kStruct_Kind: {
303 size_t total = 0; 303 size_t total = 0;
304 for (size_t i = 0; i < fFields.size(); i++) { 304 for (size_t i = 0; i < fFields.size(); i++) {
305 size_t alignment = fFields[i].fType.alignment(); 305 size_t alignment = fFields[i].fType->alignment();
306 if (total % alignment != 0) { 306 if (total % alignment != 0) {
307 total += alignment - total % alignment; 307 total += alignment - total % alignment;
308 } 308 }
309 ASSERT(false); 309 ASSERT(false);
310 ASSERT(total % alignment == 0); 310 ASSERT(total % alignment == 0);
311 total += fFields[i].fType.size(); 311 total += fFields[i].fType->size();
312 } 312 }
313 return total; 313 return total;
314 } 314 }
315 default: 315 default:
316 ABORT(("cannot determine size of type " + fName).c_str()); 316 ABORT(("cannot determine size of type " + fName).c_str());
317 } 317 }
318 } 318 }
319 319
320 /** 320 /**
321 * Returns the corresponding vector or matrix type with the specified number of columns and 321 * Returns the corresponding vector or matrix type with the specified number of columns and
322 * rows. 322 * rows.
323 */ 323 */
324 const Type& toCompound(const Context& context, int columns, int rows) const; 324 const Type& toCompound(const Context& context, int columns, int rows) const;
325 325
326 private: 326 private:
327 typedef Symbol INHERITED; 327 typedef Symbol INHERITED;
328 328
329 const Kind fTypeKind; 329 const Kind fTypeKind;
330 const bool fIsNumber = false; 330 const bool fIsNumber = false;
331 const Type* fComponentType = nullptr; 331 const Type* fComponentType = nullptr;
332 const std::vector<const Type*> fCoercibleTypes = { }; 332 const std::vector<const Type*> fCoercibleTypes;
333 const int fColumns = -1; 333 const int fColumns = -1;
334 const int fRows = -1; 334 const int fRows = -1;
335 const std::vector<Field> fFields = { }; 335 const std::vector<Field> fFields;
336 const SpvDim_ fDimensions = SpvDim1D; 336 const SpvDim_ fDimensions = SpvDim1D;
337 const bool fIsDepth = false; 337 const bool fIsDepth = false;
338 const bool fIsArrayed = false; 338 const bool fIsArrayed = false;
339 const bool fIsMultisampled = false; 339 const bool fIsMultisampled = false;
340 const bool fIsSampled = false; 340 const bool fIsSampled = false;
341 }; 341 };
342 342
343 } // namespace 343 } // namespace
344 344
345 #endif 345 #endif
OLDNEW
« no previous file with comments | « src/sksl/ir/SkSLSymbolTable.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698