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

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

Issue 678953002: Default geometry processor (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix Created 6 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 unified diff | Download patch
« no previous file with comments | « src/gpu/gl/GrGLSL.h ('k') | src/gpu/gl/builders/GrGLProgramBuilder.cpp » ('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 #ifndef GrGLProgramBuilder_DEFINED 8 #ifndef GrGLProgramBuilder_DEFINED
9 #define GrGLProgramBuilder_DEFINED 9 #define GrGLProgramBuilder_DEFINED
10 10
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 234
235 const GrOptDrawState& optState() const { return fOptState; } 235 const GrOptDrawState& optState() const { return fOptState; }
236 const GrProgramDesc& desc() const { return fDesc; } 236 const GrProgramDesc& desc() const { return fDesc; }
237 const GrProgramDesc::KeyHeader& header() const { return fDesc.header(); } 237 const GrProgramDesc::KeyHeader& header() const { return fDesc.header(); }
238 238
239 // Generates a name for a variable. The generated string will be name prefix ed by the prefix 239 // Generates a name for a variable. The generated string will be name prefix ed by the prefix
240 // char (unless the prefix is '\0'). It also mangles the name to be stage-sp ecific if we're 240 // char (unless the prefix is '\0'). It also mangles the name to be stage-sp ecific if we're
241 // generating stage code. 241 // generating stage code.
242 void nameVariable(SkString* out, char prefix, const char* name); 242 void nameVariable(SkString* out, char prefix, const char* name);
243 void setupUniformColorAndCoverageIfNeeded(GrGLSLExpr4* inputColor, GrGLSLExp r1* inputCoverage); 243 void setupUniformColorAndCoverageIfNeeded(GrGLSLExpr4* inputColor, GrGLSLExp r1* inputCoverage);
244 void emitAndInstallProcs(const GrOptDrawState& optState, 244 void emitAndInstallProcs(GrGLSLExpr4* inputColor,
245 GrGLSLExpr4* inputColor,
246 GrGLSLExpr4* inputCoverage); 245 GrGLSLExpr4* inputCoverage);
247 void emitAndInstallFragProcs(int procOffset, int numProcs, GrGLSLExpr4* inOu t); 246 void emitAndInstallFragProcs(int procOffset, int numProcs, GrGLSLExpr4* inOu t);
248 template <class Proc> 247 template <class Proc>
249 void emitAndInstallProc(const Proc&, 248 void emitAndInstallProc(const Proc&,
250 int index, 249 int index,
251 const ProcKeyProvider&, 250 const ProcKeyProvider&,
252 const GrGLSLExpr4& input, 251 const GrGLSLExpr4& input,
253 GrGLSLExpr4* output); 252 GrGLSLExpr4* output);
254 253
255 // these emit functions help to keep the createAndEmitProcessors template ge neral 254 // these emit functions help to keep the createAndEmitProcessors template ge neral
256 void emitAndInstallProc(const GrFragmentStage&, 255 void emitAndInstallProc(const GrFragmentStage&,
257 const GrProcessorKey&, 256 const GrProcessorKey&,
258 const char* outColor, 257 const char* outColor,
259 const char* inColor); 258 const char* inColor);
260 void emitAndInstallProc(const GrGeometryProcessor&, 259 void emitAndInstallProc(const GrGeometryProcessor&,
261 const GrProcessorKey&, 260 const GrProcessorKey&,
262 const char* outColor, 261 const char* outCoverage,
263 const char* inColor); 262 const char* inCoverage);
264 void verify(const GrGeometryProcessor&); 263 void verify(const GrGeometryProcessor&);
265 void verify(const GrFragmentProcessor&); 264 void verify(const GrFragmentProcessor&);
266 void emitSamplers(const GrProcessor&, 265 void emitSamplers(const GrProcessor&,
267 GrGLProcessor::TextureSamplerArray* outSamplers, 266 GrGLProcessor::TextureSamplerArray* outSamplers,
268 GrGLInstalledProc*); 267 GrGLInstalledProc*);
269 268
270 // each specific program builder has a distinct transform and must override this function 269 // each specific program builder has a distinct transform and must override this function
271 virtual void emitTransforms(const GrFragmentStage&, 270 virtual void emitTransforms(const GrFragmentStage&,
272 GrGLProcessor::TransformedCoordsArray* outCoords , 271 GrGLProcessor::TransformedCoordsArray* outCoords ,
273 GrGLInstalledFragProc*); 272 GrGLInstalledFragProc*);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 public: 306 public:
308 AutoStageAdvance(GrGLProgramBuilder* pb) : fPB(pb) { fPB->reset(); } 307 AutoStageAdvance(GrGLProgramBuilder* pb) : fPB(pb) { fPB->reset(); }
309 ~AutoStageAdvance() { fPB->exitStage(); } 308 ~AutoStageAdvance() { fPB->exitStage(); }
310 private: 309 private:
311 GrGLProgramBuilder* fPB; 310 GrGLProgramBuilder* fPB;
312 }; 311 };
313 void exitStage() { fOutOfStage = true; } 312 void exitStage() { fOutOfStage = true; }
314 void enterStage() { fOutOfStage = false; } 313 void enterStage() { fOutOfStage = false; }
315 int stageIndex() const { return fStageIndex; } 314 int stageIndex() const { return fStageIndex; }
316 315
316 struct TransformVarying {
317 TransformVarying(const GrGLVarying& v, const char* uniName, const char* sourceCoords)
318 : fV(v), fUniName(uniName), fSourceCoords(sourceCoords) {}
319 GrGLVarying fV;
320 SkString fUniName;
321 SkString fSourceCoords;
322 };
323
324 void addCoordVarying(const char* name, GrGLVarying* v, const char* uniName,
325 const char* sourceCoords) {
326 this->addVarying(name, v);
327 fCoordVaryings.push_back(TransformVarying(*v, uniName, sourceCoords));
328 }
329
330 const char* rtAdjustment() const { return "rtAdjustment"; }
331
317 // number of each input/output type in a single allocation block, used by ma ny builders 332 // number of each input/output type in a single allocation block, used by ma ny builders
318 static const int kVarsPerBlock; 333 static const int kVarsPerBlock;
319 334
320 BuiltinUniformHandles fUniformHandles; 335 BuiltinUniformHandles fUniformHandles;
321 GrGLVertexBuilder fVS; 336 GrGLVertexBuilder fVS;
322 GrGLGeometryBuilder fGS; 337 GrGLGeometryBuilder fGS;
323 GrGLFragmentShaderBuilder fFS; 338 GrGLFragmentShaderBuilder fFS;
324 bool fOutOfStage; 339 bool fOutOfStage;
325 int fStageIndex; 340 int fStageIndex;
326 341
327 GrGLInstalledGeoProc* fGeometryProcessor; 342 GrGLInstalledGeoProc* fGeometryProcessor;
328 SkAutoTUnref<GrGLInstalledFragProcs> fFragmentProcessors; 343 SkAutoTUnref<GrGLInstalledFragProcs> fFragmentProcessors;
329 344
330 const GrOptDrawState& fOptState; 345 const GrOptDrawState& fOptState;
331 const GrProgramDesc& fDesc; 346 const GrProgramDesc& fDesc;
332 GrGpuGL* fGpu; 347 GrGpuGL* fGpu;
333 UniformInfoArray fUniforms; 348 UniformInfoArray fUniforms;
349 SkSTArray<16, TransformVarying, true> fCoordVaryings;
334 350
335 friend class GrGLShaderBuilder; 351 friend class GrGLShaderBuilder;
336 friend class GrGLVertexBuilder; 352 friend class GrGLVertexBuilder;
337 friend class GrGLFragmentShaderBuilder; 353 friend class GrGLFragmentShaderBuilder;
338 friend class GrGLGeometryBuilder; 354 friend class GrGLGeometryBuilder;
339 }; 355 };
340 356
341 /** 357 /**
342 * The below structs represent processors installed in programs. All processors can have texture 358 * The below structs represent processors installed in programs. All processors can have texture
343 * samplers, but only frag processors have coord transforms, hence the need for different structs 359 * samplers, but only frag processors have coord transforms, hence the need for different structs
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 SkSTArray<2, Transform, true> fTransforms; 401 SkSTArray<2, Transform, true> fTransforms;
386 bool fLocalCoordAttrib; 402 bool fLocalCoordAttrib;
387 }; 403 };
388 404
389 struct GrGLInstalledFragProcs : public SkRefCnt { 405 struct GrGLInstalledFragProcs : public SkRefCnt {
390 virtual ~GrGLInstalledFragProcs(); 406 virtual ~GrGLInstalledFragProcs();
391 SkSTArray<8, GrGLInstalledFragProc*, true> fProcs; 407 SkSTArray<8, GrGLInstalledFragProc*, true> fProcs;
392 }; 408 };
393 409
394 #endif 410 #endif
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLSL.h ('k') | src/gpu/gl/builders/GrGLProgramBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698