Integers can now be passed as uniforms; needed for passing color count to fragment shader

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2076143003

Committed: https://skia.googlesource.com/skia/+/cc3a22b369e1a60fa2acf2987f2934baf7c4b198
Review-Url: https://codereview.chromium.org/2076143003
This commit is contained in:
fmenozzi 2016-06-21 09:42:12 -07:00 committed by Commit bot
parent 67cb666481
commit 497e9e2b36
5 changed files with 24 additions and 0 deletions

View File

@ -89,6 +89,19 @@ void GrGLProgramDataManager::setSamplers(const SkTArray<GrGLSampler>& samplers)
}
}
void GrGLProgramDataManager::set1i(UniformHandle u, int32_t i) const {
const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kInt_GrSLType);
SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
SkDEBUGCODE(this->printUnused(uni));
if (kUnusedUniform != uni.fFSLocation) {
GR_GL_CALL(fGpu->glInterface(), Uniform1i(uni.fFSLocation, i));
}
if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
GR_GL_CALL(fGpu->glInterface(), Uniform1i(uni.fVSLocation, i));
}
}
void GrGLProgramDataManager::set1f(UniformHandle u, float v0) const {
const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kFloat_GrSLType);

View File

@ -53,6 +53,7 @@ public:
/** Functions for uploading uniform values. The varities ending in v can be used to upload to an
* array of uniforms. arrayCount must be <= the array count of the uniform.
*/
void set1i(UniformHandle, int32_t) 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;

View File

@ -26,6 +26,7 @@ public:
/** Functions for uploading uniform values. The varities ending in v can be used to upload to an
* array of uniforms. arrayCount must be <= the array count of the uniform.
*/
virtual void set1i(UniformHandle, int32_t) 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;

View File

@ -54,6 +54,14 @@ void* GrVkPipelineStateDataManager::getBufferPtrAndMarkDirty(const Uniform& uni)
return buffer;
}
void GrVkPipelineStateDataManager::set1i(UniformHandle u, int32_t i) const {
const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kInt_GrSLType);
SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
void* buffer = this->getBufferPtrAndMarkDirty(uni);
memcpy(buffer, &i, sizeof(int32_t));
}
void GrVkPipelineStateDataManager::set1f(UniformHandle u, float v0) const {
const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kFloat_GrSLType);

View File

@ -23,6 +23,7 @@ public:
uint32_t vertexUniformSize,
uint32_t fragmentUniformSize);
void set1i(UniformHandle, int32_t) 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;