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

Unified Diff: src/sksl/ir/SkSLType.h

Issue 2187433003: added support for push_constant layout (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: rebased 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/sksl/ir/SkSLLayout.h ('k') | tests/SkSLMemoryLayoutTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/sksl/ir/SkSLType.h
diff --git a/src/sksl/ir/SkSLType.h b/src/sksl/ir/SkSLType.h
index 81ec13ab442b771b547a4c4732e545224f6aceb6..a4632061ae68c7de85fc8a1f3ed67da9dbd6c12d 100644
--- a/src/sksl/ir/SkSLType.h
+++ b/src/sksl/ir/SkSLType.h
@@ -238,87 +238,6 @@ public:
return fIsSampled;
}
- static size_t vector_alignment(size_t componentSize, int columns) {
- return componentSize * (columns + columns % 2);
- }
-
- /**
- * Returns the type's required alignment (when putting this type into a struct, the offset must
- * be a multiple of the alignment).
- */
- size_t alignment() const {
- // See OpenGL Spec 7.6.2.2 Standard Uniform Block Layout
- switch (fTypeKind) {
- case kScalar_Kind:
- return this->size();
- case kVector_Kind:
- return vector_alignment(fComponentType->size(), fColumns);
- case kMatrix_Kind:
- return (vector_alignment(fComponentType->size(), fRows) + 15) & ~15;
- case kArray_Kind:
- // round up to next multiple of 16
- return (fComponentType->alignment() + 15) & ~15;
- case kStruct_Kind: {
- size_t result = 16;
- for (size_t i = 0; i < fFields.size(); i++) {
- size_t alignment = fFields[i].fType->alignment();
- if (alignment > result) {
- result = alignment;
- }
- }
- }
- default:
- ABORT(("cannot determine size of type " + fName).c_str());
- }
- }
-
- /**
- * For matrices and arrays, returns the number of bytes from the start of one entry (row, in
- * the case of matrices) to the start of the next.
- */
- size_t stride() const {
- switch (fTypeKind) {
- case kMatrix_Kind: // fall through
- case kArray_Kind:
- return this->alignment();
- default:
- ABORT("type does not have a stride");
- }
- }
-
- /**
- * Returns the size of this type in bytes.
- */
- size_t size() const {
- switch (fTypeKind) {
- case kScalar_Kind:
- // FIXME need to take precision into account, once we figure out how we want to
- // handle it...
- return 4;
- case kVector_Kind:
- return fColumns * fComponentType->size();
- case kMatrix_Kind:
- return vector_alignment(fComponentType->size(), fRows) * fColumns;
- case kArray_Kind:
- return fColumns * this->stride();
- case kStruct_Kind: {
- size_t total = 0;
- for (size_t i = 0; i < fFields.size(); i++) {
- size_t alignment = fFields[i].fType->alignment();
- if (total % alignment != 0) {
- total += alignment - total % alignment;
- }
- ASSERT(false);
- ASSERT(total % alignment == 0);
- total += fFields[i].fType->size();
- }
- return total;
- }
- default:
- ABORT(("cannot determine size of type " + fName).c_str());
- }
- }
-
/**
* Returns the corresponding vector or matrix type with the specified number of columns and
* rows.
« no previous file with comments | « src/sksl/ir/SkSLLayout.h ('k') | tests/SkSLMemoryLayoutTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698