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

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

Issue 784103003: Use GrCoordTransform precision to set uniform matrix precision (Closed) Base URL: https://skia.googlesource.com/skia.git@uni_prec
Patch Set: Created 6 years 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 | « no previous file | no next file » | 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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 GrGLProcessor::TransformedCoordsArray* o utCoords, 377 GrGLProcessor::TransformedCoordsArray* o utCoords,
378 GrGLInstalledFragProc* ifp) { 378 GrGLInstalledFragProc* ifp) {
379 const GrFragmentProcessor* processor = stage.getProcessor(); 379 const GrFragmentProcessor* processor = stage.getProcessor();
380 int numTransforms = processor->numTransforms(); 380 int numTransforms = processor->numTransforms();
381 ifp->fTransforms.push_back_n(numTransforms); 381 ifp->fTransforms.push_back_n(numTransforms);
382 382
383 for (int t = 0; t < numTransforms; t++) { 383 for (int t = 0; t < numTransforms; t++) {
384 const char* uniName = "StageMatrix"; 384 const char* uniName = "StageMatrix";
385 GrSLType varyingType = stage.isPerspectiveCoordTransform(t) ? kVec3f_GrS LType : 385 GrSLType varyingType = stage.isPerspectiveCoordTransform(t) ? kVec3f_GrS LType :
386 kVec2f_GrS LType; 386 kVec2f_GrS LType;
387 GrSLPrecision precision = processor->coordTransform(t).precision();
388
387 SkString suffixedUniName; 389 SkString suffixedUniName;
388 if (0 != t) { 390 if (0 != t) {
389 suffixedUniName.append(uniName); 391 suffixedUniName.append(uniName);
390 suffixedUniName.appendf("_%i", t); 392 suffixedUniName.appendf("_%i", t);
391 uniName = suffixedUniName.c_str(); 393 uniName = suffixedUniName.c_str();
392 } 394 }
393 ifp->fTransforms[t].fHandle = this->addUniform(GrGLProgramBuilder::kVert ex_Visibility, 395 ifp->fTransforms[t].fHandle = this->addUniform(GrGLProgramBuilder::kVert ex_Visibility,
394 kMat33f_GrSLType, kDefaul t_GrSLPrecision, 396 kMat33f_GrSLType, precisi on,
395 uniName, 397 uniName,
396 &uniName).toShaderBuilder Index(); 398 &uniName).toShaderBuilder Index();
397 399
398 const char* varyingName = "MatrixCoord"; 400 const char* varyingName = "MatrixCoord";
399 SkString suffixedVaryingName; 401 SkString suffixedVaryingName;
400 if (0 != t) { 402 if (0 != t) {
401 suffixedVaryingName.append(varyingName); 403 suffixedVaryingName.append(varyingName);
402 suffixedVaryingName.appendf("_%i", t); 404 suffixedVaryingName.appendf("_%i", t);
403 varyingName = suffixedVaryingName.c_str(); 405 varyingName = suffixedVaryingName.c_str();
404 } 406 }
405 407
406 bool useLocalCoords = kLocal_GrCoordSet == processor->coordTransform(t). sourceCoords(); 408 bool useLocalCoords = kLocal_GrCoordSet == processor->coordTransform(t). sourceCoords();
407 const char* coords = useLocalCoords ? fVS.localCoords() : fVS.positionCo ords(); 409 const char* coords = useLocalCoords ? fVS.localCoords() : fVS.positionCo ords();
408 410
409 GrGLVertToFrag v(varyingType); 411 GrGLVertToFrag v(varyingType);
410 this->addVarying(varyingName, &v, processor->coordTransform(t).precision ()); 412 this->addVarying(varyingName, &v, precision);
411 fCoordVaryings.push_back(TransformVarying(v, uniName, coords)); 413 fCoordVaryings.push_back(TransformVarying(v, uniName, coords));
412 414
413 SkASSERT(kVec2f_GrSLType == varyingType || kVec3f_GrSLType == varyingTyp e); 415 SkASSERT(kVec2f_GrSLType == varyingType || kVec3f_GrSLType == varyingTyp e);
414 SkNEW_APPEND_TO_TARRAY(outCoords, GrGLProcessor::TransformedCoords, 416 SkNEW_APPEND_TO_TARRAY(outCoords, GrGLProcessor::TransformedCoords,
415 (SkString(v.fsIn()), varyingType)); 417 (SkString(v.fsIn()), varyingType));
416 } 418 }
417 } 419 }
418 420
419 void GrGLProgramBuilder::emitSamplers(const GrProcessor& processor, 421 void GrGLProgramBuilder::emitSamplers(const GrProcessor& processor,
420 GrGLProcessor::TextureSamplerArray* outSam plers, 422 GrGLProcessor::TextureSamplerArray* outSam plers,
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 } 543 }
542 544
543 //////////////////////////////////////////////////////////////////////////////// /////////////////// 545 //////////////////////////////////////////////////////////////////////////////// ///////////////////
544 546
545 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { 547 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() {
546 int numProcs = fProcs.count(); 548 int numProcs = fProcs.count();
547 for (int e = 0; e < numProcs; ++e) { 549 for (int e = 0; e < numProcs; ++e) {
548 SkDELETE(fProcs[e]); 550 SkDELETE(fProcs[e]);
549 } 551 }
550 } 552 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698