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

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

Issue 1431433003: Move shader compiling to ProgramBuilder and various ShaderBuilder cleanups. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nits Created 5 years, 2 months 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
« no previous file with comments | « src/gpu/gl/builders/GrGLProgramBuilder.h ('k') | src/gpu/gl/builders/GrGLShaderBuilder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/builders/GrGLProgramBuilder.cpp
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index 2afd3c4ab4959d01d558a563b9ea3f9e4725dd23..aca8e53f850f2b5c67075219efa87b203e56def7 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -13,11 +13,13 @@
#include "GrTexture.h"
#include "SkRTConf.h"
#include "SkTraceEvent.h"
+#include "gl/GrGLFragmentProcessor.h"
#include "gl/GrGLGeometryProcessor.h"
#include "gl/GrGLGpu.h"
#include "gl/GrGLProgram.h"
#include "gl/GrGLSLPrettyPrint.h"
#include "gl/GrGLXferProcessor.h"
+#include "gl/builders/GrGLShaderStringBuilder.h"
#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "glsl/GrGLSLTextureSampler.h"
@@ -380,6 +382,28 @@ void GrGLProgramBuilder::emitSamplers(const GrProcessor& processor,
}
}
+bool GrGLProgramBuilder::compileAndAttachShaders(GrGLShaderBuilder& shader,
+ GrGLuint programId,
+ GrGLenum type,
+ SkTDArray<GrGLuint>* shaderIds) {
+ GrGLGpu* gpu = this->gpu();
+ GrGLuint shaderId = GrGLCompileAndAttachShader(gpu->glContext(),
+ programId,
+ type,
+ shader.fCompilerStrings.begin(),
+ shader.fCompilerStringLengths.begin(),
+ shader.fCompilerStrings.count(),
+ gpu->stats());
+
+ if (!shaderId) {
+ return false;
+ }
+
+ *shaderIds->append() = shaderId;
+
+ return true;
+}
+
GrGLProgram* GrGLProgramBuilder::finalize() {
// verify we can get a program id
GrGLuint programID;
@@ -390,8 +414,8 @@ GrGLProgram* GrGLProgramBuilder::finalize() {
// compile shaders and bind attributes / uniforms
SkTDArray<GrGLuint> shadersToDelete;
-
- if (!fVS.compileAndAttachShaders(programID, &shadersToDelete)) {
+ fVS.finalize(kVertex_Visibility);
+ if (!this->compileAndAttachShaders(fVS, programID, GR_GL_VERTEX_SHADER, &shadersToDelete)) {
this->cleanupProgram(programID, shadersToDelete);
return nullptr;
}
@@ -402,7 +426,8 @@ GrGLProgram* GrGLProgramBuilder::finalize() {
fVS.bindVertexAttributes(programID);
}
- if (!fFS.compileAndAttachShaders(programID, &shadersToDelete)) {
+ fFS.finalize(kFragment_Visibility);
+ if (!this->compileAndAttachShaders(fFS, programID, GR_GL_FRAGMENT_SHADER, &shadersToDelete)) {
this->cleanupProgram(programID, shadersToDelete);
return nullptr;
}
« no previous file with comments | « src/gpu/gl/builders/GrGLProgramBuilder.h ('k') | src/gpu/gl/builders/GrGLShaderBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698