diff options
author | fmenozzi <fmenozzi@google.com> | 2016-07-20 08:26:12 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-07-20 08:26:12 -0700 |
commit | 35a98c733fb69ab72623cfd62ee2ac9859b0c613 (patch) | |
tree | 9e649b8f5dfc920dd71307a9bb6ea93100b5e711 /src | |
parent | 487f8d385be2e0dcc7e46339d7bb12e4820b91c8 (diff) |
Add integer array uniforms to GL and Vulkan
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2163173005
Review-Url: https://codereview.chromium.org/2163173005
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/gl/GrGLProgramDataManager.cpp | 15 | ||||
-rw-r--r-- | src/gpu/gl/GrGLProgramDataManager.h | 1 | ||||
-rw-r--r-- | src/gpu/glsl/GrGLSLProgramDataManager.h | 1 | ||||
-rw-r--r-- | src/gpu/vk/GrVkPipelineStateDataManager.cpp | 18 | ||||
-rw-r--r-- | src/gpu/vk/GrVkPipelineStateDataManager.h | 1 |
5 files changed, 36 insertions, 0 deletions
diff --git a/src/gpu/gl/GrGLProgramDataManager.cpp b/src/gpu/gl/GrGLProgramDataManager.cpp index 056e7b73dd..9fe7d3b4f7 100644 --- a/src/gpu/gl/GrGLProgramDataManager.cpp +++ b/src/gpu/gl/GrGLProgramDataManager.cpp @@ -102,6 +102,21 @@ void GrGLProgramDataManager::set1i(UniformHandle u, int32_t i) const { } } +void GrGLProgramDataManager::set1iv(UniformHandle u, + int arrayCount, + const int v[]) const { + const Uniform& uni = fUniforms[u.toIndex()]; + SkASSERT(uni.fType == kInt_GrSLType); + SkASSERT(arrayCount > 0); + ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount); + if (kUnusedUniform != uni.fFSLocation) { + GR_GL_CALL(fGpu->glInterface(), Uniform1iv(uni.fFSLocation, arrayCount, v)); + } + if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) { + GR_GL_CALL(fGpu->glInterface(), Uniform1iv(uni.fVSLocation, arrayCount, v)); + } +} + void GrGLProgramDataManager::set1f(UniformHandle u, float v0) const { const Uniform& uni = fUniforms[u.toIndex()]; SkASSERT(uni.fType == kFloat_GrSLType); diff --git a/src/gpu/gl/GrGLProgramDataManager.h b/src/gpu/gl/GrGLProgramDataManager.h index b2c20400eb..30c4a63ebc 100644 --- a/src/gpu/gl/GrGLProgramDataManager.h +++ b/src/gpu/gl/GrGLProgramDataManager.h @@ -54,6 +54,7 @@ public: * array of uniforms. arrayCount must be <= the array count of the uniform. */ void set1i(UniformHandle, int32_t) const override; + void set1iv(UniformHandle, int arrayCount, const int v[]) const override; void set1f(UniformHandle, float v0) const override; void set1fv(UniformHandle, int arrayCount, const float v[]) const override; void set2f(UniformHandle, float, float) const override; diff --git a/src/gpu/glsl/GrGLSLProgramDataManager.h b/src/gpu/glsl/GrGLSLProgramDataManager.h index 508cdf06f8..442a1e5bc6 100644 --- a/src/gpu/glsl/GrGLSLProgramDataManager.h +++ b/src/gpu/glsl/GrGLSLProgramDataManager.h @@ -27,6 +27,7 @@ public: * array of uniforms. arrayCount must be <= the array count of the uniform. */ virtual void set1i(UniformHandle, int32_t) const = 0; + virtual void set1iv(UniformHandle, int arrayCount, const int v[]) const = 0; virtual void set1f(UniformHandle, float v0) const = 0; virtual void set1fv(UniformHandle, int arrayCount, const float v[]) const = 0; virtual void set2f(UniformHandle, float, float) const = 0; diff --git a/src/gpu/vk/GrVkPipelineStateDataManager.cpp b/src/gpu/vk/GrVkPipelineStateDataManager.cpp index 5711df3132..ef75bd3b9d 100644 --- a/src/gpu/vk/GrVkPipelineStateDataManager.cpp +++ b/src/gpu/vk/GrVkPipelineStateDataManager.cpp @@ -62,6 +62,24 @@ void GrVkPipelineStateDataManager::set1i(UniformHandle u, int32_t i) const { memcpy(buffer, &i, sizeof(int32_t)); } +void GrVkPipelineStateDataManager::set1iv(UniformHandle u, + int arrayCount, + const int32_t v[]) const { + const Uniform& uni = fUniforms[u.toIndex()]; + SkASSERT(uni.fType == kInt_GrSLType); + SkASSERT(arrayCount > 0); + SkASSERT(arrayCount <= uni.fArrayCount || + (1 == arrayCount && GrGLSLShaderVar::kNonArray == uni.fArrayCount)); + + void* buffer = this->getBufferPtrAndMarkDirty(uni); + SkASSERT(sizeof(int32_t) == 4); + for (int i = 0; i < arrayCount; ++i) { + const int32_t* curVec = &v[i]; + memcpy(buffer, curVec, sizeof(int32_t)); + buffer = static_cast<char*>(buffer) + 4*sizeof(int32_t); + } +} + void GrVkPipelineStateDataManager::set1f(UniformHandle u, float v0) const { const Uniform& uni = fUniforms[u.toIndex()]; SkASSERT(uni.fType == kFloat_GrSLType); diff --git a/src/gpu/vk/GrVkPipelineStateDataManager.h b/src/gpu/vk/GrVkPipelineStateDataManager.h index eb7176c785..312c6c659d 100644 --- a/src/gpu/vk/GrVkPipelineStateDataManager.h +++ b/src/gpu/vk/GrVkPipelineStateDataManager.h @@ -24,6 +24,7 @@ public: uint32_t fragmentUniformSize); void set1i(UniformHandle, int32_t) const override; + void set1iv(UniformHandle, int arrayCount, const int32_t v[]) const override; void set1f(UniformHandle, float v0) const override; void set1fv(UniformHandle, int arrayCount, const float v[]) const override; void set2f(UniformHandle, float, float) const override; |