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

Unified Diff: src/gpu/gl/builders/GrGLProgramBuilder.cpp

Issue 1451683002: Initial version of external_oes texture support and unit test (Closed) Base URL: https://skia.googlesource.com/skia.git@target
Patch Set: update Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: src/gpu/gl/builders/GrGLProgramBuilder.cpp
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index 22834053f0d64b68fe9b1ad0bbebb679a6df8bbf..54df6af4780ceb2a573f227765b3d4ecc0e5aef4 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -358,6 +358,16 @@ void GrGLProgramBuilder::verify(const GrFragmentProcessor& fp) {
SkASSERT(fFS.hasReadFragmentPosition() == fp.willReadFragmentPosition());
}
+static GrSLType get_sampler_type(const GrTextureAccess& access) {
+ GrGLTexture* glTexture = static_cast<GrGLTexture*>(access.getTexture());
+ if (glTexture->target() == GR_GL_TEXTURE_EXTERNAL) {
+ return kSamplerExternal_GrSLType;
+ } else {
+ SkASSERT(glTexture->target() == GR_GL_TEXTURE_2D);
+ return kSampler2D_GrSLType;
+ }
+}
+
template <class Proc>
void GrGLProgramBuilder::emitSamplers(const GrProcessor& processor,
GrGLSLTextureSampler::TextureSamplerArray* outSamplers,
@@ -368,11 +378,19 @@ void GrGLProgramBuilder::emitSamplers(const GrProcessor& processor,
SkString name;
for (int t = 0; t < numTextures; ++t) {
name.printf("Sampler%d", t);
+ GrSLType samplerType = get_sampler_type(processor.textureAccess(t));
localSamplerUniforms[t] = this->addUniform(GrGLProgramBuilder::kFragment_Visibility,
- kSampler2D_GrSLType, kDefault_GrSLPrecision,
+ samplerType, kDefault_GrSLPrecision,
name.c_str());
SkNEW_APPEND_TO_TARRAY(outSamplers, GrGLSLTextureSampler,
(localSamplerUniforms[t], processor.textureAccess(t)));
+ if (kSamplerExternal_GrSLType == samplerType) {
+ const char* externalFeatureString = this->glslCaps()->externalTextureExtensionString();
+ // We shouldn't ever create a GrGLTexture that requires external sampler type
+ SkASSERT(externalFeatureString);
+ fFS.addFeature(1 << GrGLSLFragmentShaderBuilder::kExternalTexture_GLSLPrivateFeature,
+ externalFeatureString);
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698