Added support for Chrome's gpu command buffer extension BindUniformLocation.
R=bsalomon@google.com, bsalomon Author: skaslev@chromium.org Review URL: https://codereview.chromium.org/62163004 git-svn-id: http://skia.googlecode.com/svn/trunk@12178 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
5e4d9819db
commit
d3baf20dd1
@ -131,6 +131,8 @@ extern "C" {
|
|||||||
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLRenderbufferStorageMultisampleProc)(GrGLenum target, GrGLsizei samples, GrGLenum internalformat, GrGLsizei width, GrGLsizei height);
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLRenderbufferStorageMultisampleProc)(GrGLenum target, GrGLsizei samples, GrGLenum internalformat, GrGLsizei width, GrGLsizei height);
|
||||||
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLResolveMultisampleFramebufferProc)();
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLResolveMultisampleFramebufferProc)();
|
||||||
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLScissorProc)(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height);
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLScissorProc)(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height);
|
||||||
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLBindUniformLocation)(GrGLuint program, GrGLint location, const char* name);
|
||||||
|
|
||||||
#if GR_GL_USE_NEW_SHADER_SOURCE_SIGNATURE
|
#if GR_GL_USE_NEW_SHADER_SOURCE_SIGNATURE
|
||||||
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLShaderSourceProc)(GrGLuint shader, GrGLsizei count, const char* const * str, const GrGLint* length);
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLShaderSourceProc)(GrGLuint shader, GrGLsizei count, const char* const * str, const GrGLint* length);
|
||||||
#else
|
#else
|
||||||
|
@ -252,6 +252,9 @@ public:
|
|||||||
// the standard function in ES3+ or GL 3.0+.
|
// the standard function in ES3+ or GL 3.0+.
|
||||||
GLPtr<GrGLRenderbufferStorageMultisampleProc> fRenderbufferStorageMultisample;
|
GLPtr<GrGLRenderbufferStorageMultisampleProc> fRenderbufferStorageMultisample;
|
||||||
|
|
||||||
|
// Pointer to BindUniformLocationCHROMIUM from the GL_CHROMIUM_bind_uniform_location extension.
|
||||||
|
GLPtr<GrGLBindUniformLocation> fBindUniformLocation;
|
||||||
|
|
||||||
GLPtr<GrGLResolveMultisampleFramebufferProc> fResolveMultisampleFramebuffer;
|
GLPtr<GrGLResolveMultisampleFramebufferProc> fResolveMultisampleFramebuffer;
|
||||||
GLPtr<GrGLScissorProc> fScissor;
|
GLPtr<GrGLScissorProc> fScissor;
|
||||||
GLPtr<GrGLShaderSourceProc> fShaderSource;
|
GLPtr<GrGLShaderSourceProc> fShaderSource;
|
||||||
|
@ -260,7 +260,7 @@ public:
|
|||||||
const ModeColorFilterEffect& colorModeFilter = drawEffect.castEffect<ModeColorFilterEffect>();
|
const ModeColorFilterEffect& colorModeFilter = drawEffect.castEffect<ModeColorFilterEffect>();
|
||||||
GrGLfloat c[4];
|
GrGLfloat c[4];
|
||||||
GrColorToRGBAFloat(colorModeFilter.color(), c);
|
GrColorToRGBAFloat(colorModeFilter.color(), c);
|
||||||
uman.set4fv(fFilterColorUni, 0, 1, c);
|
uman.set4fv(fFilterColorUni, 1, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,8 +441,8 @@ public:
|
|||||||
GrGLfloat vec[] = {
|
GrGLfloat vec[] = {
|
||||||
m[4] * kScale, m[9] * kScale, m[14] * kScale, m[19] * kScale,
|
m[4] * kScale, m[9] * kScale, m[14] * kScale, m[19] * kScale,
|
||||||
};
|
};
|
||||||
uniManager.setMatrix4fv(fMatrixHandle, 0, 1, mt);
|
uniManager.setMatrix4fv(fMatrixHandle, 1, mt);
|
||||||
uniManager.set4fv(fVectorHandle, 0, 1, vec);
|
uniManager.set4fv(fVectorHandle, 1, vec);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -36,7 +36,7 @@ const SkScalar gOneQuarter = SkFloatToScalar(0.25f);
|
|||||||
#if SK_SUPPORT_GPU
|
#if SK_SUPPORT_GPU
|
||||||
void setUniformPoint3(const GrGLUniformManager& uman, UniformHandle uni, const SkPoint3& point) {
|
void setUniformPoint3(const GrGLUniformManager& uman, UniformHandle uni, const SkPoint3& point) {
|
||||||
GR_STATIC_ASSERT(sizeof(SkPoint3) == 3 * sizeof(GrGLfloat));
|
GR_STATIC_ASSERT(sizeof(SkPoint3) == 3 * sizeof(GrGLfloat));
|
||||||
uman.set3fv(uni, 0, 1, &point.fX);
|
uman.set3fv(uni, 1, &point.fX);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setUniformNormal3(const GrGLUniformManager& uman, UniformHandle uni, const SkPoint3& point) {
|
void setUniformNormal3(const GrGLUniformManager& uman, UniformHandle uni, const SkPoint3& point) {
|
||||||
|
@ -537,9 +537,9 @@ void GrGLMatrixConvolutionEffect::setData(const GrGLUniformManager& uman,
|
|||||||
float ySign = texture.origin() == kTopLeft_GrSurfaceOrigin ? 1.0f : -1.0f;
|
float ySign = texture.origin() == kTopLeft_GrSurfaceOrigin ? 1.0f : -1.0f;
|
||||||
imageIncrement[0] = 1.0f / texture.width();
|
imageIncrement[0] = 1.0f / texture.width();
|
||||||
imageIncrement[1] = ySign / texture.height();
|
imageIncrement[1] = ySign / texture.height();
|
||||||
uman.set2fv(fImageIncrementUni, 0, 1, imageIncrement);
|
uman.set2fv(fImageIncrementUni, 1, imageIncrement);
|
||||||
uman.set2fv(fTargetUni, 0, 1, conv.target());
|
uman.set2fv(fTargetUni, 1, conv.target());
|
||||||
uman.set1fv(fKernelUni, 0, fKernelSize.width() * fKernelSize.height(), conv.kernel());
|
uman.set1fv(fKernelUni, fKernelSize.width() * fKernelSize.height(), conv.kernel());
|
||||||
uman.set1f(fGainUni, conv.gain());
|
uman.set1f(fGainUni, conv.gain());
|
||||||
uman.set1f(fBiasUni, conv.bias());
|
uman.set1f(fBiasUni, conv.bias());
|
||||||
const SkIRect& bounds = conv.bounds();
|
const SkIRect& bounds = conv.bounds();
|
||||||
|
@ -434,7 +434,7 @@ void GrGLMorphologyEffect::setData(const GrGLUniformManager& uman,
|
|||||||
default:
|
default:
|
||||||
GrCrash("Unknown filter direction.");
|
GrCrash("Unknown filter direction.");
|
||||||
}
|
}
|
||||||
uman.set2fv(fImageIncrementUni, 0, 1, imageIncrement);
|
uman.set2fv(fImageIncrementUni, 1, imageIncrement);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -655,7 +655,7 @@ void GrGLConical2Gradient::setData(const GrGLUniformManager& uman,
|
|||||||
SkScalarToFloat(diffRadius)
|
SkScalarToFloat(diffRadius)
|
||||||
};
|
};
|
||||||
|
|
||||||
uman.set1fv(fParamUni, 0, 6, values);
|
uman.set1fv(fParamUni, 6, values);
|
||||||
fCachedCenter = centerX1;
|
fCachedCenter = centerX1;
|
||||||
fCachedRadius = radius0;
|
fCachedRadius = radius0;
|
||||||
fCachedDiffRadius = diffRadius;
|
fCachedDiffRadius = diffRadius;
|
||||||
|
@ -638,7 +638,7 @@ void GrGLRadial2Gradient::setData(const GrGLUniformManager& uman,
|
|||||||
data.isPosRoot() ? 1.f : -1.f
|
data.isPosRoot() ? 1.f : -1.f
|
||||||
};
|
};
|
||||||
|
|
||||||
uman.set1fv(fParamUni, 0, 6, values);
|
uman.set1fv(fParamUni, 6, values);
|
||||||
fCachedCenter = centerX1;
|
fCachedCenter = centerX1;
|
||||||
fCachedRadius = radius0;
|
fCachedRadius = radius0;
|
||||||
fCachedPosRoot = data.isPosRoot();
|
fCachedPosRoot = data.isPosRoot();
|
||||||
|
@ -95,7 +95,7 @@ void GrGLBicubicEffect::setData(const GrGLUniformManager& uman,
|
|||||||
float imageIncrement[2];
|
float imageIncrement[2];
|
||||||
imageIncrement[0] = 1.0f / texture.width();
|
imageIncrement[0] = 1.0f / texture.width();
|
||||||
imageIncrement[1] = 1.0f / texture.height();
|
imageIncrement[1] = 1.0f / texture.height();
|
||||||
uman.set2fv(fImageIncrementUni, 0, 1, imageIncrement);
|
uman.set2fv(fImageIncrementUni, 1, imageIncrement);
|
||||||
uman.setMatrix4f(fCoefficientsUni, effect.coefficients());
|
uman.setMatrix4f(fCoefficientsUni, effect.coefficients());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ void GrGLConvolutionEffect::setData(const GrGLUniformManager& uman,
|
|||||||
default:
|
default:
|
||||||
GrCrash("Unknown filter direction.");
|
GrCrash("Unknown filter direction.");
|
||||||
}
|
}
|
||||||
uman.set2fv(fImageIncrementUni, 0, 1, imageIncrement);
|
uman.set2fv(fImageIncrementUni, 1, imageIncrement);
|
||||||
if (conv.useBounds()) {
|
if (conv.useBounds()) {
|
||||||
const float* bounds = conv.bounds();
|
const float* bounds = conv.bounds();
|
||||||
if (Gr1DKernelEffect::kY_Direction == conv.direction() &&
|
if (Gr1DKernelEffect::kY_Direction == conv.direction() &&
|
||||||
@ -130,7 +130,7 @@ void GrGLConvolutionEffect::setData(const GrGLUniformManager& uman,
|
|||||||
uman.set2f(fBoundsUni, bounds[0], bounds[1]);
|
uman.set2f(fBoundsUni, bounds[0], bounds[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
uman.set1fv(fKernelUni, 0, this->width(), conv.kernel());
|
uman.set1fv(fKernelUni, this->width(), conv.kernel());
|
||||||
}
|
}
|
||||||
|
|
||||||
GrGLEffect::EffectKey GrGLConvolutionEffect::GenKey(const GrDrawEffect& drawEffect,
|
GrGLEffect::EffectKey GrGLConvolutionEffect::GenKey(const GrDrawEffect& drawEffect,
|
||||||
|
@ -113,7 +113,7 @@ void GrGLTextureDomainEffect::setData(const GrGLUniformManager& uman,
|
|||||||
SkTSwap(values[1], values[3]);
|
SkTSwap(values[1], values[3]);
|
||||||
}
|
}
|
||||||
if (0 != memcmp(values, fPrevDomain, 4 * sizeof(GrGLfloat))) {
|
if (0 != memcmp(values, fPrevDomain, 4 * sizeof(GrGLfloat))) {
|
||||||
uman.set4fv(fNameUni, 0, 1, values);
|
uman.set4fv(fNameUni, 1, values);
|
||||||
memcpy(fPrevDomain, values, 4 * sizeof(GrGLfloat));
|
memcpy(fPrevDomain, values, 4 * sizeof(GrGLfloat));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,7 @@ void GrGLProgram::setColor(const GrDrawState& drawState,
|
|||||||
// OpenGL ES doesn't support unsigned byte varieties of glUniform
|
// OpenGL ES doesn't support unsigned byte varieties of glUniform
|
||||||
GrGLfloat c[4];
|
GrGLfloat c[4];
|
||||||
GrColorToRGBAFloat(color, c);
|
GrColorToRGBAFloat(color, c);
|
||||||
fUniformManager.set4fv(fUniformHandles.fColorUni, 0, 1, c);
|
fUniformManager.set4fv(fUniformHandles.fColorUni, 1, c);
|
||||||
fColor = color;
|
fColor = color;
|
||||||
}
|
}
|
||||||
sharedState->fConstAttribColorIndex = -1;
|
sharedState->fConstAttribColorIndex = -1;
|
||||||
@ -311,7 +311,7 @@ void GrGLProgram::setCoverage(const GrDrawState& drawState,
|
|||||||
// OpenGL ES doesn't support unsigned byte varieties of glUniform
|
// OpenGL ES doesn't support unsigned byte varieties of glUniform
|
||||||
GrGLfloat c[4];
|
GrGLfloat c[4];
|
||||||
GrColorToRGBAFloat(coverage, c);
|
GrColorToRGBAFloat(coverage, c);
|
||||||
fUniformManager.set4fv(fUniformHandles.fCoverageUni, 0, 1, c);
|
fUniformManager.set4fv(fUniformHandles.fCoverageUni, 1, c);
|
||||||
fCoverage = coverage;
|
fCoverage = coverage;
|
||||||
}
|
}
|
||||||
sharedState->fConstAttribCoverageIndex = -1;
|
sharedState->fConstAttribCoverageIndex = -1;
|
||||||
|
@ -588,6 +588,9 @@ bool GrGLShaderBuilder::finish(GrGLuint* outProgramId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->bindProgramLocations(programId);
|
this->bindProgramLocations(programId);
|
||||||
|
if (fUniformManager.isUsingBindUniform()) {
|
||||||
|
fUniformManager.getUniformLocations(programId, fUniforms);
|
||||||
|
}
|
||||||
|
|
||||||
GL_CALL(LinkProgram(programId));
|
GL_CALL(LinkProgram(programId));
|
||||||
|
|
||||||
@ -619,7 +622,9 @@ bool GrGLShaderBuilder::finish(GrGLuint* outProgramId) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fUniformManager.getUniformLocations(programId, fUniforms);
|
if (!fUniformManager.isUsingBindUniform()) {
|
||||||
|
fUniformManager.getUniformLocations(programId, fUniforms);
|
||||||
|
}
|
||||||
*outProgramId = programId;
|
*outProgramId = programId;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,13 @@
|
|||||||
#include "gl/GrGpuGL.h"
|
#include "gl/GrGpuGL.h"
|
||||||
#include "SkMatrix.h"
|
#include "SkMatrix.h"
|
||||||
|
|
||||||
#define ASSERT_ARRAY_UPLOAD_IN_BOUNDS(UNI, OFFSET, COUNT) \
|
#define ASSERT_ARRAY_UPLOAD_IN_BOUNDS(UNI, COUNT) \
|
||||||
SkASSERT(offset + arrayCount <= uni.fArrayCount || \
|
SkASSERT(arrayCount <= uni.fArrayCount || \
|
||||||
(0 == offset && 1 == arrayCount && GrGLShaderVar::kNonArray == uni.fArrayCount))
|
(1 == arrayCount && GrGLShaderVar::kNonArray == uni.fArrayCount))
|
||||||
|
|
||||||
|
GrGLUniformManager::GrGLUniformManager(GrGpuGL* gpu) : fGpu(gpu) {
|
||||||
|
fUsingBindUniform = fGpu->glInterface()->fBindUniformLocation != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
GrGLUniformManager::UniformHandle GrGLUniformManager::appendUniform(GrSLType type, int arrayCount) {
|
GrGLUniformManager::UniformHandle GrGLUniformManager::appendUniform(GrSLType type, int arrayCount) {
|
||||||
int idx = fUniforms.count();
|
int idx = fUniforms.count();
|
||||||
@ -56,22 +60,21 @@ void GrGLUniformManager::set1f(UniformHandle u, GrGLfloat v0) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GrGLUniformManager::set1fv(UniformHandle u,
|
void GrGLUniformManager::set1fv(UniformHandle u,
|
||||||
int offset,
|
|
||||||
int arrayCount,
|
int arrayCount,
|
||||||
const GrGLfloat v[]) const {
|
const GrGLfloat v[]) const {
|
||||||
const Uniform& uni = fUniforms[u.toUniformIndex()];
|
const Uniform& uni = fUniforms[u.toUniformIndex()];
|
||||||
SkASSERT(uni.fType == kFloat_GrSLType);
|
SkASSERT(uni.fType == kFloat_GrSLType);
|
||||||
SkASSERT(arrayCount > 0);
|
SkASSERT(arrayCount > 0);
|
||||||
ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, offset, arrayCount);
|
ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
|
||||||
// This assert fires in some instances of the two-pt gradient for its VSParams.
|
// This assert fires in some instances of the two-pt gradient for its VSParams.
|
||||||
// Once the uniform manager is responsible for inserting the duplicate uniform
|
// Once the uniform manager is responsible for inserting the duplicate uniform
|
||||||
// arrays in VS and FS driver bug workaround, this can be enabled.
|
// arrays in VS and FS driver bug workaround, this can be enabled.
|
||||||
//SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocation);
|
//SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocation);
|
||||||
if (kUnusedUniform != uni.fFSLocation) {
|
if (kUnusedUniform != uni.fFSLocation) {
|
||||||
GR_GL_CALL(fGpu->glInterface(), Uniform1fv(uni.fFSLocation + offset, arrayCount, v));
|
GR_GL_CALL(fGpu->glInterface(), Uniform1fv(uni.fFSLocation, arrayCount, v));
|
||||||
}
|
}
|
||||||
if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
|
if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
|
||||||
GR_GL_CALL(fGpu->glInterface(), Uniform1fv(uni.fVSLocation + offset, arrayCount, v));
|
GR_GL_CALL(fGpu->glInterface(), Uniform1fv(uni.fVSLocation, arrayCount, v));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,19 +92,18 @@ void GrGLUniformManager::set2f(UniformHandle u, GrGLfloat v0, GrGLfloat v1) cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GrGLUniformManager::set2fv(UniformHandle u,
|
void GrGLUniformManager::set2fv(UniformHandle u,
|
||||||
int offset,
|
|
||||||
int arrayCount,
|
int arrayCount,
|
||||||
const GrGLfloat v[]) const {
|
const GrGLfloat v[]) const {
|
||||||
const Uniform& uni = fUniforms[u.toUniformIndex()];
|
const Uniform& uni = fUniforms[u.toUniformIndex()];
|
||||||
SkASSERT(uni.fType == kVec2f_GrSLType);
|
SkASSERT(uni.fType == kVec2f_GrSLType);
|
||||||
SkASSERT(arrayCount > 0);
|
SkASSERT(arrayCount > 0);
|
||||||
ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, offset, arrayCount);
|
ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
|
||||||
SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocation);
|
SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocation);
|
||||||
if (kUnusedUniform != uni.fFSLocation) {
|
if (kUnusedUniform != uni.fFSLocation) {
|
||||||
GR_GL_CALL(fGpu->glInterface(), Uniform2fv(uni.fFSLocation + offset, arrayCount, v));
|
GR_GL_CALL(fGpu->glInterface(), Uniform2fv(uni.fFSLocation, arrayCount, v));
|
||||||
}
|
}
|
||||||
if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
|
if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
|
||||||
GR_GL_CALL(fGpu->glInterface(), Uniform2fv(uni.fVSLocation + offset, arrayCount, v));
|
GR_GL_CALL(fGpu->glInterface(), Uniform2fv(uni.fVSLocation, arrayCount, v));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,19 +121,18 @@ void GrGLUniformManager::set3f(UniformHandle u, GrGLfloat v0, GrGLfloat v1, GrGL
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GrGLUniformManager::set3fv(UniformHandle u,
|
void GrGLUniformManager::set3fv(UniformHandle u,
|
||||||
int offset,
|
|
||||||
int arrayCount,
|
int arrayCount,
|
||||||
const GrGLfloat v[]) const {
|
const GrGLfloat v[]) const {
|
||||||
const Uniform& uni = fUniforms[u.toUniformIndex()];
|
const Uniform& uni = fUniforms[u.toUniformIndex()];
|
||||||
SkASSERT(uni.fType == kVec3f_GrSLType);
|
SkASSERT(uni.fType == kVec3f_GrSLType);
|
||||||
SkASSERT(arrayCount > 0);
|
SkASSERT(arrayCount > 0);
|
||||||
ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, offset, arrayCount);
|
ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
|
||||||
SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocation);
|
SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocation);
|
||||||
if (kUnusedUniform != uni.fFSLocation) {
|
if (kUnusedUniform != uni.fFSLocation) {
|
||||||
GR_GL_CALL(fGpu->glInterface(), Uniform3fv(uni.fFSLocation + offset, arrayCount, v));
|
GR_GL_CALL(fGpu->glInterface(), Uniform3fv(uni.fFSLocation, arrayCount, v));
|
||||||
}
|
}
|
||||||
if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
|
if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
|
||||||
GR_GL_CALL(fGpu->glInterface(), Uniform3fv(uni.fVSLocation + offset, arrayCount, v));
|
GR_GL_CALL(fGpu->glInterface(), Uniform3fv(uni.fVSLocation, arrayCount, v));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,18 +154,18 @@ void GrGLUniformManager::set4f(UniformHandle u,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GrGLUniformManager::set4fv(UniformHandle u,
|
void GrGLUniformManager::set4fv(UniformHandle u,
|
||||||
int offset,
|
|
||||||
int arrayCount,
|
int arrayCount,
|
||||||
const GrGLfloat v[]) const {
|
const GrGLfloat v[]) const {
|
||||||
const Uniform& uni = fUniforms[u.toUniformIndex()];
|
const Uniform& uni = fUniforms[u.toUniformIndex()];
|
||||||
SkASSERT(uni.fType == kVec4f_GrSLType);
|
SkASSERT(uni.fType == kVec4f_GrSLType);
|
||||||
SkASSERT(arrayCount > 0);
|
SkASSERT(arrayCount > 0);
|
||||||
|
ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
|
||||||
SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocation);
|
SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocation);
|
||||||
if (kUnusedUniform != uni.fFSLocation) {
|
if (kUnusedUniform != uni.fFSLocation) {
|
||||||
GR_GL_CALL(fGpu->glInterface(), Uniform4fv(uni.fFSLocation + offset, arrayCount, v));
|
GR_GL_CALL(fGpu->glInterface(), Uniform4fv(uni.fFSLocation, arrayCount, v));
|
||||||
}
|
}
|
||||||
if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
|
if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
|
||||||
GR_GL_CALL(fGpu->glInterface(), Uniform4fv(uni.fVSLocation + offset, arrayCount, v));
|
GR_GL_CALL(fGpu->glInterface(), Uniform4fv(uni.fVSLocation, arrayCount, v));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,40 +197,38 @@ void GrGLUniformManager::setMatrix4f(UniformHandle u, const GrGLfloat matrix[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GrGLUniformManager::setMatrix3fv(UniformHandle u,
|
void GrGLUniformManager::setMatrix3fv(UniformHandle u,
|
||||||
int offset,
|
|
||||||
int arrayCount,
|
int arrayCount,
|
||||||
const GrGLfloat matrices[]) const {
|
const GrGLfloat matrices[]) const {
|
||||||
const Uniform& uni = fUniforms[u.toUniformIndex()];
|
const Uniform& uni = fUniforms[u.toUniformIndex()];
|
||||||
SkASSERT(uni.fType == kMat33f_GrSLType);
|
SkASSERT(uni.fType == kMat33f_GrSLType);
|
||||||
SkASSERT(arrayCount > 0);
|
SkASSERT(arrayCount > 0);
|
||||||
ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, offset, arrayCount);
|
ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
|
||||||
SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocation);
|
SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocation);
|
||||||
if (kUnusedUniform != uni.fFSLocation) {
|
if (kUnusedUniform != uni.fFSLocation) {
|
||||||
GR_GL_CALL(fGpu->glInterface(),
|
GR_GL_CALL(fGpu->glInterface(),
|
||||||
UniformMatrix3fv(uni.fFSLocation + offset, arrayCount, false, matrices));
|
UniformMatrix3fv(uni.fFSLocation, arrayCount, false, matrices));
|
||||||
}
|
}
|
||||||
if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
|
if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
|
||||||
GR_GL_CALL(fGpu->glInterface(),
|
GR_GL_CALL(fGpu->glInterface(),
|
||||||
UniformMatrix3fv(uni.fVSLocation + offset, arrayCount, false, matrices));
|
UniformMatrix3fv(uni.fVSLocation, arrayCount, false, matrices));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrGLUniformManager::setMatrix4fv(UniformHandle u,
|
void GrGLUniformManager::setMatrix4fv(UniformHandle u,
|
||||||
int offset,
|
|
||||||
int arrayCount,
|
int arrayCount,
|
||||||
const GrGLfloat matrices[]) const {
|
const GrGLfloat matrices[]) const {
|
||||||
const Uniform& uni = fUniforms[u.toUniformIndex()];
|
const Uniform& uni = fUniforms[u.toUniformIndex()];
|
||||||
SkASSERT(uni.fType == kMat44f_GrSLType);
|
SkASSERT(uni.fType == kMat44f_GrSLType);
|
||||||
SkASSERT(arrayCount > 0);
|
SkASSERT(arrayCount > 0);
|
||||||
ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, offset, arrayCount);
|
ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
|
||||||
SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocation);
|
SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocation);
|
||||||
if (kUnusedUniform != uni.fFSLocation) {
|
if (kUnusedUniform != uni.fFSLocation) {
|
||||||
GR_GL_CALL(fGpu->glInterface(),
|
GR_GL_CALL(fGpu->glInterface(),
|
||||||
UniformMatrix4fv(uni.fFSLocation + offset, arrayCount, false, matrices));
|
UniformMatrix4fv(uni.fFSLocation, arrayCount, false, matrices));
|
||||||
}
|
}
|
||||||
if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
|
if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
|
||||||
GR_GL_CALL(fGpu->glInterface(),
|
GR_GL_CALL(fGpu->glInterface(),
|
||||||
UniformMatrix4fv(uni.fVSLocation + offset, arrayCount, false, matrices));
|
UniformMatrix4fv(uni.fVSLocation, arrayCount, false, matrices));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,8 +257,14 @@ void GrGLUniformManager::getUniformLocations(GrGLuint programID, const BuilderUn
|
|||||||
SkASSERT(uniforms[i].fVariable.getArrayCount() == fUniforms[i].fArrayCount);
|
SkASSERT(uniforms[i].fVariable.getArrayCount() == fUniforms[i].fArrayCount);
|
||||||
GrGLint location;
|
GrGLint location;
|
||||||
// TODO: Move the Xoom uniform array in both FS and VS bug workaround here.
|
// TODO: Move the Xoom uniform array in both FS and VS bug workaround here.
|
||||||
GR_GL_CALL_RET(fGpu->glInterface(), location,
|
if (fUsingBindUniform) {
|
||||||
|
location = i;
|
||||||
|
GR_GL_CALL(fGpu->glInterface(),
|
||||||
|
BindUniformLocation(programID, location, uniforms[i].fVariable.c_str()));
|
||||||
|
} else {
|
||||||
|
GR_GL_CALL_RET(fGpu->glInterface(), location,
|
||||||
GetUniformLocation(programID, uniforms[i].fVariable.c_str()));
|
GetUniformLocation(programID, uniforms[i].fVariable.c_str()));
|
||||||
|
}
|
||||||
if (GrGLShaderBuilder::kVertex_Visibility & uniforms[i].fVisibility) {
|
if (GrGLShaderBuilder::kVertex_Visibility & uniforms[i].fVisibility) {
|
||||||
fUniforms[i].fVSLocation = location;
|
fUniforms[i].fVSLocation = location;
|
||||||
}
|
}
|
||||||
|
@ -46,28 +46,28 @@ public:
|
|||||||
friend class GrGLUniformManager; // For accessing toUniformIndex().
|
friend class GrGLUniformManager; // For accessing toUniformIndex().
|
||||||
};
|
};
|
||||||
|
|
||||||
GrGLUniformManager(GrGpuGL* gpu) : fGpu(gpu) {}
|
GrGLUniformManager(GrGpuGL* gpu);
|
||||||
|
|
||||||
UniformHandle appendUniform(GrSLType type, int arrayCount = GrGLShaderVar::kNonArray);
|
UniformHandle appendUniform(GrSLType type, int arrayCount = GrGLShaderVar::kNonArray);
|
||||||
|
|
||||||
/** Functions for uploading uniform values. The varities ending in v can be used to upload to an
|
/** Functions for uploading uniform values. The varities ending in v can be used to upload to an
|
||||||
* array of uniforms. offset + arrayCount must be <= the array count of the uniform.
|
* array of uniforms. arrayCount must be <= the array count of the uniform.
|
||||||
*/
|
*/
|
||||||
void setSampler(UniformHandle, GrGLint texUnit) const;
|
void setSampler(UniformHandle, GrGLint texUnit) const;
|
||||||
void set1f(UniformHandle, GrGLfloat v0) const;
|
void set1f(UniformHandle, GrGLfloat v0) const;
|
||||||
void set1fv(UniformHandle, int offset, int arrayCount, const GrGLfloat v[]) const;
|
void set1fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const;
|
||||||
void set2f(UniformHandle, GrGLfloat, GrGLfloat) const;
|
void set2f(UniformHandle, GrGLfloat, GrGLfloat) const;
|
||||||
void set2fv(UniformHandle, int offset, int arrayCount, const GrGLfloat v[]) const;
|
void set2fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const;
|
||||||
void set3f(UniformHandle, GrGLfloat, GrGLfloat, GrGLfloat) const;
|
void set3f(UniformHandle, GrGLfloat, GrGLfloat, GrGLfloat) const;
|
||||||
void set3fv(UniformHandle, int offset, int arrayCount, const GrGLfloat v[]) const;
|
void set3fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const;
|
||||||
void set4f(UniformHandle, GrGLfloat, GrGLfloat, GrGLfloat, GrGLfloat) const;
|
void set4f(UniformHandle, GrGLfloat, GrGLfloat, GrGLfloat, GrGLfloat) const;
|
||||||
void set4fv(UniformHandle, int offset, int arrayCount, const GrGLfloat v[]) const;
|
void set4fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const;
|
||||||
// matrices are column-major, the first three upload a single matrix, the latter three upload
|
// matrices are column-major, the first three upload a single matrix, the latter three upload
|
||||||
// arrayCount matrices into a uniform array.
|
// arrayCount matrices into a uniform array.
|
||||||
void setMatrix3f(UniformHandle, const GrGLfloat matrix[]) const;
|
void setMatrix3f(UniformHandle, const GrGLfloat matrix[]) const;
|
||||||
void setMatrix4f(UniformHandle, const GrGLfloat matrix[]) const;
|
void setMatrix4f(UniformHandle, const GrGLfloat matrix[]) const;
|
||||||
void setMatrix3fv(UniformHandle, int offset, int arrayCount, const GrGLfloat matrices[]) const;
|
void setMatrix3fv(UniformHandle, int arrayCount, const GrGLfloat matrices[]) const;
|
||||||
void setMatrix4fv(UniformHandle, int offset, int arrayCount, const GrGLfloat matrices[]) const;
|
void setMatrix4fv(UniformHandle, int arrayCount, const GrGLfloat matrices[]) const;
|
||||||
|
|
||||||
// convenience method for uploading a SkMatrix to a 3x3 matrix uniform
|
// convenience method for uploading a SkMatrix to a 3x3 matrix uniform
|
||||||
void setSkMatrix(UniformHandle, const SkMatrix&) const;
|
void setSkMatrix(UniformHandle, const SkMatrix&) const;
|
||||||
@ -81,6 +81,13 @@ public:
|
|||||||
// name strings. Otherwise, we'd have to hand out copies.
|
// name strings. Otherwise, we'd have to hand out copies.
|
||||||
typedef GrTAllocator<BuilderUniform> BuilderUniformArray;
|
typedef GrTAllocator<BuilderUniform> BuilderUniformArray;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by the GrGLShaderBuilder to know if the manager is using
|
||||||
|
* BindUniformLocation. In that case getUniformLocations must be called
|
||||||
|
* before the program is linked.
|
||||||
|
*/
|
||||||
|
bool isUsingBindUniform() const { return fUsingBindUniform; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by the GrGLShaderBuilder to get GL locations for all uniforms.
|
* Called by the GrGLShaderBuilder to get GL locations for all uniforms.
|
||||||
*/
|
*/
|
||||||
@ -103,6 +110,7 @@ private:
|
|||||||
int fArrayCount;
|
int fArrayCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool fUsingBindUniform;
|
||||||
SkTArray<Uniform, true> fUniforms;
|
SkTArray<Uniform, true> fUniforms;
|
||||||
GrGpuGL* fGpu;
|
GrGpuGL* fGpu;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user