aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/vk/GrVkUniformHandler.cpp
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-09-18 14:10:39 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-09-18 18:32:13 +0000
commitf7b8820dc813d1eb0b6b43fe4581dded0da38caf (patch)
tree518d313a9fa571a9f9ca26af7c381664694a4706 /src/gpu/vk/GrVkUniformHandler.cpp
parent47a540f503bc722393b61c4b822e95b17f200125 (diff)
re-land of new SkSL precisions
Bug: skia: Change-Id: Ic1deb3db2cbda6ca45f93dee99832971a36a2119 Reviewed-on: https://skia-review.googlesource.com/47841 Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/gpu/vk/GrVkUniformHandler.cpp')
-rw-r--r--src/gpu/vk/GrVkUniformHandler.cpp64
1 files changed, 41 insertions, 23 deletions
diff --git a/src/gpu/vk/GrVkUniformHandler.cpp b/src/gpu/vk/GrVkUniformHandler.cpp
index 98a27518a3..abd4b086ae 100644
--- a/src/gpu/vk/GrVkUniformHandler.cpp
+++ b/src/gpu/vk/GrVkUniformHandler.cpp
@@ -16,31 +16,40 @@
// aligned to 16 bytes (i.e. has mask of 0xF).
uint32_t grsltype_to_alignment_mask(GrSLType type) {
switch(type) {
+ case kShort_GrSLType: // fall through
case kInt_GrSLType:
return 0x3;
+ case kUShort_GrSLType: // fall through
case kUint_GrSLType:
return 0x3;
- case kFloat_GrSLType:
+ case kHalf_GrSLType: // fall through
+ case kHighFloat_GrSLType:
return 0x3;
- case kVec2f_GrSLType:
+ case kHalf2_GrSLType: // fall through
+ case kHighFloat2_GrSLType:
return 0x7;
- case kVec3f_GrSLType:
+ case kHalf3_GrSLType: // fall through
+ case kHighFloat3_GrSLType:
return 0xF;
- case kVec4f_GrSLType:
+ case kHalf4_GrSLType: // fall through
+ case kHighFloat4_GrSLType:
return 0xF;
- case kVec2us_GrSLType:
+ case kUint2_GrSLType:
return 0x3;
- case kVec2i_GrSLType:
+ case kInt2_GrSLType:
return 0x7;
- case kVec3i_GrSLType:
+ case kInt3_GrSLType:
return 0xF;
- case kVec4i_GrSLType:
+ case kInt4_GrSLType:
return 0xF;
- case kMat22f_GrSLType:
+ case kHalf2x2_GrSLType: // fall through
+ case kHighFloat2x2_GrSLType:
return 0x7;
- case kMat33f_GrSLType:
+ case kHalf3x3_GrSLType: // fall through
+ case kHighFloat3x3_GrSLType:
return 0xF;
- case kMat44f_GrSLType:
+ case kHalf4x4_GrSLType: // fall through
+ case kHighFloat4x4_GrSLType:
return 0xF;
// This query is only valid for certain types.
@@ -66,32 +75,41 @@ uint32_t grsltype_to_alignment_mask(GrSLType type) {
so a float2x2 takes up 8 floats. */
static inline uint32_t grsltype_to_vk_size(GrSLType type) {
switch(type) {
+ case kShort_GrSLType: // fall through
case kInt_GrSLType:
return sizeof(int32_t);
+ case kUShort_GrSLType: // fall through
case kUint_GrSLType:
return sizeof(int32_t);
- case kFloat_GrSLType:
+ case kHalf_GrSLType: // fall through
+ case kHighFloat_GrSLType:
return sizeof(float);
- case kVec2f_GrSLType:
+ case kHalf2_GrSLType: // fall through
+ case kHighFloat2_GrSLType:
return 2 * sizeof(float);
- case kVec3f_GrSLType:
+ case kHalf3_GrSLType: // fall through
+ case kHighFloat3_GrSLType:
return 3 * sizeof(float);
- case kVec4f_GrSLType:
+ case kHalf4_GrSLType: // fall through
+ case kHighFloat4_GrSLType:
return 4 * sizeof(float);
- case kVec2us_GrSLType:
+ case kUint2_GrSLType:
return 2 * sizeof(uint16_t);
- case kVec2i_GrSLType:
+ case kInt2_GrSLType:
return 2 * sizeof(int32_t);
- case kVec3i_GrSLType:
+ case kInt3_GrSLType:
return 3 * sizeof(int32_t);
- case kVec4i_GrSLType:
+ case kInt4_GrSLType:
return 4 * sizeof(int32_t);
- case kMat22f_GrSLType:
+ case kHalf2x2_GrSLType: // fall through
+ case kHighFloat2x2_GrSLType:
//TODO: this will be 4 * szof(float) on std430.
return 8 * sizeof(float);
- case kMat33f_GrSLType:
+ case kHalf3x3_GrSLType: // fall through
+ case kHighFloat3x3_GrSLType:
return 12 * sizeof(float);
- case kMat44f_GrSLType:
+ case kHalf4x4_GrSLType: // fall through
+ case kHighFloat4x4_GrSLType:
return 16 * sizeof(float);
// This query is only valid for certain types.
@@ -122,7 +140,7 @@ void get_ubo_aligned_offset(uint32_t* uniformOffset,
int arrayCount) {
uint32_t alignmentMask = grsltype_to_alignment_mask(type);
// We want to use the std140 layout here, so we must make arrays align to 16 bytes.
- if (arrayCount || type == kMat22f_GrSLType) {
+ if (arrayCount || type == kHighFloat2x2_GrSLType) {
alignmentMask = 0xF;
}
uint32_t offsetDiff = *currentOffset & alignmentMask;