aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/gl')
-rw-r--r--src/gpu/gl/GrGLProgram.cpp60
-rw-r--r--src/gpu/gl/GrGLProgram.h9
2 files changed, 30 insertions, 39 deletions
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index 52d53bde95..a392bc26f0 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -84,9 +84,13 @@ void GrGLProgram::setData(const GrPrimitiveProcessor& primProc, const GrPipeline
int nextTexSamplerIdx = 0;
fPrimitiveProcessor->setData(fProgramDataManager, primProc,
GrFragmentProcessor::CoordTransformIter(pipeline));
- this->bindTextures(primProc, &nextTexSamplerIdx);
+ for (int i = 0; i < primProc.numTextureSamplers(); ++i) {
+ const GrPrimitiveProcessor::TextureSampler& sampler = primProc.textureSampler(i);
+ fGpu->bindTexture(nextTexSamplerIdx++, sampler.samplerState(),
+ static_cast<GrGLTexture*>(sampler.peekTexture()));
+ }
- this->setFragmentData(primProc, pipeline, &nextTexSamplerIdx);
+ this->setFragmentData(pipeline, &nextTexSamplerIdx);
const GrXferProcessor& xp = pipeline.getXferProcessor();
SkIPoint offset;
@@ -102,31 +106,47 @@ void GrGLProgram::setData(const GrPrimitiveProcessor& primProc, const GrPipeline
void GrGLProgram::generateMipmaps(const GrPrimitiveProcessor& primProc,
const GrPipeline& pipeline) {
- this->generateMipmaps(primProc);
+ auto genLevelsIfNeeded = [this](GrTexture* tex, const GrSamplerState& sampler) {
+ if (sampler.filter() == GrSamplerState::Filter::kMipMap &&
+ tex->texturePriv().mipMapped() == GrMipMapped::kYes &&
+ tex->texturePriv().mipMapsAreDirty()) {
+ SkASSERT(fGpu->caps()->mipMapSupport());
+ fGpu->regenerateMipMapLevels(static_cast<GrGLTexture*>(tex));
+ }
+ };
+
+ for (int i = 0; i < primProc.numTextureSamplers(); ++i) {
+ const auto& textureSampler = primProc.textureSampler(i);
+ genLevelsIfNeeded(textureSampler.peekTexture(), textureSampler.samplerState());
+ }
GrFragmentProcessor::Iter iter(pipeline);
while (const GrFragmentProcessor* fp = iter.next()) {
- this->generateMipmaps(*fp);
+ for (int i = 0; i < fp->numTextureSamplers(); ++i) {
+ const auto& textureSampler = fp->textureSampler(i);
+ genLevelsIfNeeded(textureSampler.peekTexture(), textureSampler.samplerState());
+ }
}
}
-void GrGLProgram::setFragmentData(const GrPrimitiveProcessor& primProc,
- const GrPipeline& pipeline,
- int* nextTexSamplerIdx) {
+void GrGLProgram::setFragmentData(const GrPipeline& pipeline, int* nextTexSamplerIdx) {
GrFragmentProcessor::Iter iter(pipeline);
GrGLSLFragmentProcessor::Iter glslIter(fFragmentProcessors.get(), fFragmentProcessorCnt);
const GrFragmentProcessor* fp = iter.next();
GrGLSLFragmentProcessor* glslFP = glslIter.next();
while (fp && glslFP) {
glslFP->setData(fProgramDataManager, *fp);
- this->bindTextures(*fp, nextTexSamplerIdx);
+ for (int i = 0; i < fp->numTextureSamplers(); ++i) {
+ const GrFragmentProcessor::TextureSampler& sampler = fp->textureSampler(i);
+ fGpu->bindTexture((*nextTexSamplerIdx)++, sampler.samplerState(),
+ static_cast<GrGLTexture*>(sampler.peekTexture()));
+ }
fp = iter.next();
glslFP = glslIter.next();
}
SkASSERT(!fp && !glslFP);
}
-
void GrGLProgram::setRenderTargetState(const GrPrimitiveProcessor& primProc,
const GrRenderTargetProxy* proxy) {
GrRenderTarget* rt = proxy->priv().peekRenderTarget();
@@ -156,25 +176,3 @@ void GrGLProgram::setRenderTargetState(const GrPrimitiveProcessor& primProc,
size, proxy->origin());
}
}
-
-void GrGLProgram::bindTextures(const GrResourceIOProcessor& processor,
- int* nextTexSamplerIdx) {
- for (int i = 0; i < processor.numTextureSamplers(); ++i) {
- const GrResourceIOProcessor::TextureSampler& sampler = processor.textureSampler(i);
- fGpu->bindTexture((*nextTexSamplerIdx)++, sampler.samplerState(),
- static_cast<GrGLTexture*>(sampler.peekTexture()));
- }
-}
-
-void GrGLProgram::generateMipmaps(const GrResourceIOProcessor& processor) {
- for (int i = 0; i < processor.numTextureSamplers(); ++i) {
- const GrResourceIOProcessor::TextureSampler& sampler = processor.textureSampler(i);
- auto* tex = sampler.peekTexture();
- if (sampler.samplerState().filter() == GrSamplerState::Filter::kMipMap &&
- tex->texturePriv().mipMapped() == GrMipMapped::kYes &&
- tex->texturePriv().mipMapsAreDirty()) {
- SkASSERT(fGpu->caps()->mipMapSupport());
- fGpu->regenerateMipMapLevels(static_cast<GrGLTexture*>(sampler.peekTexture()));
- }
- }
-}
diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h
index a8a3391adc..25b6e9a84e 100644
--- a/src/gpu/gl/GrGLProgram.h
+++ b/src/gpu/gl/GrGLProgram.h
@@ -19,7 +19,6 @@ class GrGLSLXferProcessor;
class GrPipeline;
class GrPrimitiveProcessor;
class GrRenderTargetProxy;
-class GrResourceIOProcessor;
/**
* This class manages a GPU program and records per-program information. It also records the vertex
@@ -140,17 +139,11 @@ public:
private:
// A helper to loop over effects, set the transforms (via subclass) and bind textures
- void setFragmentData(const GrPrimitiveProcessor&, const GrPipeline&, int* nextTexSamplerIdx);
+ void setFragmentData(const GrPipeline&, int* nextTexSamplerIdx);
// Helper for setData() that sets the view matrix and loads the render target height uniform
void setRenderTargetState(const GrPrimitiveProcessor&, const GrRenderTargetProxy*);
- // Helper for setData() that binds textures to the appropriate texture units
- void bindTextures(const GrResourceIOProcessor&, int* nextSamplerIdx);
-
- // Helper for generateMipmaps() that ensures mipmaps are up to date
- void generateMipmaps(const GrResourceIOProcessor&);
-
// these reflect the current values of uniforms (GL uniform values travel with program)
RenderTargetState fRenderTargetState;
GrGLSLBuiltinUniformHandles fBuiltinUniformHandles;