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

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

Issue 1885863004: Refactor how we store and use samplers in Ganesh (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove unneeded assert Created 4 years, 8 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"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 GrGLSLUniformHandler::SamplerHandle GrGLUniformHandler::internalAddSampler(uint3 2_t visibility,
56 GrPix elConfig config,
57 GrSLT ype type,
58 GrSLP recision precision,
59 const char* name) {
60 SkASSERT(name && strlen(name));
61 SkDEBUGCODE(static const uint32_t kVisMask = kVertex_GrShaderFlag | kFragmen t_GrShaderFlag);
62 SkASSERT(0 == (~kVisMask & visibility));
63 SkASSERT(0 != visibility);
64 SkString mangleName;
65 char prefix = 'u';
66 fProgramBuilder->nameVariable(&mangleName, prefix, name, true);
67 fSamplers.emplace_back(visibility, config, type, precision, mangleName.c_str ());
68 return GrGLSLUniformHandler::SamplerHandle(fSamplers.count() - 1);
69 }
70
55 void GrGLUniformHandler::appendUniformDecls(GrShaderFlags visibility, SkString* out) const { 71 void GrGLUniformHandler::appendUniformDecls(GrShaderFlags visibility, SkString* out) const {
56 for (int i = 0; i < fUniforms.count(); ++i) { 72 for (int i = 0; i < fUniforms.count(); ++i) {
57 if (fUniforms[i].fVisibility & visibility) { 73 if (fUniforms[i].fVisibility & visibility) {
58 fUniforms[i].fVariable.appendDecl(fProgramBuilder->glslCaps(), out); 74 fUniforms[i].fVariable.appendDecl(fProgramBuilder->glslCaps(), out);
59 out->append(";\n"); 75 out->append(";\n");
60 } 76 }
61 } 77 }
78 for (int i = 0; i < fSamplers.count(); ++i) {
79 if (fSamplers[i].visibility() & visibility) {
80 fSamplers[i].fShaderVar.appendDecl(fProgramBuilder->glslCaps(), out) ;
81 out->append(";\n");
82 }
83 }
62 } 84 }
63 85
64 void GrGLUniformHandler::bindUniformLocations(GrGLuint programID, const GrGLCaps & caps) { 86 void GrGLUniformHandler::bindUniformLocations(GrGLuint programID, const GrGLCaps & caps) {
65 if (caps.bindUniformLocationSupport()) { 87 if (caps.bindUniformLocationSupport()) {
66 int count = fUniforms.count(); 88 int count = fUniforms.count();
67 for (int i = 0; i < count; ++i) { 89 for (int i = 0; i < count; ++i) {
68 GL_CALL(BindUniformLocation(programID, i, fUniforms[i].fVariable.c_s tr())); 90 GL_CALL(BindUniformLocation(programID, i, fUniforms[i].fVariable.c_s tr()));
69 fUniforms[i].fLocation = i; 91 fUniforms[i].fLocation = i;
70 } 92 }
93 for (int i = 0; i < fSamplers.count(); ++i) {
94 GL_CALL(BindUniformLocation(programID, i, fSamplers[i].fShaderVar.c_ str()));
95 fSamplers[i].fLocation = i;
96 }
71 } 97 }
72 } 98 }
73 99
74 void GrGLUniformHandler::getUniformLocations(GrGLuint programID, const GrGLCaps& caps) { 100 void GrGLUniformHandler::getUniformLocations(GrGLuint programID, const GrGLCaps& caps) {
75 if (!caps.bindUniformLocationSupport()) { 101 if (!caps.bindUniformLocationSupport()) {
76 int count = fUniforms.count(); 102 int count = fUniforms.count();
77 for (int i = 0; i < count; ++i) { 103 for (int i = 0; i < count; ++i) {
78 GrGLint location; 104 GrGLint location;
79 GL_CALL_RET(location, GetUniformLocation(programID, fUniforms[i].fVa riable.c_str())); 105 GL_CALL_RET(location, GetUniformLocation(programID, fUniforms[i].fVa riable.c_str()));
80 fUniforms[i].fLocation = location; 106 fUniforms[i].fLocation = location;
81 } 107 }
108 for (int i = 0; i < fSamplers.count(); ++i) {
109 GrGLint location;
110 GL_CALL_RET(location, GetUniformLocation(programID, fSamplers[i].fSh aderVar.c_str()));
111 fSamplers[i].fLocation = location;
112 }
82 } 113 }
83 } 114 }
84 115
85 const GrGLGpu* GrGLUniformHandler::glGpu() const { 116 const GrGLGpu* GrGLUniformHandler::glGpu() const {
86 GrGLProgramBuilder* glPB = (GrGLProgramBuilder*) fProgramBuilder; 117 GrGLProgramBuilder* glPB = (GrGLProgramBuilder*) fProgramBuilder;
87 return glPB->gpu(); 118 return glPB->gpu();
88 } 119 }
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