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

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

Issue 1684063006: Add GrShaderFlags enum (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Bit->Flag Created 4 years, 10 months 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/GrGLUniformHandler.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 2015 Google Inc. 2 * Copyright 2015 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 "gl/GrGLUniformHandler.h" 8 #include "gl/GrGLUniformHandler.h"
9 9
10 #include "gl/GrGLCaps.h" 10 #include "gl/GrGLCaps.h"
11 #include "gl/GrGLGpu.h" 11 #include "gl/GrGLGpu.h"
12 #include "gl/builders/GrGLProgramBuilder.h" 12 #include "gl/builders/GrGLProgramBuilder.h"
13 13
14 #define GL_CALL(X) GR_GL_CALL(this->glGpu()->glInterface(), X) 14 #define GL_CALL(X) GR_GL_CALL(this->glGpu()->glInterface(), X)
15 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(this->glGpu()->glInterface(), R, X) 15 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(this->glGpu()->glInterface(), R, X)
16 16
17 GrGLSLUniformHandler::UniformHandle GrGLUniformHandler::internalAddUniformArray( 17 GrGLSLUniformHandler::UniformHandle GrGLUniformHandler::internalAddUniformArray(
18 uint 32_t visibility, 18 uint 32_t visibility,
19 GrSL Type type, 19 GrSL Type type,
20 GrSL Precision precision, 20 GrSL Precision precision,
21 cons t char* name, 21 cons t char* name,
22 bool mangleName, 22 bool mangleName,
23 int arrayCount, 23 int arrayCount,
24 cons t char** outName) { 24 cons t char** outName) {
25 SkASSERT(name && strlen(name)); 25 SkASSERT(name && strlen(name));
26 SkDEBUGCODE(static const uint32_t kVisibilityMask = kVertex_Visibility | kFr agment_Visibility); 26 SkDEBUGCODE(static const uint32_t kVisMask = kVertex_GrShaderFlag | kFragmen t_GrShaderFlag);
27 SkASSERT(0 == (~kVisibilityMask & visibility)); 27 SkASSERT(0 == (~kVisMask & visibility));
28 SkASSERT(0 != visibility); 28 SkASSERT(0 != visibility);
29 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(type)); 29 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(type));
30 30
31 UniformInfo& uni = fUniforms.push_back(); 31 UniformInfo& uni = fUniforms.push_back();
32 uni.fVariable.setType(type); 32 uni.fVariable.setType(type);
33 uni.fVariable.setTypeModifier(GrGLSLShaderVar::kUniform_TypeModifier); 33 uni.fVariable.setTypeModifier(GrGLSLShaderVar::kUniform_TypeModifier);
34 // TODO this is a bit hacky, lets think of a better way. Basically we need to be able to use 34 // TODO this is a bit hacky, lets think of a better way. Basically we need to be able to use
35 // the uniform view matrix name in the GP, and the GP is immutable so it has to tell the PB 35 // the uniform view matrix name in the GP, and the GP is immutable so it has to tell the PB
36 // exactly what name it wants to use for the uniform view matrix. If we pre fix anythings, then 36 // exactly what name it wants to use for the uniform view matrix. If we pre fix anythings, then
37 // the names will mismatch. I think the correct solution is to have all GPs which need the 37 // the names will mismatch. I think the correct solution is to have all GPs which need the
38 // uniform view matrix, they should upload the view matrix in their setData along with regular 38 // uniform view matrix, they should upload the view matrix in their setData along with regular
39 // uniforms. 39 // uniforms.
40 char prefix = 'u'; 40 char prefix = 'u';
41 if ('u' == name[0]) { 41 if ('u' == name[0]) {
42 prefix = '\0'; 42 prefix = '\0';
43 } 43 }
44 fProgramBuilder->nameVariable(uni.fVariable.accessName(), prefix, name, mang leName); 44 fProgramBuilder->nameVariable(uni.fVariable.accessName(), prefix, name, mang leName);
45 uni.fVariable.setArrayCount(arrayCount); 45 uni.fVariable.setArrayCount(arrayCount);
46 uni.fVisibility = visibility; 46 uni.fVisibility = visibility;
47 uni.fVariable.setPrecision(precision); 47 uni.fVariable.setPrecision(precision);
48 48
49 if (outName) { 49 if (outName) {
50 *outName = uni.fVariable.c_str(); 50 *outName = uni.fVariable.c_str();
51 } 51 }
52 return GrGLSLUniformHandler::UniformHandle(fUniforms.count() - 1); 52 return GrGLSLUniformHandler::UniformHandle(fUniforms.count() - 1);
53 } 53 }
54 54
55 void GrGLUniformHandler::appendUniformDecls(ShaderVisibility visibility, SkStrin g* out) const { 55 void GrGLUniformHandler::appendUniformDecls(GrShaderFlags visibility, SkString* out) const {
56 for (int i = 0; i < fUniforms.count(); ++i) { 56 for (int i = 0; i < fUniforms.count(); ++i) {
57 if (fUniforms[i].fVisibility & visibility) { 57 if (fUniforms[i].fVisibility & visibility) {
58 fUniforms[i].fVariable.appendDecl(fProgramBuilder->glslCaps(), out); 58 fUniforms[i].fVariable.appendDecl(fProgramBuilder->glslCaps(), out);
59 out->append(";\n"); 59 out->append(";\n");
60 } 60 }
61 } 61 }
62 } 62 }
63 63
64 void GrGLUniformHandler::bindUniformLocations(GrGLuint programID, const GrGLCaps & caps) { 64 void GrGLUniformHandler::bindUniformLocations(GrGLuint programID, const GrGLCaps & caps) {
65 if (caps.bindUniformLocationSupport()) { 65 if (caps.bindUniformLocationSupport()) {
(...skipping 15 matching lines...) Expand all
81 } 81 }
82 } 82 }
83 } 83 }
84 84
85 const GrGLGpu* GrGLUniformHandler::glGpu() const { 85 const GrGLGpu* GrGLUniformHandler::glGpu() const {
86 GrGLProgramBuilder* glPB = (GrGLProgramBuilder*) fProgramBuilder; 86 GrGLProgramBuilder* glPB = (GrGLProgramBuilder*) fProgramBuilder;
87 return glPB->gpu(); 87 return glPB->gpu();
88 } 88 }
89 89
90 90
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLUniformHandler.h ('k') | src/gpu/gl/builders/GrGLProgramBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698