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

Side by Side Diff: src/gpu/vk/GrVkPipelineStateDataManager.cpp

Issue 2129953002: Correctly handle mat2x2 in Vulkan (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nits Created 4 years, 5 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 | « gyp/shaderc.gyp ('k') | src/gpu/vk/GrVkUniformHandler.cpp » ('j') | 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 #include "GrVkPipelineStateDataManager.h" 8 #include "GrVkPipelineStateDataManager.h"
9 9
10 #include "GrVkGpu.h" 10 #include "GrVkGpu.h"
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 226
227 set_uniform_matrix<N>::set(buffer, uni.fOffset, arrayCount, matrices); 227 set_uniform_matrix<N>::set(buffer, uni.fOffset, arrayCount, matrices);
228 } 228 }
229 229
230 template<int N> struct set_uniform_matrix { 230 template<int N> struct set_uniform_matrix {
231 inline static void set(void* buffer, int uniformOffset, int count, const flo at matrices[]) { 231 inline static void set(void* buffer, int uniformOffset, int count, const flo at matrices[]) {
232 GR_STATIC_ASSERT(sizeof(float) == 4); 232 GR_STATIC_ASSERT(sizeof(float) == 4);
233 buffer = static_cast<char*>(buffer) + uniformOffset; 233 buffer = static_cast<char*>(buffer) + uniformOffset;
234 for (int i = 0; i < count; ++i) { 234 for (int i = 0; i < count; ++i) {
235 const float* matrix = &matrices[N * N * i]; 235 const float* matrix = &matrices[N * N * i];
236 memcpy(buffer, &matrix[0], N * sizeof(float)); 236 for (int j = 0; j < N; ++j) {
237 buffer = static_cast<char*>(buffer) + 4*sizeof(float); 237 memcpy(buffer, &matrix[j * N], N * sizeof(float));
238 memcpy(buffer, &matrix[3], N * sizeof(float)); 238 buffer = static_cast<char*>(buffer) + 4 * sizeof(float);
239 buffer = static_cast<char*>(buffer) + 4*sizeof(float); 239 }
240 memcpy(buffer, &matrix[6], N * sizeof(float));
241 buffer = static_cast<char*>(buffer) + 4*sizeof(float);
242 } 240 }
243 } 241 }
244 }; 242 };
245 243
246 template<> struct set_uniform_matrix<4> { 244 template<> struct set_uniform_matrix<4> {
247 inline static void set(void* buffer, int uniformOffset, int count, const flo at matrices[]) { 245 inline static void set(void* buffer, int uniformOffset, int count, const flo at matrices[]) {
248 GR_STATIC_ASSERT(sizeof(float) == 4); 246 GR_STATIC_ASSERT(sizeof(float) == 4);
249 buffer = static_cast<char*>(buffer) + uniformOffset; 247 buffer = static_cast<char*>(buffer) + uniformOffset;
250 memcpy(buffer, matrices, count * 16 * sizeof(float)); 248 memcpy(buffer, matrices, count * 16 * sizeof(float));
251 } 249 }
252 }; 250 };
253 251
254 bool GrVkPipelineStateDataManager::uploadUniformBuffers(GrVkGpu* gpu, 252 bool GrVkPipelineStateDataManager::uploadUniformBuffers(GrVkGpu* gpu,
255 GrVkUniformBuffer* verte xBuffer, 253 GrVkUniformBuffer* verte xBuffer,
256 GrVkUniformBuffer* fragm entBuffer) const { 254 GrVkUniformBuffer* fragm entBuffer) const {
257 bool updatedBuffer = false; 255 bool updatedBuffer = false;
258 if (vertexBuffer && fVertexUniformsDirty) { 256 if (vertexBuffer && fVertexUniformsDirty) {
259 SkAssertResult(vertexBuffer->updateData(gpu, fVertexUniformData.get(), f VertexUniformSize, 257 SkAssertResult(vertexBuffer->updateData(gpu, fVertexUniformData.get(), f VertexUniformSize,
260 &updatedBuffer)); 258 &updatedBuffer));
261 fVertexUniformsDirty = false; 259 fVertexUniformsDirty = false;
262 } 260 }
263 261
264 if (fragmentBuffer && fFragmentUniformsDirty) { 262 if (fragmentBuffer && fFragmentUniformsDirty) {
265 SkAssertResult(fragmentBuffer->updateData(gpu, fFragmentUniformData.get( ), 263 SkAssertResult(fragmentBuffer->updateData(gpu, fFragmentUniformData.get( ),
266 fFragmentUniformSize, &updated Buffer)); 264 fFragmentUniformSize, &updated Buffer));
267 fFragmentUniformsDirty = false; 265 fFragmentUniformsDirty = false;
268 } 266 }
269 return updatedBuffer; 267 return updatedBuffer;
270 } 268 }
OLDNEW
« no previous file with comments | « gyp/shaderc.gyp ('k') | src/gpu/vk/GrVkUniformHandler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698