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

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

Issue 1870893002: Implement texel buffers (Closed) Base URL: https://skia.googlesource.com/skia.git@upload_texelfetch
Patch Set: 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
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"
11 #include "GrProcessor.h" 11 #include "GrProcessor.h"
12 #include "GrCoordTransform.h" 12 #include "GrCoordTransform.h"
13 #include "GrGLGpu.h" 13 #include "GrGLGpu.h"
14 #include "GrGLBuffer.h"
14 #include "GrGLPathRendering.h" 15 #include "GrGLPathRendering.h"
15 #include "GrPathProcessor.h" 16 #include "GrPathProcessor.h"
16 #include "GrPipeline.h" 17 #include "GrPipeline.h"
17 #include "GrXferProcessor.h" 18 #include "GrXferProcessor.h"
18 #include "glsl/GrGLSLFragmentProcessor.h" 19 #include "glsl/GrGLSLFragmentProcessor.h"
19 #include "glsl/GrGLSLGeometryProcessor.h" 20 #include "glsl/GrGLSLGeometryProcessor.h"
20 #include "glsl/GrGLSLXferProcessor.h" 21 #include "glsl/GrGLSLXferProcessor.h"
21 #include "SkXfermode.h" 22 #include "SkXfermode.h"
22 23
23 #define GL_CALL(X) GR_GL_CALL(fGpu->glInterface(), X) 24 #define GL_CALL(X) GR_GL_CALL(fGpu->glInterface(), X)
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 delete fFragmentProcessors[i]; 60 delete fFragmentProcessors[i];
60 } 61 }
61 } 62 }
62 63
63 void GrGLProgram::abandon() { 64 void GrGLProgram::abandon() {
64 fProgramID = 0; 65 fProgramID = 0;
65 } 66 }
66 67
67 /////////////////////////////////////////////////////////////////////////////// 68 ///////////////////////////////////////////////////////////////////////////////
68 69
69 static void append_texture_bindings(const GrProcessor& processor,
70 SkTArray<const GrTextureAccess*>* textureBin dings) {
71 if (int numTextures = processor.numTextures()) {
72 const GrTextureAccess** bindings = textureBindings->push_back_n(numTextu res);
73 int i = 0;
74 do {
75 bindings[i] = &processor.textureAccess(i);
76 } while (++i < numTextures);
77 }
78 }
79
80 void GrGLProgram::setData(const GrPrimitiveProcessor& primProc, 70 void GrGLProgram::setData(const GrPrimitiveProcessor& primProc,
81 const GrPipeline& pipeline, 71 const GrPipeline& pipeline,
82 SkTArray<const GrTextureAccess*>* textureBindings) { 72 bool allowSRGBInputs) {
83 this->setRenderTargetState(primProc, pipeline); 73 this->setRenderTargetState(primProc, pipeline);
84 74
85 // we set the textures, and uniforms for installed processors in a generic w ay, but subclasses 75 // we set the textures, and uniforms for installed processors in a generic w ay, but subclasses
86 // of GLProgram determine how to set coord transforms 76 // of GLProgram determine how to set coord transforms
77 int nextSamplerIdx = 0;
87 fGeometryProcessor->setData(fProgramDataManager, primProc); 78 fGeometryProcessor->setData(fProgramDataManager, primProc);
88 append_texture_bindings(primProc, textureBindings); 79 this->bindTextures(primProc, allowSRGBInputs, &nextSamplerIdx);
89 80
90 this->setFragmentData(primProc, pipeline, textureBindings); 81 this->setFragmentData(primProc, pipeline, allowSRGBInputs, &nextSamplerIdx);
91 82
92 if (primProc.getPixelLocalStorageState() != 83 if (primProc.getPixelLocalStorageState() !=
93 GrPixelLocalStorageState::kDraw_GrPixelLocalStorageState) { 84 GrPixelLocalStorageState::kDraw_GrPixelLocalStorageState) {
94 const GrXferProcessor& xp = pipeline.getXferProcessor(); 85 const GrXferProcessor& xp = pipeline.getXferProcessor();
95 fXferProcessor->setData(fProgramDataManager, xp); 86 fXferProcessor->setData(fProgramDataManager, xp);
96 append_texture_bindings(xp, textureBindings); 87 this->bindTextures(xp, allowSRGBInputs, &nextSamplerIdx);
97 } 88 }
98 } 89 }
99 90
100 void GrGLProgram::setFragmentData(const GrPrimitiveProcessor& primProc, 91 void GrGLProgram::setFragmentData(const GrPrimitiveProcessor& primProc,
101 const GrPipeline& pipeline, 92 const GrPipeline& pipeline,
102 SkTArray<const GrTextureAccess*>* textureBindi ngs) { 93 bool allowSRGBInputs,
94 int* nextSamplerIdx) {
103 int numProcessors = fFragmentProcessors.count(); 95 int numProcessors = fFragmentProcessors.count();
104 for (int i = 0; i < numProcessors; ++i) { 96 for (int i = 0; i < numProcessors; ++i) {
105 const GrFragmentProcessor& processor = pipeline.getFragmentProcessor(i); 97 const GrFragmentProcessor& processor = pipeline.getFragmentProcessor(i);
106 fFragmentProcessors[i]->setData(fProgramDataManager, processor); 98 fFragmentProcessors[i]->setData(fProgramDataManager, processor);
107 this->setTransformData(primProc, processor, i); 99 this->setTransformData(primProc, processor, i);
108 append_texture_bindings(processor, textureBindings); 100 this->bindTextures(processor, allowSRGBInputs, nextSamplerIdx);
109 } 101 }
110 } 102 }
111 void GrGLProgram::setTransformData(const GrPrimitiveProcessor& primProc, 103 void GrGLProgram::setTransformData(const GrPrimitiveProcessor& primProc,
112 const GrFragmentProcessor& processor, 104 const GrFragmentProcessor& processor,
113 int index) { 105 int index) {
114 fGeometryProcessor->setTransformData(primProc, fProgramDataManager, index, 106 fGeometryProcessor->setTransformData(primProc, fProgramDataManager, index,
115 processor.coordTransforms()); 107 processor.coordTransforms());
116 } 108 }
117 109
118 void GrGLProgram::setRenderTargetState(const GrPrimitiveProcessor& primProc, 110 void GrGLProgram::setRenderTargetState(const GrPrimitiveProcessor& primProc,
(...skipping 19 matching lines...) Expand all
138 fRenderTargetState.getRTAdjustmentVec(rtAdjustmentVec); 130 fRenderTargetState.getRTAdjustmentVec(rtAdjustmentVec);
139 fProgramDataManager.set4fv(fBuiltinUniformHandles.fRTAdjustmentUni, 1, rtAdjustmentVec); 131 fProgramDataManager.set4fv(fBuiltinUniformHandles.fRTAdjustmentUni, 1, rtAdjustmentVec);
140 } 132 }
141 } else { 133 } else {
142 SkASSERT(fGpu->glCaps().shaderCaps()->pathRenderingSupport()); 134 SkASSERT(fGpu->glCaps().shaderCaps()->pathRenderingSupport());
143 const GrPathProcessor& pathProc = primProc.cast<GrPathProcessor>(); 135 const GrPathProcessor& pathProc = primProc.cast<GrPathProcessor>();
144 fGpu->glPathRendering()->setProjectionMatrix(pathProc.viewMatrix(), 136 fGpu->glPathRendering()->setProjectionMatrix(pathProc.viewMatrix(),
145 size, rt->origin()); 137 size, rt->origin());
146 } 138 }
147 } 139 }
140
141 void GrGLProgram::bindTextures(const GrProcessor& processor, bool allowSRGBInput s,
142 int* nextSamplerIdx) {
143 for (int i = 0; i < processor.numTextures(); ++i) {
144 const GrTextureAccess& access = processor.textureAccess(i);
145 fGpu->bindTexture((*nextSamplerIdx)++, access.getParams(),
146 allowSRGBInputs, static_cast<GrGLTexture*>(access.getT exture()));
147 }
148 for (int i = 0; i < processor.numBuffers(); ++i) {
149 const GrBufferAccess& access = processor.bufferAccess(i);
150 fGpu->bindTexelBuffer((*nextSamplerIdx)++, access.offsetInBytes(), acces s.texelConfig(),
151 static_cast<GrGLBuffer*>(access.buffer()));
152 }
153 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698