| OLD | NEW |
| 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" |
| 11 #include "gl/GrGLUniformHandle.h" | 11 #include "gl/GrGLUniformHandle.h" |
| 12 #include "../GrGLXferProcessor.h" | 12 #include "../GrGLXferProcessor.h" |
| 13 #include "../GrGpuGL.h" | 13 #include "../GrGpuGL.h" |
| 14 #include "GrCoordTransform.h" | 14 #include "GrCoordTransform.h" |
| 15 #include "GrGLLegacyNvprProgramBuilder.h" | 15 #include "GrGLLegacyNvprProgramBuilder.h" |
| 16 #include "GrGLNvprProgramBuilder.h" | 16 #include "GrGLNvprProgramBuilder.h" |
| 17 #include "GrGLProgramBuilder.h" | 17 #include "GrGLProgramBuilder.h" |
| 18 #include "GrTexture.h" | 18 #include "GrTexture.h" |
| 19 #include "SkRTConf.h" | 19 #include "SkRTConf.h" |
| 20 #include "SkTraceEvent.h" | 20 #include "SkTraceEvent.h" |
| 21 | 21 |
| 22 #define GL_CALL(X) GR_GL_CALL(this->gpu()->glInterface(), X) | 22 #define GL_CALL(X) GR_GL_CALL(this->gpu()->glInterface(), X) |
| 23 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(this->gpu()->glInterface(), R, X) | 23 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(this->gpu()->glInterface(), R, X) |
| 24 | 24 |
| 25 ////////////////////////////////////////////////////////////////////////////// | 25 ////////////////////////////////////////////////////////////////////////////// |
| 26 | 26 |
| 27 const int GrGLProgramBuilder::kVarsPerBlock = 8; | 27 const int GrGLProgramBuilder::kVarsPerBlock = 8; |
| 28 | 28 |
| 29 GrGLProgram* GrGLProgramBuilder::CreateProgram(const GrOptDrawState& optState, G
rGpuGL* gpu) { | 29 GrGLProgram* GrGLProgramBuilder::CreateProgram(const GrOptDrawState& optState, G
rGLGpu* gpu) { |
| 30 // create a builder. This will be handed off to effects so they can use it
to add | 30 // create a builder. This will be handed off to effects so they can use it
to add |
| 31 // uniforms, varyings, textures, etc | 31 // uniforms, varyings, textures, etc |
| 32 SkAutoTDelete<GrGLProgramBuilder> builder(CreateProgramBuilder(optState, | 32 SkAutoTDelete<GrGLProgramBuilder> builder(CreateProgramBuilder(optState, |
| 33 optState.hasG
eometryProcessor(), | 33 optState.hasG
eometryProcessor(), |
| 34 gpu)); | 34 gpu)); |
| 35 | 35 |
| 36 GrGLProgramBuilder* pb = builder.get(); | 36 GrGLProgramBuilder* pb = builder.get(); |
| 37 const GrGLProgramDescBuilder::GLKeyHeader& header = GrGLProgramDescBuilder::
GetHeader(pb->desc()); | 37 const GrGLProgramDescBuilder::GLKeyHeader& header = GrGLProgramDescBuilder::
GetHeader(pb->desc()); |
| 38 | 38 |
| 39 // emit code to read the dst copy texture, if necessary | 39 // emit code to read the dst copy texture, if necessary |
| 40 if (GrGLFragmentShaderBuilder::kNoDstRead_DstReadKey != header.fDstReadKey &
& | 40 if (GrGLFragmentShaderBuilder::kNoDstRead_DstReadKey != header.fDstReadKey &
& |
| 41 !gpu->glCaps().fbFetchSupport()) { | 41 !gpu->glCaps().fbFetchSupport()) { |
| 42 pb->fFS.emitCodeToReadDstTexture(); | 42 pb->fFS.emitCodeToReadDstTexture(); |
| 43 } | 43 } |
| 44 | 44 |
| 45 // TODO: Once all stages can handle taking a float or vec4 and correctly han
dling them we can | 45 // TODO: Once all stages can handle taking a float or vec4 and correctly han
dling them we can |
| 46 // seed correctly here | 46 // seed correctly here |
| 47 GrGLSLExpr4 inputColor; | 47 GrGLSLExpr4 inputColor; |
| 48 GrGLSLExpr4 inputCoverage; | 48 GrGLSLExpr4 inputCoverage; |
| 49 | 49 |
| 50 pb->emitAndInstallProcs(&inputColor, &inputCoverage); | 50 pb->emitAndInstallProcs(&inputColor, &inputCoverage); |
| 51 | 51 |
| 52 return pb->finalize(); | 52 return pb->finalize(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 GrGLProgramBuilder* GrGLProgramBuilder::CreateProgramBuilder(const GrOptDrawStat
e& optState, | 55 GrGLProgramBuilder* GrGLProgramBuilder::CreateProgramBuilder(const GrOptDrawStat
e& optState, |
| 56 bool hasGeometryPro
cessor, | 56 bool hasGeometryPro
cessor, |
| 57 GrGpuGL* gpu) { | 57 GrGLGpu* gpu) { |
| 58 const GrProgramDesc& desc = optState.programDesc(); | 58 const GrProgramDesc& desc = optState.programDesc(); |
| 59 if (GrGLProgramDescBuilder::GetHeader(desc).fUseNvpr) { | 59 if (GrGLProgramDescBuilder::GetHeader(desc).fUseNvpr) { |
| 60 SkASSERT(gpu->glCaps().pathRenderingSupport()); | 60 SkASSERT(gpu->glCaps().pathRenderingSupport()); |
| 61 SkASSERT(!hasGeometryProcessor); | 61 SkASSERT(!hasGeometryProcessor); |
| 62 if (gpu->glPathRendering()->texturingMode() == | 62 if (gpu->glPathRendering()->texturingMode() == |
| 63 GrGLPathRendering::FixedFunction_TexturingMode) { | 63 GrGLPathRendering::FixedFunction_TexturingMode) { |
| 64 return SkNEW_ARGS(GrGLLegacyNvprProgramBuilder, (gpu, optState)); | 64 return SkNEW_ARGS(GrGLLegacyNvprProgramBuilder, (gpu, optState)); |
| 65 } else { | 65 } else { |
| 66 return SkNEW_ARGS(GrGLNvprProgramBuilder, (gpu, optState)); | 66 return SkNEW_ARGS(GrGLNvprProgramBuilder, (gpu, optState)); |
| 67 } | 67 } |
| 68 } else { | 68 } else { |
| 69 return SkNEW_ARGS(GrGLProgramBuilder, (gpu, optState)); | 69 return SkNEW_ARGS(GrGLProgramBuilder, (gpu, optState)); |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 ///////////////////////////////////////////////////////////////////////////// | 73 ///////////////////////////////////////////////////////////////////////////// |
| 74 | 74 |
| 75 GrGLProgramBuilder::GrGLProgramBuilder(GrGpuGL* gpu, const GrOptDrawState& optSt
ate) | 75 GrGLProgramBuilder::GrGLProgramBuilder(GrGLGpu* gpu, const GrOptDrawState& optSt
ate) |
| 76 : fVS(this) | 76 : fVS(this) |
| 77 , fGS(this) | 77 , fGS(this) |
| 78 , fFS(this, optState.programDesc().header().fFragPosKey) | 78 , fFS(this, optState.programDesc().header().fFragPosKey) |
| 79 , fOutOfStage(true) | 79 , fOutOfStage(true) |
| 80 , fStageIndex(-1) | 80 , fStageIndex(-1) |
| 81 , fGeometryProcessor(NULL) | 81 , fGeometryProcessor(NULL) |
| 82 , fXferProcessor(NULL) | 82 , fXferProcessor(NULL) |
| 83 , fOptState(optState) | 83 , fOptState(optState) |
| 84 , fDesc(optState.programDesc()) | 84 , fDesc(optState.programDesc()) |
| 85 , fGpu(gpu) | 85 , fGpu(gpu) |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 } | 540 } |
| 541 | 541 |
| 542 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 542 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 543 | 543 |
| 544 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { | 544 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { |
| 545 int numProcs = fProcs.count(); | 545 int numProcs = fProcs.count(); |
| 546 for (int e = 0; e < numProcs; ++e) { | 546 for (int e = 0; e < numProcs; ++e) { |
| 547 SkDELETE(fProcs[e]); | 547 SkDELETE(fProcs[e]); |
| 548 } | 548 } |
| 549 } | 549 } |
| OLD | NEW |