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

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

Issue 2163173005: Add integer array uniforms to GL and Vulkan (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 | « src/gpu/vk/GrVkPipelineStateDataManager.h ('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 #include "GrVkPipelineStateDataManager.h" 8 #include "GrVkPipelineStateDataManager.h"
9 9
10 #include "GrVkGpu.h" 10 #include "GrVkGpu.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 } 55 }
56 56
57 void GrVkPipelineStateDataManager::set1i(UniformHandle u, int32_t i) const { 57 void GrVkPipelineStateDataManager::set1i(UniformHandle u, int32_t i) const {
58 const Uniform& uni = fUniforms[u.toIndex()]; 58 const Uniform& uni = fUniforms[u.toIndex()];
59 SkASSERT(uni.fType == kInt_GrSLType); 59 SkASSERT(uni.fType == kInt_GrSLType);
60 SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); 60 SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
61 void* buffer = this->getBufferPtrAndMarkDirty(uni); 61 void* buffer = this->getBufferPtrAndMarkDirty(uni);
62 memcpy(buffer, &i, sizeof(int32_t)); 62 memcpy(buffer, &i, sizeof(int32_t));
63 } 63 }
64 64
65 void GrVkPipelineStateDataManager::set1iv(UniformHandle u,
66 int arrayCount,
67 const int32_t v[]) const {
68 const Uniform& uni = fUniforms[u.toIndex()];
69 SkASSERT(uni.fType == kInt_GrSLType);
70 SkASSERT(arrayCount > 0);
71 SkASSERT(arrayCount <= uni.fArrayCount ||
72 (1 == arrayCount && GrGLSLShaderVar::kNonArray == uni.fArrayCount)) ;
73
74 void* buffer = this->getBufferPtrAndMarkDirty(uni);
75 SkASSERT(sizeof(int32_t) == 4);
76 for (int i = 0; i < arrayCount; ++i) {
77 const int32_t* curVec = &v[i];
78 memcpy(buffer, curVec, sizeof(int32_t));
79 buffer = static_cast<char*>(buffer) + 4*sizeof(int32_t);
80 }
81 }
82
65 void GrVkPipelineStateDataManager::set1f(UniformHandle u, float v0) const { 83 void GrVkPipelineStateDataManager::set1f(UniformHandle u, float v0) const {
66 const Uniform& uni = fUniforms[u.toIndex()]; 84 const Uniform& uni = fUniforms[u.toIndex()];
67 SkASSERT(uni.fType == kFloat_GrSLType); 85 SkASSERT(uni.fType == kFloat_GrSLType);
68 SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); 86 SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
69 void* buffer = this->getBufferPtrAndMarkDirty(uni); 87 void* buffer = this->getBufferPtrAndMarkDirty(uni);
70 SkASSERT(sizeof(float) == 4); 88 SkASSERT(sizeof(float) == 4);
71 memcpy(buffer, &v0, sizeof(float)); 89 memcpy(buffer, &v0, sizeof(float));
72 } 90 }
73 91
74 void GrVkPipelineStateDataManager::set1fv(UniformHandle u, 92 void GrVkPipelineStateDataManager::set1fv(UniformHandle u,
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 fVertexUniformsDirty = false; 277 fVertexUniformsDirty = false;
260 } 278 }
261 279
262 if (fragmentBuffer && fFragmentUniformsDirty) { 280 if (fragmentBuffer && fFragmentUniformsDirty) {
263 SkAssertResult(fragmentBuffer->updateData(gpu, fFragmentUniformData.get( ), 281 SkAssertResult(fragmentBuffer->updateData(gpu, fFragmentUniformData.get( ),
264 fFragmentUniformSize, &updated Buffer)); 282 fFragmentUniformSize, &updated Buffer));
265 fFragmentUniformsDirty = false; 283 fFragmentUniformsDirty = false;
266 } 284 }
267 return updatedBuffer; 285 return updatedBuffer;
268 } 286 }
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkPipelineStateDataManager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698