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

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

Issue 777673003: move program descriptor generation to flush (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix builder bug 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/GrGLProgram.h ('k') | src/gpu/gl/GrGLProgramDesc.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 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 const GrTextureAccess& textureAccess = processor.textureAccess(s); 116 const GrTextureAccess& textureAccess = processor.textureAccess(s);
117 fGpu->bindTexture(samplers[s].fTextureUnit, 117 fGpu->bindTexture(samplers[s].fTextureUnit,
118 textureAccess.getParams(), 118 textureAccess.getParams(),
119 static_cast<GrGLTexture*>(textureAccess.getTexture())) ; 119 static_cast<GrGLTexture*>(textureAccess.getTexture())) ;
120 } 120 }
121 } 121 }
122 122
123 123
124 /////////////////////////////////////////////////////////////////////////////// 124 ///////////////////////////////////////////////////////////////////////////////
125 125
126 void GrGLProgram::setData(const GrOptDrawState& optState, GrGpu::DrawType drawTy pe) { 126 void GrGLProgram::setData(const GrOptDrawState& optState) {
127 GrColor color = optState.getColor(); 127 GrColor color = optState.getColor();
128 uint8_t coverage = optState.getCoverage(); 128 uint8_t coverage = optState.getCoverage();
129 129
130 this->setColor(optState, color); 130 this->setColor(optState, color);
131 this->setCoverage(optState, coverage); 131 this->setCoverage(optState, coverage);
132 this->setMatrixAndRenderTargetHeight(drawType, optState); 132 this->setMatrixAndRenderTargetHeight(optState);
133 133
134 const GrDeviceCoordTexture* dstCopy = optState.getDstCopy(); 134 const GrDeviceCoordTexture* dstCopy = optState.getDstCopy();
135 if (dstCopy) { 135 if (dstCopy) {
136 if (fBuiltinUniformHandles.fDstCopyTopLeftUni.isValid()) { 136 if (fBuiltinUniformHandles.fDstCopyTopLeftUni.isValid()) {
137 fProgramDataManager.set2f(fBuiltinUniformHandles.fDstCopyTopLeftUni, 137 fProgramDataManager.set2f(fBuiltinUniformHandles.fDstCopyTopLeftUni,
138 static_cast<GrGLfloat>(dstCopy->offset(). fX), 138 static_cast<GrGLfloat>(dstCopy->offset(). fX),
139 static_cast<GrGLfloat>(dstCopy->offset(). fY)); 139 static_cast<GrGLfloat>(dstCopy->offset(). fY));
140 fProgramDataManager.set2f(fBuiltinUniformHandles.fDstCopyScaleUni, 140 fProgramDataManager.set2f(fBuiltinUniformHandles.fDstCopyScaleUni,
141 1.f / dstCopy->texture()->width(), 141 1.f / dstCopy->texture()->width(),
142 1.f / dstCopy->texture()->height()); 142 1.f / dstCopy->texture()->height());
(...skipping 14 matching lines...) Expand all
157 // of GLProgram determine how to set coord transforms 157 // of GLProgram determine how to set coord transforms
158 if (fGeometryProcessor.get()) { 158 if (fGeometryProcessor.get()) {
159 SkASSERT(optState.hasGeometryProcessor()); 159 SkASSERT(optState.hasGeometryProcessor());
160 const GrGeometryProcessor& gp = *optState.getGeometryProcessor(); 160 const GrGeometryProcessor& gp = *optState.getGeometryProcessor();
161 fGeometryProcessor->fGLProc->setData(fProgramDataManager, gp); 161 fGeometryProcessor->fGLProc->setData(fProgramDataManager, gp);
162 this->bindTextures(fGeometryProcessor, gp); 162 this->bindTextures(fGeometryProcessor, gp);
163 } 163 }
164 this->setFragmentData(optState); 164 this->setFragmentData(optState);
165 165
166 // Some of GrGLProgram subclasses need to update state here 166 // Some of GrGLProgram subclasses need to update state here
167 this->didSetData(drawType); 167 this->didSetData(optState.drawType());
168 } 168 }
169 169
170 void GrGLProgram::setFragmentData(const GrOptDrawState& optState) { 170 void GrGLProgram::setFragmentData(const GrOptDrawState& optState) {
171 int numProcessors = fFragmentProcessors->fProcs.count(); 171 int numProcessors = fFragmentProcessors->fProcs.count();
172 for (int e = 0; e < numProcessors; ++e) { 172 for (int e = 0; e < numProcessors; ++e) {
173 const GrPendingFragmentStage& stage = optState.getFragmentStage(e); 173 const GrPendingFragmentStage& stage = optState.getFragmentStage(e);
174 const GrProcessor& processor = *stage.getProcessor(); 174 const GrProcessor& processor = *stage.getProcessor();
175 fFragmentProcessors->fProcs[e]->fGLProc->setData(fProgramDataManager, pr ocessor); 175 fFragmentProcessors->fProcs[e]->fGLProc->setData(fProgramDataManager, pr ocessor);
176 this->setTransformData(stage, fFragmentProcessors->fProcs[e]); 176 this->setTransformData(stage, fFragmentProcessors->fProcs[e]);
177 this->bindTextures(fFragmentProcessors->fProcs[e], processor); 177 this->bindTextures(fFragmentProcessors->fProcs[e], processor);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 } 234 }
235 break; 235 break;
236 case GrProgramDesc::kAllOnes_ColorInput: 236 case GrProgramDesc::kAllOnes_ColorInput:
237 // Handled by shader creation 237 // Handled by shader creation
238 break; 238 break;
239 default: 239 default:
240 SkFAIL("Unexpected coverage type."); 240 SkFAIL("Unexpected coverage type.");
241 } 241 }
242 } 242 }
243 243
244 void GrGLProgram::setMatrixAndRenderTargetHeight(GrGpu::DrawType drawType, 244 void GrGLProgram::setMatrixAndRenderTargetHeight(const GrOptDrawState& optState) {
245 const GrOptDrawState& optState) {
246 // Load the RT height uniform if it is needed to y-flip gl_FragCoord. 245 // Load the RT height uniform if it is needed to y-flip gl_FragCoord.
247 if (fBuiltinUniformHandles.fRTHeightUni.isValid() && 246 if (fBuiltinUniformHandles.fRTHeightUni.isValid() &&
248 fMatrixState.fRenderTargetSize.fHeight != optState.getRenderTarget()->he ight()) { 247 fMatrixState.fRenderTargetSize.fHeight != optState.getRenderTarget()->he ight()) {
249 fProgramDataManager.set1f(fBuiltinUniformHandles.fRTHeightUni, 248 fProgramDataManager.set1f(fBuiltinUniformHandles.fRTHeightUni,
250 SkIntToScalar(optState.getRenderTarget()->hei ght())); 249 SkIntToScalar(optState.getRenderTarget()->hei ght()));
251 } 250 }
252 251
253 // call subclasses to set the actual view matrix 252 // call subclasses to set the actual view matrix
254 this->onSetMatrixAndRenderTargetHeight(drawType, optState); 253 this->onSetMatrixAndRenderTargetHeight(optState);
255 } 254 }
256 255
257 void GrGLProgram::onSetMatrixAndRenderTargetHeight(GrGpu::DrawType drawType, 256 void GrGLProgram::onSetMatrixAndRenderTargetHeight(const GrOptDrawState& optStat e) {
258 const GrOptDrawState& optStat e) {
259 const GrRenderTarget* rt = optState.getRenderTarget(); 257 const GrRenderTarget* rt = optState.getRenderTarget();
260 SkISize size; 258 SkISize size;
261 size.set(rt->width(), rt->height()); 259 size.set(rt->width(), rt->height());
262 if (fMatrixState.fRenderTargetOrigin != rt->origin() || 260 if (fMatrixState.fRenderTargetOrigin != rt->origin() ||
263 fMatrixState.fRenderTargetSize != size || 261 fMatrixState.fRenderTargetSize != size ||
264 !fMatrixState.fViewMatrix.cheapEqualTo(optState.getViewMatrix())) { 262 !fMatrixState.fViewMatrix.cheapEqualTo(optState.getViewMatrix())) {
265 SkASSERT(fBuiltinUniformHandles.fViewMatrixUni.isValid()); 263 SkASSERT(fBuiltinUniformHandles.fViewMatrixUni.isValid());
266 264
267 fMatrixState.fViewMatrix = optState.getViewMatrix(); 265 fMatrixState.fViewMatrix = optState.getViewMatrix();
268 fMatrixState.fRenderTargetSize = size; 266 fMatrixState.fRenderTargetSize = size;
(...skipping 13 matching lines...) Expand all
282 280
283 GrGLNvprProgramBase::GrGLNvprProgramBase(GrGpuGL* gpu, 281 GrGLNvprProgramBase::GrGLNvprProgramBase(GrGpuGL* gpu,
284 const GrProgramDesc& desc, 282 const GrProgramDesc& desc,
285 const BuiltinUniformHandles& builtinUni forms, 283 const BuiltinUniformHandles& builtinUni forms,
286 GrGLuint programID, 284 GrGLuint programID,
287 const UniformInfoArray& uniforms, 285 const UniformInfoArray& uniforms,
288 GrGLInstalledFragProcs* fragmentProcess ors) 286 GrGLInstalledFragProcs* fragmentProcess ors)
289 : INHERITED(gpu, desc, builtinUniforms, programID, uniforms, NULL, fragmentP rocessors) { 287 : INHERITED(gpu, desc, builtinUniforms, programID, uniforms, NULL, fragmentP rocessors) {
290 } 288 }
291 289
292 void GrGLNvprProgramBase::onSetMatrixAndRenderTargetHeight(GrGpu::DrawType drawT ype, 290 void GrGLNvprProgramBase::onSetMatrixAndRenderTargetHeight(const GrOptDrawState& optState) {
293 const GrOptDrawState& optState) { 291 SkASSERT(GrGpu::IsPathRenderingDrawType(optState.drawType()));
294 SkASSERT(GrGpu::IsPathRenderingDrawType(drawType));
295 const GrRenderTarget* rt = optState.getRenderTarget(); 292 const GrRenderTarget* rt = optState.getRenderTarget();
296 SkISize size; 293 SkISize size;
297 size.set(rt->width(), rt->height()); 294 size.set(rt->width(), rt->height());
298 fGpu->glPathRendering()->setProjectionMatrix(optState.getViewMatrix(), size, rt->origin()); 295 fGpu->glPathRendering()->setProjectionMatrix(optState.getViewMatrix(), size, rt->origin());
299 } 296 }
300 297
301 //////////////////////////////////////////////////////////////////////////////// ///////// 298 //////////////////////////////////////////////////////////////////////////////// /////////
302 299
303 GrGLNvprProgram::GrGLNvprProgram(GrGpuGL* gpu, 300 GrGLNvprProgram::GrGLNvprProgram(GrGpuGL* gpu,
304 const GrProgramDesc& desc, 301 const GrProgramDesc& desc,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 for (int t = 0; t < numTransforms; ++t) { 372 for (int t = 0; t < numTransforms; ++t) {
376 const SkMatrix& transform = get_transform_matrix(proc, t); 373 const SkMatrix& transform = get_transform_matrix(proc, t);
377 GrGLPathRendering::PathTexGenComponents components = 374 GrGLPathRendering::PathTexGenComponents components =
378 GrGLPathRendering::kST_PathTexGenComponents; 375 GrGLPathRendering::kST_PathTexGenComponents;
379 if (proc.isPerspectiveCoordTransform(t)) { 376 if (proc.isPerspectiveCoordTransform(t)) {
380 components = GrGLPathRendering::kSTR_PathTexGenComponents; 377 components = GrGLPathRendering::kSTR_PathTexGenComponents;
381 } 378 }
382 fGpu->glPathRendering()->enablePathTexGen(texCoordIndex++, components, t ransform); 379 fGpu->glPathRendering()->enablePathTexGen(texCoordIndex++, components, t ransform);
383 } 380 }
384 } 381 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLProgram.h ('k') | src/gpu/gl/GrGLProgramDesc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698