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

Side by Side Diff: src/gpu/gl/GrGLProgramDesc.cpp

Issue 777443003: Move shader precision out of GrShaderVar (Closed) Base URL: https://skia.googlesource.com/skia.git@prec
Patch Set: rebase 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 | « src/gpu/gl/GrGLCaps.cpp ('k') | src/gpu/gl/GrGLShaderVar.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 2013 Google Inc. 2 * Copyright 2013 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 #include "GrGLProgramDesc.h" 7 #include "GrGLProgramDesc.h"
8 8
9 #include "GrGLProcessor.h" 9 #include "GrGLProcessor.h"
10 #include "GrProcessor.h" 10 #include "GrProcessor.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 kMatrixTypeKeyMask = (1 << kMatrixTypeKeyBits) - 1, 62 kMatrixTypeKeyMask = (1 << kMatrixTypeKeyBits) - 1,
63 63
64 kPrecisionBits = 2, 64 kPrecisionBits = 2,
65 kPrecisionShift = kMatrixTypeKeyBits, 65 kPrecisionShift = kMatrixTypeKeyBits,
66 66
67 kPositionCoords_Flag = (1 << (kPrecisionShift + kPrecisionBits)), 67 kPositionCoords_Flag = (1 << (kPrecisionShift + kPrecisionBits)),
68 68
69 kTransformKeyBits = kMatrixTypeKeyBits + kPrecisionBits + 1, 69 kTransformKeyBits = kMatrixTypeKeyBits + kPrecisionBits + 1,
70 }; 70 };
71 71
72 GR_STATIC_ASSERT(GrShaderVar::kHigh_Precision < (1 << kPrecisionBits)); 72 GR_STATIC_ASSERT(kHigh_GrSLPrecision < (1 << kPrecisionBits));
73 73
74 /** 74 /**
75 * We specialize the vertex code for each of these matrix types. 75 * We specialize the vertex code for each of these matrix types.
76 */ 76 */
77 enum MatrixType { 77 enum MatrixType {
78 kNoPersp_MatrixType = 0, 78 kNoPersp_MatrixType = 0,
79 kGeneral_MatrixType = 1, 79 kGeneral_MatrixType = 1,
80 }; 80 };
81 81
82 static uint32_t gen_transform_key(const GrPendingFragmentStage& stage, bool useE xplicitLocalCoords) { 82 static uint32_t gen_transform_key(const GrPendingFragmentStage& stage, bool useE xplicitLocalCoords) {
83 uint32_t totalKey = 0; 83 uint32_t totalKey = 0;
84 int numTransforms = stage.getProcessor()->numTransforms(); 84 int numTransforms = stage.getProcessor()->numTransforms();
85 for (int t = 0; t < numTransforms; ++t) { 85 for (int t = 0; t < numTransforms; ++t) {
86 uint32_t key = 0; 86 uint32_t key = 0;
87 if (stage.isPerspectiveCoordTransform(t)) { 87 if (stage.isPerspectiveCoordTransform(t)) {
88 key |= kGeneral_MatrixType; 88 key |= kGeneral_MatrixType;
89 } else { 89 } else {
90 key |= kNoPersp_MatrixType; 90 key |= kNoPersp_MatrixType;
91 } 91 }
92 92
93 const GrCoordTransform& coordTransform = stage.getProcessor()->coordTran sform(t); 93 const GrCoordTransform& coordTransform = stage.getProcessor()->coordTran sform(t);
94 if (kLocal_GrCoordSet != coordTransform.sourceCoords() && useExplicitLoc alCoords) { 94 if (kLocal_GrCoordSet != coordTransform.sourceCoords() && useExplicitLoc alCoords) {
95 key |= kPositionCoords_Flag; 95 key |= kPositionCoords_Flag;
96 } 96 }
97 97
98 GR_STATIC_ASSERT(GrShaderVar::kPrecisionCount <= (1 << kPrecisionBits)); 98 GR_STATIC_ASSERT(kGrSLPrecisionCount <= (1 << kPrecisionBits));
99 key |= (coordTransform.precision() << kPrecisionShift); 99 key |= (coordTransform.precision() << kPrecisionShift);
100 100
101 key <<= kTransformKeyBits * t; 101 key <<= kTransformKeyBits * t;
102 102
103 SkASSERT(0 == (totalKey & key)); // keys for each transform ought not to overlap 103 SkASSERT(0 == (totalKey & key)); // keys for each transform ought not to overlap
104 totalKey |= key; 104 totalKey |= key;
105 } 105 }
106 return totalKey; 106 return totalKey;
107 } 107 }
108 108
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 } 261 }
262 262
263 header->fPrimaryOutputType = descInfo.fPrimaryOutputType; 263 header->fPrimaryOutputType = descInfo.fPrimaryOutputType;
264 header->fSecondaryOutputType = descInfo.fSecondaryOutputType; 264 header->fSecondaryOutputType = descInfo.fSecondaryOutputType;
265 265
266 header->fColorEffectCnt = optState.numColorStages(); 266 header->fColorEffectCnt = optState.numColorStages();
267 header->fCoverageEffectCnt = optState.numCoverageStages(); 267 header->fCoverageEffectCnt = optState.numCoverageStages();
268 desc->finalize(); 268 desc->finalize();
269 return true; 269 return true;
270 } 270 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLCaps.cpp ('k') | src/gpu/gl/GrGLShaderVar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698