| 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 "GrGLGeometryShaderBuilder.h" | 8 #include "GrGLGeometryShaderBuilder.h" |
| 9 #include "GrGLShaderStringBuilder.h" | 9 #include "GrGLShaderStringBuilder.h" |
| 10 #include "GrGLProgramBuilder.h" | 10 #include "GrGLProgramBuilder.h" |
| 11 #include "../GrGpuGL.h" | 11 #include "../GrGpuGL.h" |
| 12 | 12 |
| 13 GrGLGeometryBuilder::GrGLGeometryBuilder(GrGLProgramBuilder* program) | 13 GrGLGeometryBuilder::GrGLGeometryBuilder(GrGLProgramBuilder* program) |
| 14 : INHERITED(program) { | 14 : INHERITED(program) { |
| 15 | 15 |
| 16 } | 16 } |
| 17 | 17 |
| 18 void GrGLGeometryBuilder::addVarying(GrSLType type, | 18 void GrGLGeometryBuilder::addVarying(const char* name, GrGLVarying* v) { |
| 19 const char* name, | |
| 20 const char** gsOutName) { | |
| 21 // if we have a GS take each varying in as an array | 19 // if we have a GS take each varying in as an array |
| 22 // and output as non-array. | 20 // and output as non-array. |
| 23 fInputs.push_back(); | 21 if (v->vsVarying()) { |
| 24 fInputs.back().setType(type); | 22 fInputs.push_back(); |
| 25 fInputs.back().setTypeModifier(GrGLShaderVar::kVaryingIn_TypeModifier); | 23 fInputs.back().setType(v->fType); |
| 26 fInputs.back().setUnsizedArray(); | 24 fInputs.back().setTypeModifier(GrGLShaderVar::kVaryingIn_TypeModifier); |
| 27 *fInputs.back().accessName() = name; | 25 fInputs.back().setUnsizedArray(); |
| 28 fOutputs.push_back(); | 26 *fInputs.back().accessName() = v->fVsOut; |
| 29 fOutputs.back().setType(type); | 27 v->fGsIn = v->fVsOut; |
| 30 fOutputs.back().setTypeModifier(GrGLShaderVar::kVaryingOut_TypeModifier); | 28 } |
| 31 fProgramBuilder->nameVariable(fOutputs.back().accessName(), 'g', name); | 29 |
| 32 if (gsOutName) { | 30 if (v->fsVarying()) { |
| 33 *gsOutName = fOutputs.back().getName().c_str(); | 31 fOutputs.push_back(); |
| 32 fOutputs.back().setType(v->fType); |
| 33 fOutputs.back().setTypeModifier(GrGLShaderVar::kVaryingOut_TypeModifier)
; |
| 34 fProgramBuilder->nameVariable(fOutputs.back().accessName(), 'g', name); |
| 35 v->fGsOut = fOutputs.back().getName().c_str(); |
| 34 } | 36 } |
| 35 } | 37 } |
| 36 | 38 |
| 37 | |
| 38 bool GrGLGeometryBuilder::compileAndAttachShaders(GrGLuint programId, | 39 bool GrGLGeometryBuilder::compileAndAttachShaders(GrGLuint programId, |
| 39 SkTDArray<GrGLuint>* shaderIds) const { | 40 SkTDArray<GrGLuint>* shaderIds) const { |
| 40 const GrGLContext& glCtx = fProgramBuilder->gpu()->glContext(); | 41 const GrGLContext& glCtx = fProgramBuilder->gpu()->glContext(); |
| 41 SkASSERT(fProgramBuilder->ctxInfo().glslGeneration() >= k150_GrGLSLGeneratio
n); | 42 SkASSERT(fProgramBuilder->ctxInfo().glslGeneration() >= k150_GrGLSLGeneratio
n); |
| 42 SkString geomShaderSrc(GrGetGLSLVersionDecl(fProgramBuilder->ctxInfo())); | 43 SkString geomShaderSrc(GrGetGLSLVersionDecl(fProgramBuilder->ctxInfo())); |
| 43 geomShaderSrc.append("layout(triangles) in;\n" | 44 geomShaderSrc.append("layout(triangles) in;\n" |
| 44 "layout(triangle_strip, max_vertices = 6) out;\n"); | 45 "layout(triangle_strip, max_vertices = 6) out;\n"); |
| 45 this->appendDecls(fInputs, &geomShaderSrc); | 46 this->appendDecls(fInputs, &geomShaderSrc); |
| 46 this->appendDecls(fOutputs, &geomShaderSrc); | 47 this->appendDecls(fOutputs, &geomShaderSrc); |
| 47 geomShaderSrc.append("void main() {\n"); | 48 geomShaderSrc.append("void main() {\n"); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 63 GrGLuint geomShaderId = | 64 GrGLuint geomShaderId = |
| 64 GrGLCompileAndAttachShader(glCtx, programId, | 65 GrGLCompileAndAttachShader(glCtx, programId, |
| 65 GR_GL_GEOMETRY_SHADER, geomShaderSrc, | 66 GR_GL_GEOMETRY_SHADER, geomShaderSrc, |
| 66 fProgramBuilder->gpu()->gpuStats()); | 67 fProgramBuilder->gpu()->gpuStats()); |
| 67 if (!geomShaderId) { | 68 if (!geomShaderId) { |
| 68 return false; | 69 return false; |
| 69 } | 70 } |
| 70 *shaderIds->append() = geomShaderId; | 71 *shaderIds->append() = geomShaderId; |
| 71 return true; | 72 return true; |
| 72 } | 73 } |
| OLD | NEW |