OLD | NEW |
---|---|
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 | 8 |
9 #include "GrGLGpu.h" | 9 #include "GrGLGpu.h" |
10 #include "GrGLGLSL.h" | 10 #include "GrGLGLSL.h" |
11 #include "GrGLStencilAttachment.h" | 11 #include "GrGLStencilAttachment.h" |
12 #include "GrGLTextureRenderTarget.h" | 12 #include "GrGLTextureRenderTarget.h" |
13 #include "GrGpuResourcePriv.h" | 13 #include "GrGpuResourcePriv.h" |
14 #include "GrPipeline.h" | 14 #include "GrPipeline.h" |
15 #include "GrPLSGeometryProcessor.h" | |
15 #include "GrRenderTargetPriv.h" | 16 #include "GrRenderTargetPriv.h" |
16 #include "GrSurfacePriv.h" | 17 #include "GrSurfacePriv.h" |
17 #include "GrTexturePriv.h" | 18 #include "GrTexturePriv.h" |
18 #include "GrTypes.h" | 19 #include "GrTypes.h" |
19 #include "GrVertices.h" | 20 #include "GrVertices.h" |
20 #include "builders/GrGLShaderStringBuilder.h" | 21 #include "builders/GrGLShaderStringBuilder.h" |
21 #include "glsl/GrGLSL.h" | 22 #include "glsl/GrGLSL.h" |
22 #include "glsl/GrGLSLCaps.h" | 23 #include "glsl/GrGLSLCaps.h" |
24 #include "glsl/GrGLSLPLSPathRendering.h" | |
23 #include "SkStrokeRec.h" | 25 #include "SkStrokeRec.h" |
24 #include "SkTemplates.h" | 26 #include "SkTemplates.h" |
25 | 27 |
26 #define GL_CALL(X) GR_GL_CALL(this->glInterface(), X) | 28 #define GL_CALL(X) GR_GL_CALL(this->glInterface(), X) |
27 #define GL_CALL_RET(RET, X) GR_GL_CALL_RET(this->glInterface(), RET, X) | 29 #define GL_CALL_RET(RET, X) GR_GL_CALL_RET(this->glInterface(), RET, X) |
28 | 30 |
29 #define SKIP_CACHE_CHECK true | 31 #define SKIP_CACHE_CHECK true |
30 | 32 |
31 #if GR_GL_CHECK_ALLOC_WITH_GET_ERROR | 33 #if GR_GL_CHECK_ALLOC_WITH_GET_ERROR |
32 #define CLEAR_ERROR_BEFORE_ALLOC(iface) GrGLClearErr(iface) | 34 #define CLEAR_ERROR_BEFORE_ALLOC(iface) GrGLClearErr(iface) |
33 #define GL_ALLOC_CALL(iface, call) GR_GL_CALL_NOERRCHECK(iface, call) | 35 #define GL_ALLOC_CALL(iface, call) GR_GL_CALL_NOERRCHECK(iface, call) |
34 #define CHECK_ALLOC_ERROR(iface) GR_GL_GET_ERROR(iface) | 36 #define CHECK_ALLOC_ERROR(iface) GR_GL_GET_ERROR(iface) |
35 #else | 37 #else |
36 #define CLEAR_ERROR_BEFORE_ALLOC(iface) | 38 #define CLEAR_ERROR_BEFORE_ALLOC(iface) |
37 #define GL_ALLOC_CALL(iface, call) GR_GL_CALL(iface, call) | 39 #define GL_ALLOC_CALL(iface, call) GR_GL_CALL(iface, call) |
38 #define CHECK_ALLOC_ERROR(iface) GR_GL_NO_ERROR | 40 #define CHECK_ALLOC_ERROR(iface) GR_GL_NO_ERROR |
39 #endif | 41 #endif |
40 | 42 |
43 #define GL_SHADER_PIXEL_LOCAL_STORAGE_EXT 0x8F64 | |
bsalomon
2016/01/13 19:15:34
GrGLDefines.h
| |
44 | |
41 | 45 |
42 /////////////////////////////////////////////////////////////////////////////// | 46 /////////////////////////////////////////////////////////////////////////////// |
43 | 47 |
44 | 48 |
45 static const GrGLenum gXfermodeEquation2Blend[] = { | 49 static const GrGLenum gXfermodeEquation2Blend[] = { |
46 // Basic OpenGL blend equations. | 50 // Basic OpenGL blend equations. |
47 GR_GL_FUNC_ADD, | 51 GR_GL_FUNC_ADD, |
48 GR_GL_FUNC_SUBTRACT, | 52 GR_GL_FUNC_SUBTRACT, |
49 GR_GL_FUNC_REVERSE_SUBTRACT, | 53 GR_GL_FUNC_REVERSE_SUBTRACT, |
50 | 54 |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
217 fTempSrcFBOID = 0; | 221 fTempSrcFBOID = 0; |
218 fTempDstFBOID = 0; | 222 fTempDstFBOID = 0; |
219 fStencilClearFBOID = 0; | 223 fStencilClearFBOID = 0; |
220 | 224 |
221 if (this->glCaps().shaderCaps()->pathRenderingSupport()) { | 225 if (this->glCaps().shaderCaps()->pathRenderingSupport()) { |
222 fPathRendering.reset(new GrGLPathRendering(this)); | 226 fPathRendering.reset(new GrGLPathRendering(this)); |
223 } | 227 } |
224 this->createCopyPrograms(); | 228 this->createCopyPrograms(); |
225 fWireRectProgram.fProgram = 0; | 229 fWireRectProgram.fProgram = 0; |
226 fWireRectArrayBuffer = 0; | 230 fWireRectArrayBuffer = 0; |
231 #ifdef ENABLE_PLS | |
bsalomon
2016/01/13 19:15:34
untab
| |
232 if (this->glCaps().shaderCaps()->pixelLocalStorageSize() > 0) { | |
bsalomon
2016/01/13 19:15:34
Check for framebuffer_fetch too?
| |
233 this->createPLSSetupProgram(); | |
234 } | |
235 else { | |
236 memset(&fPLSSetupProgram, 0, sizeof(fPLSSetupProgram)); | |
237 } | |
238 fHWPLSEnabled = false; | |
239 #endif | |
227 } | 240 } |
228 | 241 |
229 GrGLGpu::~GrGLGpu() { | 242 GrGLGpu::~GrGLGpu() { |
230 if (0 != fHWProgramID) { | 243 if (0 != fHWProgramID) { |
231 // detach the current program so there is no confusion on OpenGL's part | 244 // detach the current program so there is no confusion on OpenGL's part |
232 // that we want it to be deleted | 245 // that we want it to be deleted |
233 GL_CALL(UseProgram(0)); | 246 GL_CALL(UseProgram(0)); |
234 } | 247 } |
235 | 248 |
236 if (0 != fTempSrcFBOID) { | 249 if (0 != fTempSrcFBOID) { |
(...skipping 17 matching lines...) Expand all Loading... | |
254 } | 267 } |
255 | 268 |
256 if (0 != fWireRectProgram.fProgram) { | 269 if (0 != fWireRectProgram.fProgram) { |
257 GL_CALL(DeleteProgram(fWireRectProgram.fProgram)); | 270 GL_CALL(DeleteProgram(fWireRectProgram.fProgram)); |
258 } | 271 } |
259 | 272 |
260 if (0 != fWireRectArrayBuffer) { | 273 if (0 != fWireRectArrayBuffer) { |
261 GL_CALL(DeleteBuffers(1, &fWireRectArrayBuffer)); | 274 GL_CALL(DeleteBuffers(1, &fWireRectArrayBuffer)); |
262 } | 275 } |
263 | 276 |
277 #ifdef ENABLE_PLS | |
278 if (0 != fPLSSetupProgram.fArrayBuffer) { | |
279 GL_CALL(DeleteBuffers(1, &fPLSSetupProgram.fArrayBuffer)); | |
280 } | |
281 | |
282 if (0 != fPLSSetupProgram.fProgram) { | |
283 GL_CALL(DeleteProgram(fPLSSetupProgram.fProgram)); | |
284 } | |
285 #endif | |
286 | |
264 delete fProgramCache; | 287 delete fProgramCache; |
265 } | 288 } |
266 | 289 |
290 #ifdef ENABLE_PLS | |
bsalomon
2016/01/13 19:15:34
Any code that won't be run without the GrPLSPR sub
| |
291 void GrGLGpu::createPLSSetupProgram() { | |
292 const char* version = this->glCaps().glslCaps()->versionDeclString(); | |
293 | |
294 GrGLSLShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kAttribute _TypeModifier); | |
295 GrGLSLShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType, | |
296 GrShaderVar::kUniform_TypeModifier); | |
297 GrGLSLShaderVar uPosXform("u_posXform", kVec4f_GrSLType, GrShaderVar::kUnifo rm_TypeModifier); | |
298 GrGLSLShaderVar uTexture("u_texture", kSampler2D_GrSLType, GrShaderVar::kUni form_TypeModifier); | |
299 GrGLSLShaderVar vTexCoord("v_texCoord", kVec2f_GrSLType, GrShaderVar::kVaryi ngOut_TypeModifier); | |
300 | |
301 SkString vshaderTxt(version); | |
302 aVertex.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | |
303 vshaderTxt.append(";"); | |
304 uTexCoordXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | |
305 vshaderTxt.append(";"); | |
306 uPosXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | |
307 vshaderTxt.append(";"); | |
308 vTexCoord.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | |
309 vshaderTxt.append(";"); | |
310 | |
311 vshaderTxt.append( | |
312 "// PLS Setup Program VS\n" | |
313 "void main() {" | |
314 " gl_Position.xy = a_vertex * u_posXform.xy + u_posXform.zw;" | |
315 " gl_Position.zw = vec2(0, 1);" | |
316 "}" | |
317 ); | |
318 | |
319 SkString fshaderTxt(version); | |
320 fshaderTxt.append("#extension GL_ARM_shader_framebuffer_fetch : require\n"); | |
bsalomon
2016/01/13 19:15:34
This extension has aliases, see GrGLSLCaps()::fbFe
| |
321 fshaderTxt.append("#extension GL_EXT_shader_pixel_local_storage : require\n" ); | |
322 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, | |
323 *this->glCaps().glslCaps(), | |
324 &fshaderTxt); | |
325 vTexCoord.setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier); | |
326 vTexCoord.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); | |
327 fshaderTxt.append(";"); | |
328 uTexture.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); | |
329 fshaderTxt.append(";"); | |
330 | |
331 fshaderTxt.appendf( | |
332 "// PLS Setup Program FS\n" | |
333 PLS_PATH_DATA_DECL | |
334 "void main() {\n" | |
335 " " PLS_DSTCOLOR_NAME " = gl_LastFragColorARM;\n" | |
336 " pls.windings = ivec4(0, 0, 0, 0);\n" | |
337 "}" | |
338 ); | |
339 GL_CALL_RET(fPLSSetupProgram.fProgram, CreateProgram()); | |
340 const char* str; | |
341 GrGLint length; | |
342 | |
343 str = vshaderTxt.c_str(); | |
344 length = SkToInt(vshaderTxt.size()); | |
345 GrGLuint vshader = GrGLCompileAndAttachShader(*fGLContext, fPLSSetupProgram. fProgram, | |
346 GR_GL_VERTEX_SHADER, &str, &le ngth, 1, &fStats); | |
347 | |
348 str = fshaderTxt.c_str(); | |
349 length = SkToInt(fshaderTxt.size()); | |
350 GrGLuint fshader = GrGLCompileAndAttachShader(*fGLContext, fPLSSetupProgram. fProgram, | |
351 GR_GL_FRAGMENT_SHADER, &str, & length, 1, &fStats); | |
352 | |
353 GL_CALL(LinkProgram(fPLSSetupProgram.fProgram)); | |
354 | |
355 GL_CALL_RET(fPLSSetupProgram.fPosXformUniform, GetUniformLocation(fPLSSetupP rogram.fProgram, | |
356 "u_posXform")) ; | |
357 | |
358 GL_CALL(BindAttribLocation(fPLSSetupProgram.fProgram, 0, "a_vertex")); | |
359 | |
360 GL_CALL(DeleteShader(vshader)); | |
361 GL_CALL(DeleteShader(fshader)); | |
362 | |
363 GL_CALL(GenBuffers(1, &fPLSSetupProgram.fArrayBuffer)); | |
364 fHWGeometryState.setVertexBufferID(this, fPLSSetupProgram.fArrayBuffer); | |
365 static const GrGLfloat vdata[] = { | |
366 0, 0, | |
367 0, 1, | |
368 1, 0, | |
369 1, 1 | |
370 }; | |
371 GL_ALLOC_CALL(this->glInterface(), | |
372 BufferData(GR_GL_ARRAY_BUFFER, | |
373 (GrGLsizeiptr) sizeof(vdata), | |
374 vdata, // data ptr | |
375 GR_GL_STATIC_DRAW)); | |
376 } | |
377 #endif | |
378 | |
267 void GrGLGpu::contextAbandoned() { | 379 void GrGLGpu::contextAbandoned() { |
268 INHERITED::contextAbandoned(); | 380 INHERITED::contextAbandoned(); |
269 fProgramCache->abandon(); | 381 fProgramCache->abandon(); |
270 fHWProgramID = 0; | 382 fHWProgramID = 0; |
271 fTempSrcFBOID = 0; | 383 fTempSrcFBOID = 0; |
272 fTempDstFBOID = 0; | 384 fTempDstFBOID = 0; |
273 fStencilClearFBOID = 0; | 385 fStencilClearFBOID = 0; |
274 fCopyProgramArrayBuffer = 0; | 386 fCopyProgramArrayBuffer = 0; |
275 for (size_t i = 0; i < SK_ARRAY_COUNT(fCopyPrograms); ++i) { | 387 for (size_t i = 0; i < SK_ARRAY_COUNT(fCopyPrograms); ++i) { |
276 fCopyPrograms[i].fProgram = 0; | 388 fCopyPrograms[i].fProgram = 0; |
(...skipping 1849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2126 if (!flipY) { | 2238 if (!flipY) { |
2127 dst += rowBytes; | 2239 dst += rowBytes; |
2128 } else { | 2240 } else { |
2129 dst -= rowBytes; | 2241 dst -= rowBytes; |
2130 } | 2242 } |
2131 } | 2243 } |
2132 } | 2244 } |
2133 return true; | 2245 return true; |
2134 } | 2246 } |
2135 | 2247 |
2248 void GrGLGpu::performFlushWorkaround() { | |
2249 #ifdef ENABLE_PLS | |
2250 if (this->glCaps().shaderCaps()->pixelLocalStorageSize() > 0) { | |
2251 /* There is an ARM driver bug where if we use PLS, and then draw a f rame which does not | |
2252 * use PLS, it leaves garbage all over the place. As a workaround, w e use PLS in a | |
2253 * trivial way every frame. | |
2254 */ | |
2255 if (kYes_TriState == fHWScissorSettings.fEnabled) { | |
2256 GL_CALL(Disable(GR_GL_SCISSOR_TEST)); | |
2257 } | |
2258 GL_CALL(Enable(GL_SHADER_PIXEL_LOCAL_STORAGE_EXT)); | |
2259 this->stampRectUsingProgram(fPLSSetupProgram.fProgram, | |
2260 SkRect::MakeXYWH(-100.0f, -100.0f, 0.01f , 0.01f), | |
2261 fPLSSetupProgram.fPosXformUniform, | |
2262 fPLSSetupProgram.fArrayBuffer); | |
2263 GL_CALL(Disable(GL_SHADER_PIXEL_LOCAL_STORAGE_EXT)); | |
2264 if (kYes_TriState == fHWScissorSettings.fEnabled) { | |
2265 GL_CALL(Enable(GR_GL_SCISSOR_TEST)); | |
2266 } | |
2267 } | |
2268 #endif | |
2269 } | |
2270 | |
2136 void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound) { | 2271 void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound) { |
2137 | |
2138 SkASSERT(target); | 2272 SkASSERT(target); |
2139 | 2273 |
2140 uint32_t rtID = target->getUniqueID(); | 2274 uint32_t rtID = target->getUniqueID(); |
2141 if (fHWBoundRenderTargetUniqueID != rtID) { | 2275 if (fHWBoundRenderTargetUniqueID != rtID) { |
2142 fStats.incRenderTargetBinds(); | 2276 fStats.incRenderTargetBinds(); |
2143 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID())); | 2277 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID())); |
2144 #ifdef SK_DEBUG | 2278 #ifdef SK_DEBUG |
2145 // don't do this check in Chromium -- this is causing | 2279 // don't do this check in Chromium -- this is causing |
2146 // lots of repeated command buffer flushes when the compositor is | 2280 // lots of repeated command buffer flushes when the compositor is |
2147 // rendering with Ganesh, which is really slow; even too slow for | 2281 // rendering with Ganesh, which is really slow; even too slow for |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2210 } | 2344 } |
2211 } | 2345 } |
2212 #endif | 2346 #endif |
2213 #endif | 2347 #endif |
2214 | 2348 |
2215 void GrGLGpu::onDraw(const DrawArgs& args, const GrNonInstancedVertices& vertice s) { | 2349 void GrGLGpu::onDraw(const DrawArgs& args, const GrNonInstancedVertices& vertice s) { |
2216 if (!this->flushGLState(args)) { | 2350 if (!this->flushGLState(args)) { |
2217 return; | 2351 return; |
2218 } | 2352 } |
2219 | 2353 |
2354 #ifdef ENABLE_PLS | |
2355 GrPixelLocalStorageState plsState = args.fPrimitiveProcessor->getPixelLo calStorageState(); | |
2356 if (!fHWPLSEnabled && plsState != GrPixelLocalStorageState::kDisabled_St ate) { | |
2357 GL_CALL(Enable(GL_SHADER_PIXEL_LOCAL_STORAGE_EXT)); | |
2358 this->setupPixelLocalStorage(args); | |
2359 fHWPLSEnabled = true; | |
2360 } | |
2361 if (plsState == GrPixelLocalStorageState::kFinish_State) { | |
2362 GrStencilSettings stencil; | |
2363 stencil.setDisabled(); | |
2364 this->flushStencil(stencil); | |
2365 } | |
2366 #endif | |
2367 | |
2220 size_t indexOffsetInBytes = 0; | 2368 size_t indexOffsetInBytes = 0; |
2221 this->setupGeometry(*args.fPrimitiveProcessor, vertices, &indexOffsetInBytes ); | 2369 this->setupGeometry(*args.fPrimitiveProcessor, vertices, &indexOffsetInBytes ); |
2222 | 2370 |
2223 SkASSERT((size_t)vertices.primitiveType() < SK_ARRAY_COUNT(gPrimitiveType2GL Mode)); | 2371 SkASSERT((size_t)vertices.primitiveType() < SK_ARRAY_COUNT(gPrimitiveType2GL Mode)); |
2224 | 2372 |
2225 if (vertices.isIndexed()) { | 2373 if (vertices.isIndexed()) { |
2226 GrGLvoid* indices = | 2374 GrGLvoid* indices = |
2227 reinterpret_cast<GrGLvoid*>(indexOffsetInBytes + sizeof(uint16_t) * | 2375 reinterpret_cast<GrGLvoid*>(indexOffsetInBytes + sizeof(uint16_t) * |
2228 vertices.startIndex()); | 2376 vertices.startIndex()); |
2229 // info.startVertex() was accounted for by setupGeometry. | 2377 // info.startVertex() was accounted for by setupGeometry. |
2230 GL_CALL(DrawElements(gPrimitiveType2GLMode[vertices.primitiveType()], | 2378 GL_CALL(DrawElements(gPrimitiveType2GLMode[vertices.primitiveType()], |
2231 vertices.indexCount(), | 2379 vertices.indexCount(), |
2232 GR_GL_UNSIGNED_SHORT, | 2380 GR_GL_UNSIGNED_SHORT, |
2233 indices)); | 2381 indices)); |
2234 } else { | 2382 } else { |
2235 // Pass 0 for parameter first. We have to adjust glVertexAttribPointer() to account for | 2383 // Pass 0 for parameter first. We have to adjust glVertexAttribPointer() to account for |
2236 // startVertex in the DrawElements case. So we always rely on setupGeome try to have | 2384 // startVertex in the DrawElements case. So we always rely on setupGeome try to have |
2237 // accounted for startVertex. | 2385 // accounted for startVertex. |
2238 GL_CALL(DrawArrays(gPrimitiveType2GLMode[vertices.primitiveType()], 0, | 2386 GL_CALL(DrawArrays(gPrimitiveType2GLMode[vertices.primitiveType()], 0, |
2239 vertices.vertexCount())); | 2387 vertices.vertexCount())); |
2240 } | 2388 } |
2389 | |
2390 #ifdef ENABLE_PLS | |
2391 if (fHWPLSEnabled && plsState == GrPixelLocalStorageState::kFinish_State ) { | |
2392 // PLS draws always involve multiple draws, finishing up with a non- PLS | |
2393 // draw that writes to the color buffer. That draw ends up here; we wait | |
2394 // until after it is complete to actually disable PLS. | |
2395 GL_CALL(Disable(GL_SHADER_PIXEL_LOCAL_STORAGE_EXT)); | |
2396 fHWPLSEnabled = false; | |
2397 this->disableScissor(); | |
2398 } | |
2399 #endif | |
2400 | |
2241 #if SWAP_PER_DRAW | 2401 #if SWAP_PER_DRAW |
2242 glFlush(); | 2402 glFlush(); |
2243 #if defined(SK_BUILD_FOR_MAC) | 2403 #if defined(SK_BUILD_FOR_MAC) |
2244 aglSwapBuffers(aglGetCurrentContext()); | 2404 aglSwapBuffers(aglGetCurrentContext()); |
2245 int set_a_break_pt_here = 9; | 2405 int set_a_break_pt_here = 9; |
2246 aglSwapBuffers(aglGetCurrentContext()); | 2406 aglSwapBuffers(aglGetCurrentContext()); |
2247 #elif defined(SK_BUILD_FOR_WIN32) | 2407 #elif defined(SK_BUILD_FOR_WIN32) |
2248 SwapBuf(); | 2408 SwapBuf(); |
2249 int set_a_break_pt_here = 9; | 2409 int set_a_break_pt_here = 9; |
2250 SwapBuf(); | 2410 SwapBuf(); |
2251 #endif | 2411 #endif |
2252 #endif | 2412 #endif |
2253 } | 2413 } |
2254 | 2414 |
2415 void GrGLGpu::stampRectUsingProgram(GrGLuint program, const SkRect& bounds, GrGL int posXformUniform, | |
2416 GrGLuint arrayBuffer) { | |
2417 GL_CALL(UseProgram(program)); | |
2418 this->fHWGeometryState.setVertexArrayID(this, 0); | |
2419 | |
2420 GrGLAttribArrayState* attribs = | |
2421 this->fHWGeometryState.bindArrayAndBufferToDraw(this, arrayBuffer); | |
2422 attribs->set(this, 0, arrayBuffer, 2, GR_GL_FLOAT, false, 2 * sizeof(GrGLflo at), 0); | |
2423 attribs->disableUnusedArrays(this, 0x1); | |
2424 | |
2425 GL_CALL(Uniform4f(posXformUniform, bounds.width(), bounds.height(), bounds.l eft(), | |
2426 bounds.top())); | |
2427 | |
2428 GrXferProcessor::BlendInfo blendInfo; | |
2429 blendInfo.reset(); | |
2430 this->flushBlend(blendInfo, GrSwizzle()); | |
2431 this->flushColorWrite(true); | |
2432 this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); | |
2433 if (!fHWStencilSettings.isDisabled()) { | |
2434 GL_CALL(Disable(GR_GL_STENCIL_TEST)); | |
2435 } | |
2436 GL_CALL(DrawArrays(GR_GL_TRIANGLE_STRIP, 0, 4)); | |
2437 GL_CALL(UseProgram(fHWProgramID)); | |
2438 if (!fHWStencilSettings.isDisabled()) { | |
2439 GL_CALL(Enable(GR_GL_STENCIL_TEST)); | |
2440 } | |
2441 } | |
2442 | |
2443 #ifdef ENABLE_PLS | |
2444 void GrGLGpu::setupPixelLocalStorage(const DrawArgs& args) { | |
2445 const SkRect& bounds = | |
2446 static_cast<const GrPLSGeometryProcessor*>(args.fPrimitiveProcessor) ->fBounds; | |
2447 // setup pixel local storage -- this means capturing and storing the current framebuffer color | |
2448 // and initializing the winding counts to zero | |
2449 GrRenderTarget* rt = args.fPipeline->getRenderTarget(); | |
2450 SkScalar width = rt->width(); | |
2451 SkScalar height = rt->height(); | |
2452 // dst rect edges in NDC (-1 to 1) | |
2453 // having some issues with rounding, just expand the bounds by 1 and trust t he scissor to keep | |
2454 // it contained properly | |
2455 GrGLfloat dx0 = 2.0f * (bounds.left() - 1) / width - 1.0f; | |
2456 GrGLfloat dx1 = 2.0f * (bounds.right() + 1) / width - 1.0f; | |
2457 GrGLfloat dy0 = -2.0f * (bounds.top() - 1) / height + 1.0f; | |
2458 GrGLfloat dy1 = -2.0f * (bounds.bottom() + 1) / height + 1.0f; | |
2459 SkRect deviceBounds = SkRect::MakeXYWH(dx0, dy0, dx1 - dx0, dy1 - dy0); | |
2460 | |
2461 GL_CALL(Enable(GR_GL_FETCH_PER_SAMPLE_ARM)); | |
2462 this->stampRectUsingProgram(fPLSSetupProgram.fProgram, deviceBounds, | |
2463 fPLSSetupProgram.fPosXformUniform, fPLSSetupProg ram.fArrayBuffer); | |
2464 } | |
2465 #endif | |
2466 | |
2255 void GrGLGpu::onResolveRenderTarget(GrRenderTarget* target) { | 2467 void GrGLGpu::onResolveRenderTarget(GrRenderTarget* target) { |
2256 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(target); | 2468 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(target); |
2257 if (rt->needsResolve()) { | 2469 if (rt->needsResolve()) { |
2258 // Some extensions automatically resolves the texture when it is read. | 2470 // Some extensions automatically resolves the texture when it is read. |
2259 if (this->glCaps().usesMSAARenderBuffers()) { | 2471 if (this->glCaps().usesMSAARenderBuffers()) { |
2260 SkASSERT(rt->textureFBOID() != rt->renderFBOID()); | 2472 SkASSERT(rt->textureFBOID() != rt->renderFBOID()); |
2261 fStats.incRenderTargetBinds(); | 2473 fStats.incRenderTargetBinds(); |
2262 fStats.incRenderTargetBinds(); | 2474 fStats.incRenderTargetBinds(); |
2263 GL_CALL(BindFramebuffer(GR_GL_READ_FRAMEBUFFER, rt->renderFBOID())); | 2475 GL_CALL(BindFramebuffer(GR_GL_READ_FRAMEBUFFER, rt->renderFBOID())); |
2264 GL_CALL(BindFramebuffer(GR_GL_DRAW_FRAMEBUFFER, rt->textureFBOID())) ; | 2476 GL_CALL(BindFramebuffer(GR_GL_DRAW_FRAMEBUFFER, rt->textureFBOID())) ; |
(...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3457 this->setVertexArrayID(gpu, 0); | 3669 this->setVertexArrayID(gpu, 0); |
3458 } | 3670 } |
3459 int attrCount = gpu->glCaps().maxVertexAttributes(); | 3671 int attrCount = gpu->glCaps().maxVertexAttributes(); |
3460 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 3672 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
3461 fDefaultVertexArrayAttribState.resize(attrCount); | 3673 fDefaultVertexArrayAttribState.resize(attrCount); |
3462 } | 3674 } |
3463 attribState = &fDefaultVertexArrayAttribState; | 3675 attribState = &fDefaultVertexArrayAttribState; |
3464 } | 3676 } |
3465 return attribState; | 3677 return attribState; |
3466 } | 3678 } |
OLD | NEW |