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

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

Issue 766753006: clean up default precision handling (Closed) Base URL: https://skia.googlesource.com/skia.git@precision
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 | « src/gpu/gl/GrGLShaderVar.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 #include "GrGLFragmentShaderBuilder.h" 8 #include "GrGLFragmentShaderBuilder.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 #define GL_CALL(X) GR_GL_CALL(fProgramBuilder->gpu()->glInterface(), X) 13 #define GL_CALL(X) GR_GL_CALL(fProgramBuilder->gpu()->glInterface(), X)
14 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(fProgramBuilder->gpu()->glInterface(), R, X) 14 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(fProgramBuilder->gpu()->glInterface(), R, X)
15 15
16 // ES2 FS only guarantees mediump and lowp support
17 static const GrGLShaderVar::Precision kDefaultFragmentPrecision = GrGLShaderVar: :kMedium_Precision;
18 const char* GrGLFragmentShaderBuilder::kDstCopyColorName = "_dstColor"; 16 const char* GrGLFragmentShaderBuilder::kDstCopyColorName = "_dstColor";
19 static const char* declared_color_output_name() { return "fsColorOut"; } 17 static const char* declared_color_output_name() { return "fsColorOut"; }
20 static const char* dual_source_output_name() { return "dualSourceOut"; } 18 static const char* dual_source_output_name() { return "dualSourceOut"; }
21 static void append_default_precision_qualifier(GrGLShaderVar::Precision p, 19 static void append_default_precision_qualifier(GrGLShaderVar::Precision p,
22 GrGLStandard standard, 20 GrGLStandard standard,
23 SkString* str) { 21 SkString* str) {
24 // Desktop GLSL has added precision qualifiers but they don't do anything. 22 // Desktop GLSL has added precision qualifiers but they don't do anything.
25 if (kGLES_GrGLStandard == standard) { 23 if (kGLES_GrGLStandard == standard) {
26 switch (p) { 24 switch (p) {
27 case GrGLShaderVar::kHigh_Precision: 25 case GrGLShaderVar::kHigh_Precision:
28 str->append("precision highp float;\n"); 26 str->append("precision highp float;\n");
29 break; 27 break;
30 case GrGLShaderVar::kMedium_Precision: 28 case GrGLShaderVar::kMedium_Precision:
31 str->append("precision mediump float;\n"); 29 str->append("precision mediump float;\n");
32 break; 30 break;
33 case GrGLShaderVar::kLow_Precision: 31 case GrGLShaderVar::kLow_Precision:
34 str->append("precision lowp float;\n"); 32 str->append("precision lowp float;\n");
35 break; 33 break;
36 case GrGLShaderVar::kDefault_Precision:
37 SkFAIL("Default precision now allowed.");
38 default: 34 default:
39 SkFAIL("Unknown precision value."); 35 SkFAIL("Unknown precision value.");
40 } 36 }
41 } 37 }
42 } 38 }
43 39
44 GrGLFragmentShaderBuilder::DstReadKey 40 GrGLFragmentShaderBuilder::DstReadKey
45 GrGLFragmentShaderBuilder::KeyForDstRead(const GrTexture* dstCopy, const GrGLCap s& caps) { 41 GrGLFragmentShaderBuilder::KeyForDstRead(const GrTexture* dstCopy, const GrGLCap s& caps) {
46 uint32_t key = kYesDstRead_DstReadKeyBit; 42 uint32_t key = kYesDstRead_DstReadKeyBit;
47 if (caps.fbFetchSupport()) { 43 if (caps.fbFetchSupport()) {
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 } 299 }
304 300
305 this->codeAppendf("\t%s = %s;\n", this->getPrimaryColorOutputName(), fragCol or.c_str()); 301 this->codeAppendf("\t%s = %s;\n", this->getPrimaryColorOutputName(), fragCol or.c_str());
306 } 302 }
307 303
308 bool GrGLFragmentShaderBuilder::compileAndAttachShaders(GrGLuint programId, 304 bool GrGLFragmentShaderBuilder::compileAndAttachShaders(GrGLuint programId,
309 SkTDArray<GrGLuint>* sha derIds) const { 305 SkTDArray<GrGLuint>* sha derIds) const {
310 GrGpuGL* gpu = fProgramBuilder->gpu(); 306 GrGpuGL* gpu = fProgramBuilder->gpu();
311 SkString fragShaderSrc(GrGetGLSLVersionDecl(gpu->ctxInfo())); 307 SkString fragShaderSrc(GrGetGLSLVersionDecl(gpu->ctxInfo()));
312 fragShaderSrc.append(fExtensions); 308 fragShaderSrc.append(fExtensions);
313 append_default_precision_qualifier(kDefaultFragmentPrecision, 309 append_default_precision_qualifier(GrShaderVar::kDefault_Precision,
314 gpu->glStandard(), 310 gpu->glStandard(),
315 &fragShaderSrc); 311 &fragShaderSrc);
316 fProgramBuilder->appendUniformDecls(GrGLProgramBuilder::kFragment_Visibility , &fragShaderSrc); 312 fProgramBuilder->appendUniformDecls(GrGLProgramBuilder::kFragment_Visibility , &fragShaderSrc);
317 this->appendDecls(fInputs, &fragShaderSrc); 313 this->appendDecls(fInputs, &fragShaderSrc);
318 // We shouldn't have declared outputs on 1.10 314 // We shouldn't have declared outputs on 1.10
319 SkASSERT(k110_GrGLSLGeneration != gpu->glslGeneration() || fOutputs.empty()) ; 315 SkASSERT(k110_GrGLSLGeneration != gpu->glslGeneration() || fOutputs.empty()) ;
320 this->appendDecls(fOutputs, &fragShaderSrc); 316 this->appendDecls(fOutputs, &fragShaderSrc);
321 fragShaderSrc.append(fFunctions); 317 fragShaderSrc.append(fFunctions);
322 fragShaderSrc.append("void main() {\n"); 318 fragShaderSrc.append("void main() {\n");
323 fragShaderSrc.append(fCode); 319 fragShaderSrc.append(fCode);
(...skipping 22 matching lines...) Expand all
346 } 342 }
347 } 343 }
348 344
349 void GrGLFragmentShaderBuilder::addVarying(GrGLVarying* v, GrGLShaderVar::Precis ion fsPrec) { 345 void GrGLFragmentShaderBuilder::addVarying(GrGLVarying* v, GrGLShaderVar::Precis ion fsPrec) {
350 v->fFsIn = v->fVsOut; 346 v->fFsIn = v->fVsOut;
351 if (v->fGsOut) { 347 if (v->fGsOut) {
352 v->fFsIn = v->fGsOut; 348 v->fFsIn = v->fGsOut;
353 } 349 }
354 fInputs.push_back().set(v->fType, GrGLShaderVar::kVaryingIn_TypeModifier, v- >fFsIn, fsPrec); 350 fInputs.push_back().set(v->fType, GrGLShaderVar::kVaryingIn_TypeModifier, v- >fFsIn, fsPrec);
355 } 351 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLShaderVar.h ('k') | src/gpu/gl/builders/GrGLProgramBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698