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

Side by Side Diff: src/gpu/gl/builders/GrGLProgramBuilder.cpp

Issue 820783005: More changes to bring together path / geo procs (Closed) Base URL: https://skia.googlesource.com/skia.git@lc1
Patch Set: dm fix Created 5 years, 11 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 unified diff | Download patch
« no previous file with comments | « src/gpu/gl/builders/GrGLProgramBuilder.h ('k') | src/gpu/gl/builders/GrGLVertexShaderBuilder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrGLProgramBuilder.h" 8 #include "GrGLProgramBuilder.h"
9 #include "gl/GrGLProgram.h" 9 #include "gl/GrGLProgram.h"
10 #include "gl/GrGLSLPrettyPrint.h" 10 #include "gl/GrGLSLPrettyPrint.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 ////////////////////////////////////////////////////////////////////////////// 47 //////////////////////////////////////////////////////////////////////////////
48 48
49 const int GrGLProgramBuilder::kVarsPerBlock = 8; 49 const int GrGLProgramBuilder::kVarsPerBlock = 8;
50 50
51 GrGLProgram* GrGLProgramBuilder::CreateProgram(const GrOptDrawState& optState, G rGLGpu* gpu) { 51 GrGLProgram* GrGLProgramBuilder::CreateProgram(const GrOptDrawState& optState, G rGLGpu* gpu) {
52 // create a builder. This will be handed off to effects so they can use it to add 52 // create a builder. This will be handed off to effects so they can use it to add
53 // uniforms, varyings, textures, etc 53 // uniforms, varyings, textures, etc
54 SkAutoTDelete<GrGLProgramBuilder> builder(CreateProgramBuilder(optState, gpu )); 54 SkAutoTDelete<GrGLProgramBuilder> builder(CreateProgramBuilder(optState, gpu ));
55 55
56 GrGLProgramBuilder* pb = builder.get(); 56 GrGLProgramBuilder* pb = builder.get();
57 const GrGLProgramDescBuilder::GLKeyHeader& header =
58 GrGLProgramDescBuilder::GetHeader(pb->desc());
59 57
60 // emit code to read the dst copy texture, if necessary 58 // emit code to read the dst copy texture, if necessary
61 if (GrGLFragmentShaderBuilder::kNoDstRead_DstReadKey != header.fDstReadKey & & 59 if (GrGLFragmentShaderBuilder::kNoDstRead_DstReadKey != pb->header().fDstRea dKey &&
62 !gpu->glCaps().fbFetchSupport()) { 60 !gpu->glCaps().fbFetchSupport()) {
63 pb->fFS.emitCodeToReadDstTexture(); 61 pb->fFS.emitCodeToReadDstTexture();
64 } 62 }
65 63
66 // TODO: Once all stages can handle taking a float or vec4 and correctly han dling them we can 64 // TODO: Once all stages can handle taking a float or vec4 and correctly han dling them we can
67 // seed correctly here 65 // seed correctly here
68 GrGLSLExpr4 inputColor; 66 GrGLSLExpr4 inputColor;
69 GrGLSLExpr4 inputCoverage; 67 GrGLSLExpr4 inputCoverage;
70 68
71 pb->emitAndInstallProcs(&inputColor, &inputCoverage); 69 pb->emitAndInstallProcs(&inputColor, &inputCoverage);
72 70
73 return pb->finalize(); 71 return pb->finalize();
74 } 72 }
75 73
76 GrGLProgramBuilder* GrGLProgramBuilder::CreateProgramBuilder(const GrOptDrawStat e& optState, 74 GrGLProgramBuilder* GrGLProgramBuilder::CreateProgramBuilder(const GrOptDrawStat e& optState,
77 GrGLGpu* gpu) { 75 GrGLGpu* gpu) {
78 const GrProgramDesc& desc = optState.programDesc(); 76 if (GrGpu::IsPathRenderingDrawType(optState.drawType())) {
79 if (GrGLProgramDescBuilder::GetHeader(desc).fUseNvpr) { 77 SkASSERT(gpu->glCaps().pathRenderingSupport() &&
80 SkASSERT(gpu->glCaps().pathRenderingSupport()); 78 !optState.getPrimitiveProcessor()->willUseGeoShader() &&
81 SkASSERT(!optState.hasGeometryProcessor()); 79 optState.getPrimitiveProcessor()->numAttribs() == 0);
82 return SkNEW_ARGS(GrGLNvprProgramBuilder, (gpu, optState)); 80 return SkNEW_ARGS(GrGLNvprProgramBuilder, (gpu, optState));
83 } else { 81 } else {
84 return SkNEW_ARGS(GrGLProgramBuilder, (gpu, optState)); 82 return SkNEW_ARGS(GrGLProgramBuilder, (gpu, optState));
85 } 83 }
86 } 84 }
87 85
88 ///////////////////////////////////////////////////////////////////////////// 86 /////////////////////////////////////////////////////////////////////////////
89 87
90 GrGLProgramBuilder::GrGLProgramBuilder(GrGLGpu* gpu, const GrOptDrawState& optSt ate) 88 GrGLProgramBuilder::GrGLProgramBuilder(GrGLGpu* gpu, const GrOptDrawState& optSt ate)
91 : fVS(this) 89 : fVS(this)
92 , fGS(this) 90 , fGS(this)
93 , fFS(this, optState.programDesc().header().fFragPosKey) 91 , fFS(this, optState.programDesc().header().fFragPosKey)
94 , fOutOfStage(true) 92 , fOutOfStage(true)
95 , fStageIndex(-1) 93 , fStageIndex(-1)
96 , fGeometryProcessor(NULL) 94 , fGeometryProcessor(NULL)
97 , fXferProcessor(NULL) 95 , fXferProcessor(NULL)
98 , fOptState(optState) 96 , fOptState(optState)
99 , fDesc(optState.programDesc()) 97 , fDesc(optState.programDesc())
100 , fGpu(gpu) 98 , fGpu(gpu)
101 , fUniforms(kVarsPerBlock) { 99 , fUniforms(kVarsPerBlock) {
102 } 100 }
103 101
104 void GrGLProgramBuilder::addVarying(const char* name, 102 void GrGLProgramBuilder::addVarying(const char* name,
105 GrGLVarying* varying, 103 GrGLVarying* varying,
106 GrSLPrecision fsPrecision) { 104 GrSLPrecision fsPrecision) {
107 SkASSERT(varying); 105 SkASSERT(varying);
108 if (varying->vsVarying()) { 106 if (varying->vsVarying()) {
109 fVS.addVarying(name, varying); 107 fVS.addVarying(name, varying);
110 } 108 }
111 if (fOptState.hasGeometryProcessor() && fOptState.getGeometryProcessor()->wi llUseGeoShader()) { 109 if (fOptState.getPrimitiveProcessor()->willUseGeoShader()) {
112 fGS.addVarying(name, varying); 110 fGS.addVarying(name, varying);
113 } 111 }
114 if (varying->fsVarying()) { 112 if (varying->fsVarying()) {
115 fFS.addVarying(varying, fsPrecision); 113 fFS.addVarying(varying, fsPrecision);
116 } 114 }
117 } 115 }
118 116
119 void GrGLProgramBuilder::addPassThroughAttribute(const GrGeometryProcessor::GrAt tribute* input, 117 void GrGLProgramBuilder::addPassThroughAttribute(const GrPrimitiveProcessor::Att ribute* input,
120 const char* output) { 118 const char* output) {
121 GrSLType type = GrVertexAttribTypeToSLType(input->fType); 119 GrSLType type = GrVertexAttribTypeToSLType(input->fType);
122 GrGLVertToFrag v(type); 120 GrGLVertToFrag v(type);
123 this->addVarying(input->fName, &v); 121 this->addVarying(input->fName, &v);
124 fVS.codeAppendf("%s = %s;", v.vsOut(), input->fName); 122 fVS.codeAppendf("%s = %s;", v.vsOut(), input->fName);
125 fFS.codeAppendf("%s = %s;", output, v.fsIn()); 123 fFS.codeAppendf("%s = %s;", output, v.fsIn());
126 } 124 }
127 125
128 void GrGLProgramBuilder::nameVariable(SkString* out, char prefix, const char* na me) { 126 void GrGLProgramBuilder::nameVariable(SkString* out, char prefix, const char* na me) {
129 if ('\0' == prefix) { 127 if ('\0' == prefix) {
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 GrGLProgram* GrGLProgramBuilder::finalize() { 389 GrGLProgram* GrGLProgramBuilder::finalize() {
392 // verify we can get a program id 390 // verify we can get a program id
393 GrGLuint programID; 391 GrGLuint programID;
394 GL_CALL_RET(programID, CreateProgram()); 392 GL_CALL_RET(programID, CreateProgram());
395 if (0 == programID) { 393 if (0 == programID) {
396 return NULL; 394 return NULL;
397 } 395 }
398 396
399 // compile shaders and bind attributes / uniforms 397 // compile shaders and bind attributes / uniforms
400 SkTDArray<GrGLuint> shadersToDelete; 398 SkTDArray<GrGLuint> shadersToDelete;
401 if (!(GrGLProgramDescBuilder::GetHeader(fDesc).fUseNvpr && 399
402 fGpu->glPathRendering()->texturingMode() == 400 // Legacy nvpr will not compile with a vertex shader, but newer nvpr require s a dummy vertex
403 GrGLPathRendering::FixedFunction_TexturingMode)) { 401 // shader
402 bool useNvpr = GrGpu::IsPathRenderingDrawType(fOptState.drawType());
403 if (!(useNvpr && fGpu->glCaps().nvprSupport() == GrGLCaps::kLegacy_NvprSuppo rt)) {
404 if (!fVS.compileAndAttachShaders(programID, &shadersToDelete)) { 404 if (!fVS.compileAndAttachShaders(programID, &shadersToDelete)) {
405 this->cleanupProgram(programID, shadersToDelete); 405 this->cleanupProgram(programID, shadersToDelete);
406 return NULL; 406 return NULL;
407 } 407 }
408 408
409 // Non fixed function NVPR actually requires a vertex shader to compile 409 // Non fixed function NVPR actually requires a vertex shader to compile
410 if (fOptState.hasGeometryProcessor()) { 410 if (!useNvpr) {
411 fVS.bindVertexAttributes(programID); 411 fVS.bindVertexAttributes(programID);
412 } 412 }
413 } 413 }
414 414
415 if (!fFS.compileAndAttachShaders(programID, &shadersToDelete)) { 415 if (!fFS.compileAndAttachShaders(programID, &shadersToDelete)) {
416 this->cleanupProgram(programID, shadersToDelete); 416 this->cleanupProgram(programID, shadersToDelete);
417 return NULL; 417 return NULL;
418 } 418 }
419 419
420 bool usingBindUniform = fGpu->glInterface()->fFunctions.fBindUniformLocation != NULL; 420 bool usingBindUniform = fGpu->glInterface()->fFunctions.fBindUniformLocation != NULL;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 } 498 }
499 499
500 //////////////////////////////////////////////////////////////////////////////// /////////////////// 500 //////////////////////////////////////////////////////////////////////////////// ///////////////////
501 501
502 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { 502 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() {
503 int numProcs = fProcs.count(); 503 int numProcs = fProcs.count();
504 for (int e = 0; e < numProcs; ++e) { 504 for (int e = 0; e < numProcs; ++e) {
505 SkDELETE(fProcs[e]); 505 SkDELETE(fProcs[e]);
506 } 506 }
507 } 507 }
OLDNEW
« no previous file with comments | « src/gpu/gl/builders/GrGLProgramBuilder.h ('k') | src/gpu/gl/builders/GrGLVertexShaderBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698