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

Side by Side Diff: src/gpu/gl/GrGLProgram.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/GrGLProgram.h ('k') | src/gpu/gl/GrGLProgramDataManager.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 2011 Google Inc. 2 * Copyright 2011 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 "GrGLProgram.h" 8 #include "GrGLProgram.h"
9 9
10 #include "GrAllocator.h" 10 #include "GrAllocator.h"
(...skipping 13 matching lines...) Expand all
24 #define GL_CALL(X) GR_GL_CALL(fGpu->glInterface(), X) 24 #define GL_CALL(X) GR_GL_CALL(fGpu->glInterface(), X)
25 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(fGpu->glInterface(), R, X) 25 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(fGpu->glInterface(), R, X)
26 26
27 //////////////////////////////////////////////////////////////////////////////// /////////////////// 27 //////////////////////////////////////////////////////////////////////////////// ///////////////////
28 28
29 GrGLProgram::GrGLProgram(GrGLGpu* gpu, 29 GrGLProgram::GrGLProgram(GrGLGpu* gpu,
30 const GrProgramDesc& desc, 30 const GrProgramDesc& desc,
31 const BuiltinUniformHandles& builtinUniforms, 31 const BuiltinUniformHandles& builtinUniforms,
32 GrGLuint programID, 32 GrGLuint programID,
33 const UniformInfoArray& uniforms, 33 const UniformInfoArray& uniforms,
34 const SkTArray<GrGLSampler>& samplers,
34 const VaryingInfoArray& pathProcVaryings, 35 const VaryingInfoArray& pathProcVaryings,
35 GrGLSLPrimitiveProcessor* geometryProcessor, 36 GrGLSLPrimitiveProcessor* geometryProcessor,
36 GrGLSLXferProcessor* xferProcessor, 37 GrGLSLXferProcessor* xferProcessor,
37 const GrGLSLFragProcs& fragmentProcessors, 38 const GrGLSLFragProcs& fragmentProcessors)
38 SkTArray<UniformHandle>* passSamplerUniforms)
39 : fBuiltinUniformHandles(builtinUniforms) 39 : fBuiltinUniformHandles(builtinUniforms)
40 , fProgramID(programID) 40 , fProgramID(programID)
41 , fGeometryProcessor(geometryProcessor) 41 , fGeometryProcessor(geometryProcessor)
42 , fXferProcessor(xferProcessor) 42 , fXferProcessor(xferProcessor)
43 , fFragmentProcessors(fragmentProcessors) 43 , fFragmentProcessors(fragmentProcessors)
44 , fDesc(desc) 44 , fDesc(desc)
45 , fGpu(gpu) 45 , fGpu(gpu)
46 , fProgramDataManager(gpu, programID, uniforms, pathProcVaryings) { 46 , fProgramDataManager(gpu, programID, uniforms, pathProcVaryings) {
47 fSamplerUniforms.swap(passSamplerUniforms);
48 // Assign texture units to sampler uniforms one time up front. 47 // Assign texture units to sampler uniforms one time up front.
49 GL_CALL(UseProgram(fProgramID)); 48 GL_CALL(UseProgram(fProgramID));
50 for (int i = 0; i < fSamplerUniforms.count(); i++) { 49 fProgramDataManager.setSamplers(samplers);
51 fProgramDataManager.setSampler(fSamplerUniforms[i], i);
52 }
53 } 50 }
54 51
55 GrGLProgram::~GrGLProgram() { 52 GrGLProgram::~GrGLProgram() {
56 if (fProgramID) { 53 if (fProgramID) {
57 GL_CALL(DeleteProgram(fProgramID)); 54 GL_CALL(DeleteProgram(fProgramID));
58 } 55 }
59 for (int i = 0; i < fFragmentProcessors.count(); ++i) { 56 for (int i = 0; i < fFragmentProcessors.count(); ++i) {
60 delete fFragmentProcessors[i]; 57 delete fFragmentProcessors[i];
61 } 58 }
62 } 59 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 const GrTextureAccess& access = processor.textureAccess(i); 139 const GrTextureAccess& access = processor.textureAccess(i);
143 fGpu->bindTexture((*nextSamplerIdx)++, access.getParams(), 140 fGpu->bindTexture((*nextSamplerIdx)++, access.getParams(),
144 allowSRGBInputs, static_cast<GrGLTexture*>(access.getT exture())); 141 allowSRGBInputs, static_cast<GrGLTexture*>(access.getT exture()));
145 } 142 }
146 for (int i = 0; i < processor.numBuffers(); ++i) { 143 for (int i = 0; i < processor.numBuffers(); ++i) {
147 const GrBufferAccess& access = processor.bufferAccess(i); 144 const GrBufferAccess& access = processor.bufferAccess(i);
148 fGpu->bindTexelBuffer((*nextSamplerIdx)++, access.offsetInBytes(), acces s.texelConfig(), 145 fGpu->bindTexelBuffer((*nextSamplerIdx)++, access.offsetInBytes(), acces s.texelConfig(),
149 static_cast<GrGLBuffer*>(access.buffer())); 146 static_cast<GrGLBuffer*>(access.buffer()));
150 } 147 }
151 } 148 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLProgram.h ('k') | src/gpu/gl/GrGLProgramDataManager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698