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

Unified Diff: src/gpu/vk/GrVkProgramDataManager.cpp

Issue 1734403002: Fix uniform buffer layout in vulkan (Closed) Base URL: https://skia.googlesource.com/skia.git@addFileBack
Patch Set: Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/gpu/vk/GrVkUniformHandler.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/vk/GrVkProgramDataManager.cpp
diff --git a/src/gpu/vk/GrVkProgramDataManager.cpp b/src/gpu/vk/GrVkProgramDataManager.cpp
index fe14cdb1fc6102ddab94aa875c5130fc27113f22..732e937ef529b024bc0c7987fbe69f2ec3c36765 100644
--- a/src/gpu/vk/GrVkProgramDataManager.cpp
+++ b/src/gpu/vk/GrVkProgramDataManager.cpp
@@ -74,7 +74,11 @@ void GrVkProgramDataManager::set1fv(UniformHandle u,
}
buffer = static_cast<char*>(buffer) + uni.fOffset;
SkASSERT(sizeof(float) == 4);
- memcpy(buffer, v, arrayCount * sizeof(float));
+ for (int i = 0; i < arrayCount; ++i) {
+ const float* curVec = &v[i];
+ memcpy(buffer, curVec, sizeof(float));
+ buffer = static_cast<char*>(buffer) + 4*sizeof(float);
+ }
}
void GrVkProgramDataManager::set2f(UniformHandle u, float v0, float v1) const {
@@ -114,7 +118,11 @@ void GrVkProgramDataManager::set2fv(UniformHandle u,
}
buffer = static_cast<char*>(buffer) + uni.fOffset;
SkASSERT(sizeof(float) == 4);
- memcpy(buffer, v, arrayCount * 2* sizeof(float));
+ for (int i = 0; i < arrayCount; ++i) {
+ const float* curVec = &v[2 * i];
+ memcpy(buffer, curVec, 2 * sizeof(float));
+ buffer = static_cast<char*>(buffer) + 4*sizeof(float);
+ }
}
void GrVkProgramDataManager::set3f(UniformHandle u, float v0, float v1, float v2) const {
@@ -154,7 +162,11 @@ void GrVkProgramDataManager::set3fv(UniformHandle u,
}
buffer = static_cast<char*>(buffer) + uni.fOffset;
SkASSERT(sizeof(float) == 4);
- memcpy(buffer, v, arrayCount * 3 * sizeof(float));
+ for (int i = 0; i < arrayCount; ++i) {
+ const float* curVec = &v[3 * i];
+ memcpy(buffer, curVec, 3 * sizeof(float));
+ buffer = static_cast<char*>(buffer) + 4*sizeof(float);
+ }
}
void GrVkProgramDataManager::set4f(UniformHandle u, float v0, float v1, float v2, float v3) const {
@@ -215,7 +227,7 @@ void GrVkProgramDataManager::setMatrix3f(UniformHandle u, const float matrix[])
memcpy(buffer, &matrix[0], 3 * sizeof(float));
buffer = static_cast<char*>(buffer) + 4*sizeof(float);
memcpy(buffer, &matrix[3], 3 * sizeof(float));
- buffer = static_cast<char*>(buffer) + 4 * sizeof(float);
+ buffer = static_cast<char*>(buffer) + 4*sizeof(float);
memcpy(buffer, &matrix[6], 3 * sizeof(float));
}
@@ -241,11 +253,11 @@ void GrVkProgramDataManager::setMatrix3fv(UniformHandle u,
for (int i = 0; i < arrayCount; ++i) {
const float* matrix = &matrices[9 * i];
memcpy(buffer, &matrix[0], 3 * sizeof(float));
- buffer = static_cast<char*>(buffer)+4 * sizeof(float);
+ buffer = static_cast<char*>(buffer) + 4*sizeof(float);
memcpy(buffer, &matrix[3], 3 * sizeof(float));
- buffer = static_cast<char*>(buffer)+4 * sizeof(float);
+ buffer = static_cast<char*>(buffer) + 4*sizeof(float);
memcpy(buffer, &matrix[6], 3 * sizeof(float));
- buffer = static_cast<char*>(buffer)+4 * sizeof(float);
+ buffer = static_cast<char*>(buffer) + 4*sizeof(float);
}
}
« no previous file with comments | « no previous file | src/gpu/vk/GrVkUniformHandler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698