reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 1 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 2 | * Copyright 2011 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
jvanverth | 39edf76 | 2014-12-22 11:44:19 -0800 | [diff] [blame] | 8 | #ifndef GrGLGpu_DEFINED |
| 9 | #define GrGLGpu_DEFINED |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 10 | |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 11 | #include "GrGLContext.h" |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 12 | #include "GrGLIRect.h" |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 13 | #include "GrGLPathRendering.h" |
bsalomon@google.com | 5739d2c | 2012-05-31 15:07:19 +0000 | [diff] [blame] | 14 | #include "GrGLProgram.h" |
bsalomon | 37dd331 | 2014-11-03 08:47:23 -0800 | [diff] [blame] | 15 | #include "GrGLRenderTarget.h" |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 16 | #include "GrGLStencilAttachment.h" |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 17 | #include "GrGLTexture.h" |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 18 | #include "GrGLVertexArray.h" |
commit-bot@chromium.org | a0b4028 | 2013-09-18 13:00:55 +0000 | [diff] [blame] | 19 | #include "GrGpu.h" |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 20 | #include "GrMesh.h" |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 21 | #include "GrWindowRectsState.h" |
egdaniel | 080e673 | 2014-12-22 07:35:52 -0800 | [diff] [blame] | 22 | #include "GrXferProcessor.h" |
Ethan Nicholas | 1b9924f | 2016-12-15 15:28:42 -0500 | [diff] [blame] | 23 | #include "SkLRUCache.h" |
cblume | 55f2d2d | 2016-02-26 13:20:48 -0800 | [diff] [blame] | 24 | #include "SkTArray.h" |
commit-bot@chromium.org | a0b4028 | 2013-09-18 13:00:55 +0000 | [diff] [blame] | 25 | #include "SkTypes.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 26 | |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 27 | class GrGLBuffer; |
Robert Phillips | 5b5d84c | 2018-08-09 15:12:18 -0400 | [diff] [blame] | 28 | class GrGLGpuRTCommandBuffer; |
| 29 | class GrGLGpuTextureCommandBuffer; |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 30 | class GrPipeline; |
bsalomon | 7f9b2e4 | 2016-01-12 13:29:26 -0800 | [diff] [blame] | 31 | class GrSwizzle; |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 32 | |
djsollen | efe46d2 | 2016-04-29 06:41:35 -0700 | [diff] [blame] | 33 | #ifdef SK_DEBUG |
jvanverth@google.com | 9487877 | 2013-03-12 16:00:54 +0000 | [diff] [blame] | 34 | #define PROGRAM_CACHE_STATS |
| 35 | #endif |
| 36 | |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 37 | class GrGLGpu final : public GrGpu, private GrMesh::SendToGpuImpl { |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 38 | public: |
Robert Phillips | e42edcc | 2017-12-13 11:50:22 -0500 | [diff] [blame] | 39 | static sk_sp<GrGpu> Make(sk_sp<const GrGLInterface>, const GrContextOptions&, GrContext*); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 40 | ~GrGLGpu() override; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 41 | |
bsalomon | 6e2aad4 | 2016-04-01 11:54:31 -0700 | [diff] [blame] | 42 | void disconnect(DisconnectType) override; |
bsalomon | c8dc1f7 | 2014-08-21 13:02:13 -0700 | [diff] [blame] | 43 | |
bsalomon | 424cc26 | 2015-05-22 10:37:30 -0700 | [diff] [blame] | 44 | const GrGLContext& glContext() const { return *fGLContext; } |
commit-bot@chromium.org | c9424b8 | 2013-10-30 20:03:16 +0000 | [diff] [blame] | 45 | |
bsalomon | 424cc26 | 2015-05-22 10:37:30 -0700 | [diff] [blame] | 46 | const GrGLInterface* glInterface() const { return fGLContext->interface(); } |
| 47 | const GrGLContextInfo& ctxInfo() const { return *fGLContext; } |
| 48 | GrGLStandard glStandard() const { return fGLContext->standard(); } |
| 49 | GrGLVersion glVersion() const { return fGLContext->version(); } |
| 50 | GrGLSLGeneration glslGeneration() const { return fGLContext->glslGeneration(); } |
| 51 | const GrGLCaps& glCaps() const { return *fGLContext->caps(); } |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 52 | |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 53 | GrGLPathRendering* glPathRendering() { |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 54 | SkASSERT(glCaps().shaderCaps()->pathRenderingSupport()); |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 55 | return static_cast<GrGLPathRendering*>(pathRendering()); |
cdalton | c7103a1 | 2014-08-11 14:05:05 -0700 | [diff] [blame] | 56 | } |
| 57 | |
kkinnunen | cfe62e3 | 2015-07-01 02:58:50 -0700 | [diff] [blame] | 58 | // Used by GrGLProgram to configure OpenGL state. |
Brian Salomon | dc82994 | 2018-10-23 16:07:24 -0400 | [diff] [blame] | 59 | void bindTexture(int unitIdx, GrSamplerState samplerState, GrGLTexture* texture); |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 60 | |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 61 | // These functions should be used to bind GL objects. They track the GL state and skip redundant |
skia.committer@gmail.com | 754a3eb | 2013-03-08 07:01:25 +0000 | [diff] [blame] | 62 | // bindings. Making the equivalent glBind calls directly will confuse the state tracking. |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 63 | void bindVertexArray(GrGLuint id) { |
cdalton | e2e71c2 | 2016-04-07 18:13:29 -0700 | [diff] [blame] | 64 | fHWVertexArrayState.setVertexArrayID(this, id); |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | // These callbacks update state tracking when GL objects are deleted. They are called from |
| 68 | // GrGLResource onRelease functions. |
| 69 | void notifyVertexArrayDelete(GrGLuint id) { |
cdalton | e2e71c2 | 2016-04-07 18:13:29 -0700 | [diff] [blame] | 70 | fHWVertexArrayState.notifyVertexArrayDelete(id); |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 71 | } |
bsalomon@google.com | 880b8fc | 2013-02-19 20:17:28 +0000 | [diff] [blame] | 72 | |
cdalton | e2e71c2 | 2016-04-07 18:13:29 -0700 | [diff] [blame] | 73 | // Binds a buffer to the GL target corresponding to 'type', updates internal state tracking, and |
| 74 | // returns the GL target the buffer was bound to. |
| 75 | // When 'type' is kIndex_GrBufferType, this function will also implicitly bind the default VAO. |
| 76 | // If the caller wishes to bind an index buffer to a specific VAO, it can call glBind directly. |
Brian Salomon | ae64c19 | 2019-02-05 09:41:37 -0500 | [diff] [blame] | 77 | GrGLenum bindBuffer(GrGpuBufferType type, const GrBuffer*); |
joshualitt | 93316b9 | 2015-10-23 09:08:08 -0700 | [diff] [blame] | 78 | |
Greg Daniel | 500d58b | 2017-08-24 15:59:33 -0400 | [diff] [blame] | 79 | // The GrGLGpuRTCommandBuffer does not buffer up draws before submitting them to the gpu. |
egdaniel | 9cb6340 | 2016-06-23 08:37:05 -0700 | [diff] [blame] | 80 | // Thus this is the implementation of the draw call for the corresponding passthrough function |
Greg Daniel | 500d58b | 2017-08-24 15:59:33 -0400 | [diff] [blame] | 81 | // on GrGLRTGpuCommandBuffer. |
Robert Phillips | d0fe875 | 2019-01-31 14:13:59 -0500 | [diff] [blame] | 82 | void draw(GrRenderTarget*, GrSurfaceOrigin, |
| 83 | const GrPrimitiveProcessor&, |
Brian Salomon | ff168d9 | 2018-06-23 15:17:27 -0400 | [diff] [blame] | 84 | const GrPipeline&, |
Brian Salomon | 4934890 | 2018-06-26 09:12:38 -0400 | [diff] [blame] | 85 | const GrPipeline::FixedDynamicState*, |
| 86 | const GrPipeline::DynamicStateArrays*, |
Chris Dalton | 46983b7 | 2017-06-06 12:27:16 -0600 | [diff] [blame] | 87 | const GrMesh[], |
egdaniel | 9cb6340 | 2016-06-23 08:37:05 -0700 | [diff] [blame] | 88 | int meshCount); |
| 89 | |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 90 | // GrMesh::SendToGpuImpl methods. These issue the actual GL draw calls. |
| 91 | // Marked final as a hint to the compiler to not use virtual dispatch. |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 92 | void sendMeshToGpu(GrPrimitiveType, const GrBuffer* vertexBuffer, int vertexCount, |
| 93 | int baseVertex) final; |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 94 | |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 95 | void sendIndexedMeshToGpu(GrPrimitiveType, const GrBuffer* indexBuffer, int indexCount, |
| 96 | int baseIndex, uint16_t minIndexValue, uint16_t maxIndexValue, |
| 97 | const GrBuffer* vertexBuffer, int baseVertex, |
| 98 | GrPrimitiveRestart) final; |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 99 | |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 100 | void sendInstancedMeshToGpu(GrPrimitiveType, const GrBuffer* vertexBuffer, int vertexCount, |
| 101 | int baseVertex, const GrBuffer* instanceBuffer, int instanceCount, |
Chris Dalton | 1d61635 | 2017-05-31 12:51:23 -0600 | [diff] [blame] | 102 | int baseInstance) final; |
| 103 | |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 104 | void sendIndexedInstancedMeshToGpu(GrPrimitiveType, const GrBuffer* indexBuffer, int indexCount, |
| 105 | int baseIndex, const GrBuffer* vertexBuffer, int baseVertex, |
Chris Dalton | 1d61635 | 2017-05-31 12:51:23 -0600 | [diff] [blame] | 106 | const GrBuffer* instanceBuffer, int instanceCount, |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 107 | int baseInstance, GrPrimitiveRestart) final; |
Chris Dalton | 1d61635 | 2017-05-31 12:51:23 -0600 | [diff] [blame] | 108 | |
Greg Daniel | 500d58b | 2017-08-24 15:59:33 -0400 | [diff] [blame] | 109 | // The GrGLGpuRTCommandBuffer does not buffer up draws before submitting them to the gpu. |
egdaniel | 9cb6340 | 2016-06-23 08:37:05 -0700 | [diff] [blame] | 110 | // Thus this is the implementation of the clear call for the corresponding passthrough function |
Greg Daniel | 500d58b | 2017-08-24 15:59:33 -0400 | [diff] [blame] | 111 | // on GrGLGpuRTCommandBuffer. |
Brian Osman | 9a9baae | 2018-11-05 15:06:26 -0500 | [diff] [blame] | 112 | void clear(const GrFixedClip&, const SkPMColor4f&, GrRenderTarget*, GrSurfaceOrigin); |
egdaniel | 9cb6340 | 2016-06-23 08:37:05 -0700 | [diff] [blame] | 113 | |
Greg Daniel | 500d58b | 2017-08-24 15:59:33 -0400 | [diff] [blame] | 114 | // The GrGLGpuRTCommandBuffer does not buffer up draws before submitting them to the gpu. |
egdaniel | 9cb6340 | 2016-06-23 08:37:05 -0700 | [diff] [blame] | 115 | // Thus this is the implementation of the clearStencil call for the corresponding passthrough |
Greg Daniel | 500d58b | 2017-08-24 15:59:33 -0400 | [diff] [blame] | 116 | // function on GrGLGpuRTCommandBuffer. |
Robert Phillips | 19e51dc | 2017-08-09 09:30:51 -0400 | [diff] [blame] | 117 | void clearStencilClip(const GrFixedClip&, bool insideStencilMask, |
| 118 | GrRenderTarget*, GrSurfaceOrigin); |
egdaniel | 9cb6340 | 2016-06-23 08:37:05 -0700 | [diff] [blame] | 119 | |
Michael Ludwig | c39d0c8 | 2019-01-15 10:03:43 -0500 | [diff] [blame] | 120 | // FIXME (michaelludwig): Can this go away and just use clearStencilClip() + marking the |
| 121 | // stencil buffer as not dirty? |
Greg Daniel | cfa3935 | 2018-10-05 12:01:59 -0400 | [diff] [blame] | 122 | void clearStencil(GrRenderTarget*, int clearValue); |
egdaniel | ec00d94 | 2015-09-14 12:56:10 -0700 | [diff] [blame] | 123 | |
Robert Phillips | 5b5d84c | 2018-08-09 15:12:18 -0400 | [diff] [blame] | 124 | GrGpuRTCommandBuffer* getCommandBuffer( |
Ethan Nicholas | 56d19a5 | 2018-10-15 11:26:20 -0400 | [diff] [blame] | 125 | GrRenderTarget*, GrSurfaceOrigin, const SkRect&, |
Greg Daniel | 500d58b | 2017-08-24 15:59:33 -0400 | [diff] [blame] | 126 | const GrGpuRTCommandBuffer::LoadAndStoreInfo&, |
| 127 | const GrGpuRTCommandBuffer::StencilLoadAndStoreInfo&) override; |
| 128 | |
Robert Phillips | 5b5d84c | 2018-08-09 15:12:18 -0400 | [diff] [blame] | 129 | GrGpuTextureCommandBuffer* getCommandBuffer(GrTexture*, GrSurfaceOrigin) override; |
egdaniel | 066df7c | 2016-06-08 14:02:27 -0700 | [diff] [blame] | 130 | |
egdaniel | ec00d94 | 2015-09-14 12:56:10 -0700 | [diff] [blame] | 131 | void invalidateBoundRenderTarget() { |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 132 | fHWBoundRenderTargetUniqueID.makeInvalid(); |
egdaniel | ec00d94 | 2015-09-14 12:56:10 -0700 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | GrStencilAttachment* createStencilAttachmentForRenderTarget(const GrRenderTarget* rt, |
| 136 | int width, |
| 137 | int height) override; |
Brian Salomon | f865b05 | 2018-03-09 09:01:53 -0500 | [diff] [blame] | 138 | #if GR_TEST_UTILS |
Brian Salomon | 52e943a | 2018-03-13 09:32:39 -0400 | [diff] [blame] | 139 | GrBackendTexture createTestingOnlyBackendTexture(const void* pixels, int w, int h, |
Robert Phillips | 646f637 | 2018-09-25 09:31:10 -0400 | [diff] [blame] | 140 | GrColorType colorType, bool isRenderTarget, |
| 141 | GrMipMapped mipMapped, |
| 142 | size_t rowBytes = 0) override; |
Robert Phillips | d21b2a5 | 2017-12-12 13:01:25 -0500 | [diff] [blame] | 143 | bool isTestingOnlyBackendTexture(const GrBackendTexture&) const override; |
Brian Salomon | 26102cb | 2018-03-09 09:33:19 -0500 | [diff] [blame] | 144 | void deleteTestingOnlyBackendTexture(const GrBackendTexture&) override; |
jvanverth | 672bb7f | 2015-07-13 07:19:57 -0700 | [diff] [blame] | 145 | |
Brian Osman | 2d010b6 | 2018-08-09 10:55:09 -0400 | [diff] [blame] | 146 | GrBackendRenderTarget createTestingOnlyBackendRenderTarget(int w, int h, GrColorType) override; |
Brian Salomon | f865b05 | 2018-03-09 09:01:53 -0500 | [diff] [blame] | 147 | |
| 148 | void deleteTestingOnlyBackendRenderTarget(const GrBackendRenderTarget&) override; |
| 149 | |
| 150 | const GrGLContext* glContextForTesting() const override { return &this->glContext(); } |
| 151 | |
| 152 | void resetShaderCacheForTesting() const override { fProgramCache->abandon(); } |
joshualitt | 8fd844f | 2015-12-02 13:36:47 -0800 | [diff] [blame] | 153 | |
Greg Daniel | 26b50a4 | 2018-03-08 09:49:58 -0500 | [diff] [blame] | 154 | void testingOnly_flushGpuAndSync() override; |
Brian Salomon | f865b05 | 2018-03-09 09:01:53 -0500 | [diff] [blame] | 155 | #endif |
Greg Daniel | 26b50a4 | 2018-03-08 09:49:58 -0500 | [diff] [blame] | 156 | |
Robert Phillips | 5b5d84c | 2018-08-09 15:12:18 -0400 | [diff] [blame] | 157 | void submit(GrGpuCommandBuffer* buffer) override; |
| 158 | |
Greg Daniel | 6be3523 | 2017-03-01 17:01:09 -0500 | [diff] [blame] | 159 | GrFence SK_WARN_UNUSED_RESULT insertFence() override; |
| 160 | bool waitFence(GrFence, uint64_t timeout) override; |
jvanverth | 84741b3 | 2016-09-30 08:39:02 -0700 | [diff] [blame] | 161 | void deleteFence(GrFence) const override; |
| 162 | |
Greg Daniel | a5cb781 | 2017-06-16 09:45:32 -0400 | [diff] [blame] | 163 | sk_sp<GrSemaphore> SK_WARN_UNUSED_RESULT makeSemaphore(bool isOwned) override; |
Greg Daniel | 48661b8 | 2018-01-22 16:11:35 -0500 | [diff] [blame] | 164 | sk_sp<GrSemaphore> wrapBackendSemaphore(const GrBackendSemaphore& semaphore, |
| 165 | GrResourceProvider::SemaphoreWrapType wrapType, |
| 166 | GrWrapOwnership ownership) override; |
Greg Daniel | 858e12c | 2018-12-06 11:11:37 -0500 | [diff] [blame] | 167 | void insertSemaphore(sk_sp<GrSemaphore> semaphore) override; |
Greg Daniel | 48661b8 | 2018-01-22 16:11:35 -0500 | [diff] [blame] | 168 | void waitSemaphore(sk_sp<GrSemaphore> semaphore) override; |
Greg Daniel | 6be3523 | 2017-03-01 17:01:09 -0500 | [diff] [blame] | 169 | |
Brian Osman | 13dddce | 2017-05-09 13:19:50 -0400 | [diff] [blame] | 170 | sk_sp<GrSemaphore> prepareTextureForCrossContextUsage(GrTexture*) override; |
| 171 | |
Greg Daniel | 6be3523 | 2017-03-01 17:01:09 -0500 | [diff] [blame] | 172 | void deleteSync(GrGLsync) const; |
| 173 | |
Robert Phillips | 65a88fa | 2017-08-08 08:36:22 -0400 | [diff] [blame] | 174 | void insertEventMarker(const char*); |
| 175 | |
Adrienne Walker | 4ee8851 | 2018-05-17 11:37:14 -0700 | [diff] [blame] | 176 | void bindFramebuffer(GrGLenum fboTarget, GrGLuint fboid); |
| 177 | void deleteFramebuffer(GrGLuint fboid); |
Adrienne Walker | 3ed3399 | 2018-05-15 11:44:34 -0700 | [diff] [blame] | 178 | |
bsalomon@google.com | 02ddc8b | 2013-01-28 15:35:28 +0000 | [diff] [blame] | 179 | private: |
Brian Salomon | 8ab1cc4 | 2017-12-07 12:40:00 -0500 | [diff] [blame] | 180 | GrGLGpu(std::unique_ptr<GrGLContext>, GrContext*); |
bsalomon | 424cc26 | 2015-05-22 10:37:30 -0700 | [diff] [blame] | 181 | |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 182 | // GrGpu overrides |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 183 | void onResetContext(uint32_t resetBits) override; |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 184 | |
Brian Salomon | 1f05d45 | 2019-02-08 12:33:08 -0500 | [diff] [blame] | 185 | void onResetTextureBindings() override; |
| 186 | |
bsalomon | cb02b38 | 2015-08-12 11:14:50 -0700 | [diff] [blame] | 187 | void xferBarrier(GrRenderTarget*, GrXferBarrierType) override; |
| 188 | |
Robert Phillips | 67d52cf | 2017-06-05 13:38:13 -0400 | [diff] [blame] | 189 | sk_sp<GrTexture> onCreateTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, |
Brian Salomon | 58389b9 | 2018-03-07 13:01:25 -0500 | [diff] [blame] | 190 | const GrMipLevel texels[], int mipLevelCount) override; |
cblume | 55f2d2d | 2016-02-26 13:20:48 -0800 | [diff] [blame] | 191 | |
Brian Salomon | dbf7072 | 2019-02-07 11:31:24 -0500 | [diff] [blame] | 192 | sk_sp<GrGpuBuffer> onCreateBuffer(size_t size, GrGpuBufferType intendedType, GrAccessPattern, |
| 193 | const void* data) override; |
Greg Daniel | 7ef28f3 | 2017-04-20 16:41:55 +0000 | [diff] [blame] | 194 | |
Brian Salomon | fa2ebea | 2019-01-24 15:58:58 -0500 | [diff] [blame] | 195 | sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&, GrWrapOwnership, GrWrapCacheable, |
| 196 | GrIOType) override; |
Brian Salomon | aa6ca0a | 2019-01-24 16:03:07 -0500 | [diff] [blame] | 197 | sk_sp<GrTexture> onWrapRenderableBackendTexture(const GrBackendTexture&, int sampleCnt, |
| 198 | GrWrapOwnership, GrWrapCacheable) override; |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 199 | sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTarget&) override; |
Greg Daniel | 7ef28f3 | 2017-04-20 16:41:55 +0000 | [diff] [blame] | 200 | sk_sp<GrRenderTarget> onWrapBackendTextureAsRenderTarget(const GrBackendTexture&, |
Greg Daniel | 7ef28f3 | 2017-04-20 16:41:55 +0000 | [diff] [blame] | 201 | int sampleCnt) override; |
csmartdalton | e0d3629 | 2016-07-29 08:14:20 -0700 | [diff] [blame] | 202 | |
egdaniel | ff1d547 | 2015-09-10 08:37:20 -0700 | [diff] [blame] | 203 | // Given a GrPixelConfig return the index into the stencil format array on GrGLCaps to a |
bsalomon | 62a627b | 2015-12-17 09:50:47 -0800 | [diff] [blame] | 204 | // compatible stencil format, or negative if there is no compatible stencil format. |
egdaniel | ff1d547 | 2015-09-10 08:37:20 -0700 | [diff] [blame] | 205 | int getCompatibleStencilIndex(GrPixelConfig config); |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 206 | |
Adrienne Walker | ca0cdef | 2018-08-20 13:49:40 -0700 | [diff] [blame] | 207 | void onFBOChanged(); |
bsalomon | 7e68ab7 | 2016-04-13 14:29:25 -0700 | [diff] [blame] | 208 | |
erikchen | 9a1ed5d | 2016-02-10 16:32:34 -0800 | [diff] [blame] | 209 | // Returns whether the texture is successfully created. On success, the |
| 210 | // result is stored in |info|. |
cblume | 55f2d2d | 2016-02-26 13:20:48 -0800 | [diff] [blame] | 211 | // The texture is populated with |texels|, if it exists. |
erikchen | 9a1ed5d | 2016-02-10 16:32:34 -0800 | [diff] [blame] | 212 | // The texture parameters are cached in |initialTexParams|. |
Brian Salomon | 2a4f983 | 2018-03-03 22:43:43 -0500 | [diff] [blame] | 213 | bool createTextureImpl(const GrSurfaceDesc& desc, GrGLTextureInfo* info, bool renderTarget, |
Brian Salomon | dc82994 | 2018-10-23 16:07:24 -0400 | [diff] [blame] | 214 | GrGLTexture::SamplerParams* initialTexParams, const GrMipLevel texels[], |
Brian Salomon | 58389b9 | 2018-03-07 13:01:25 -0500 | [diff] [blame] | 215 | int mipLevelCount, GrMipMapsStatus* mipMapsStatus); |
erikchen | 9a1ed5d | 2016-02-10 16:32:34 -0800 | [diff] [blame] | 216 | |
bsalomon | 1aa2029 | 2016-01-22 08:16:09 -0800 | [diff] [blame] | 217 | // Checks whether glReadPixels can be called to get pixel values in readConfig from the |
| 218 | // render target. |
| 219 | bool readPixelsSupported(GrRenderTarget* target, GrPixelConfig readConfig); |
| 220 | |
| 221 | // Checks whether glReadPixels can be called to get pixel values in readConfig from a |
| 222 | // render target that has renderTargetConfig. This may have to create a temporary |
| 223 | // render target and thus is less preferable than the variant that takes a render target. |
| 224 | bool readPixelsSupported(GrPixelConfig renderTargetConfig, GrPixelConfig readConfig); |
| 225 | |
| 226 | // Checks whether glReadPixels can be called to get pixel values in readConfig from a |
| 227 | // render target that has the same config as surfaceForConfig. Calls one of the the two |
| 228 | // variations above, depending on whether the surface is a render target or not. |
| 229 | bool readPixelsSupported(GrSurface* surfaceForConfig, GrPixelConfig readConfig); |
| 230 | |
Brian Salomon | a694870 | 2018-06-01 15:33:20 -0400 | [diff] [blame] | 231 | bool onReadPixels(GrSurface*, int left, int top, int width, int height, GrColorType, |
| 232 | void* buffer, size_t rowBytes) override; |
bsalomon | d95263c | 2014-12-16 13:05:12 -0800 | [diff] [blame] | 233 | |
Brian Salomon | a9b04b9 | 2018-06-01 15:04:28 -0400 | [diff] [blame] | 234 | bool onWritePixels(GrSurface*, int left, int top, int width, int height, GrColorType, |
| 235 | const GrMipLevel texels[], int mipLevelCount) override; |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 236 | |
Brian Salomon | c320b15 | 2018-02-20 14:05:36 -0500 | [diff] [blame] | 237 | bool onTransferPixels(GrTexture*, int left, int top, int width, int height, GrColorType, |
Brian Salomon | dbf7072 | 2019-02-07 11:31:24 -0500 | [diff] [blame] | 238 | GrGpuBuffer* transferBuffer, size_t offset, size_t rowBytes) override; |
jvanverth | 17aa047 | 2016-01-05 10:41:27 -0800 | [diff] [blame] | 239 | |
Brian Osman | 9b56024 | 2017-09-05 15:34:52 -0400 | [diff] [blame] | 240 | // Before calling any variation of TexImage, TexSubImage, etc..., call this to ensure that the |
| 241 | // PIXEL_UNPACK_BUFFER is unbound. |
| 242 | void unbindCpuToGpuXferBuffer(); |
| 243 | |
Brian Salomon | 1fabd51 | 2018-02-09 09:54:25 -0500 | [diff] [blame] | 244 | void onResolveRenderTarget(GrRenderTarget* target) override; |
bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 245 | |
Brian Salomon | 930f939 | 2018-06-20 16:25:26 -0400 | [diff] [blame] | 246 | bool onRegenerateMipMapLevels(GrTexture*) override; |
| 247 | |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 248 | bool onCopySurface(GrSurface* dst, GrSurfaceOrigin dstOrigin, |
| 249 | GrSurface* src, GrSurfaceOrigin srcOrigin, |
Greg Daniel | 55fa647 | 2018-03-16 16:13:10 -0400 | [diff] [blame] | 250 | const SkIRect& srcRect, const SkIPoint& dstPoint, |
| 251 | bool canDiscardOutsideDstRect) override; |
joshualitt | 1cbdcde | 2015-08-21 11:53:29 -0700 | [diff] [blame] | 252 | |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 253 | // binds texture unit in GL |
bsalomon@google.com | 8531c1c | 2011-01-13 19:52:45 +0000 | [diff] [blame] | 254 | void setTextureUnit(int unitIdx); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 255 | |
Brian Salomon | f723264 | 2018-09-19 08:58:08 -0400 | [diff] [blame] | 256 | /** |
| 257 | * primitiveProcessorTextures must contain GrPrimitiveProcessor::numTextureSamplers() * |
| 258 | * numPrimitiveProcessorTextureSets entries. |
| 259 | */ |
| 260 | void resolveAndGenerateMipMapsForProcessorTextures( |
Brian Salomon | 7eae3e0 | 2018-08-07 14:02:38 +0000 | [diff] [blame] | 261 | const GrPrimitiveProcessor&, const GrPipeline&, |
Brian Salomon | f723264 | 2018-09-19 08:58:08 -0400 | [diff] [blame] | 262 | const GrTextureProxy* const primitiveProcessorTextures[], |
| 263 | int numPrimitiveProcessorTextureSets); |
Brian Salomon | dfec99f | 2018-08-02 10:40:05 -0400 | [diff] [blame] | 264 | |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 265 | // Flushes state from GrPipeline to GL. Returns false if the state couldn't be set. |
bsalomon | 2eda5b3 | 2016-09-21 10:53:24 -0700 | [diff] [blame] | 266 | // willDrawPoints must be true if point primitives will be rendered after setting the GL state. |
Brian Salomon | f723264 | 2018-09-19 08:58:08 -0400 | [diff] [blame] | 267 | // If DynamicStateArrays is not null then dynamicStateArraysLength is the number of dynamic |
| 268 | // state entries in each array. |
Robert Phillips | d0fe875 | 2019-01-31 14:13:59 -0500 | [diff] [blame] | 269 | bool flushGLState(GrRenderTarget*, GrSurfaceOrigin, const GrPrimitiveProcessor&, |
| 270 | const GrPipeline&, const GrPipeline::FixedDynamicState*, |
| 271 | const GrPipeline::DynamicStateArrays*, int dynamicStateArraysLength, |
| 272 | bool willDrawPoints); |
bsalomon | d95263c | 2014-12-16 13:05:12 -0800 | [diff] [blame] | 273 | |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 274 | void flushProgram(sk_sp<GrGLProgram>); |
| 275 | |
| 276 | // Version for programs that aren't GrGLProgram. |
| 277 | void flushProgram(GrGLuint); |
| 278 | |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 279 | // Sets up vertex/instance attribute pointers and strides. |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 280 | void setupGeometry(const GrBuffer* indexBuffer, |
Chris Dalton | ff92650 | 2017-05-03 14:36:54 -0400 | [diff] [blame] | 281 | const GrBuffer* vertexBuffer, |
Chris Dalton | 1d61635 | 2017-05-31 12:51:23 -0600 | [diff] [blame] | 282 | int baseVertex, |
| 283 | const GrBuffer* instanceBuffer, |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 284 | int baseInstance, |
| 285 | GrPrimitiveRestart); |
bsalomon@google.com | 7acdb8e | 2011-02-11 14:07:02 +0000 | [diff] [blame] | 286 | |
bsalomon | 7f9b2e4 | 2016-01-12 13:29:26 -0800 | [diff] [blame] | 287 | void flushBlend(const GrXferProcessor::BlendInfo& blendInfo, const GrSwizzle&); |
bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 288 | |
Greg Daniel | 5131678 | 2017-08-02 15:10:09 +0000 | [diff] [blame] | 289 | void onFinishFlush(bool insertedSemaphores) override; |
| 290 | |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 291 | bool copySurfaceAsDraw(GrSurface* dst, GrSurfaceOrigin dstOrigin, |
| 292 | GrSurface* src, GrSurfaceOrigin srcOrigin, |
| 293 | const SkIRect& srcRect, const SkIPoint& dstPoint); |
| 294 | void copySurfaceAsCopyTexSubImage(GrSurface* dst, GrSurfaceOrigin dstOrigin, |
| 295 | GrSurface* src, GrSurfaceOrigin srcOrigin, |
| 296 | const SkIRect& srcRect, const SkIPoint& dstPoint); |
| 297 | bool copySurfaceAsBlitFramebuffer(GrSurface* dst, GrSurfaceOrigin dstOrigin, |
| 298 | GrSurface* src, GrSurfaceOrigin srcOrigin, |
| 299 | const SkIRect& srcRect, const SkIPoint& dstPoint); |
bsalomon | 6df8640 | 2015-06-01 10:41:49 -0700 | [diff] [blame] | 300 | |
bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 301 | static bool BlendCoeffReferencesConstant(GrBlendCoeff coeff); |
bsalomon@google.com | 080773c | 2011-03-15 19:09:25 +0000 | [diff] [blame] | 302 | |
commit-bot@chromium.org | a0b4028 | 2013-09-18 13:00:55 +0000 | [diff] [blame] | 303 | class ProgramCache : public ::SkNoncopyable { |
bsalomon@google.com | c1d2a58 | 2012-06-01 15:08:19 +0000 | [diff] [blame] | 304 | public: |
bsalomon | 861e103 | 2014-12-16 07:33:49 -0800 | [diff] [blame] | 305 | ProgramCache(GrGLGpu* gpu); |
jvanverth@google.com | 9487877 | 2013-03-12 16:00:54 +0000 | [diff] [blame] | 306 | ~ProgramCache(); |
bsalomon@google.com | 5739d2c | 2012-05-31 15:07:19 +0000 | [diff] [blame] | 307 | |
bsalomon@google.com | c1d2a58 | 2012-06-01 15:08:19 +0000 | [diff] [blame] | 308 | void abandon(); |
Robert Phillips | d0fe875 | 2019-01-31 14:13:59 -0500 | [diff] [blame] | 309 | GrGLProgram* refProgram(GrGLGpu*, GrRenderTarget*, GrSurfaceOrigin, |
| 310 | const GrPrimitiveProcessor&, |
Greg Daniel | 9a51a86 | 2018-11-30 10:18:14 -0500 | [diff] [blame] | 311 | const GrTextureProxy* const primProcProxies[], |
| 312 | const GrPipeline&, bool hasPointSize); |
bsalomon@google.com | 2db3ded | 2013-05-22 14:34:04 +0000 | [diff] [blame] | 313 | |
bsalomon@google.com | c1d2a58 | 2012-06-01 15:08:19 +0000 | [diff] [blame] | 314 | private: |
Ethan Nicholas | 1b9924f | 2016-12-15 15:28:42 -0500 | [diff] [blame] | 315 | // We may actually have kMaxEntries+1 shaders in the GL context because we create a new |
| 316 | // shader before evicting from the cache. |
| 317 | static const int kMaxEntries = 128; |
bsalomon@google.com | c1d2a58 | 2012-06-01 15:08:19 +0000 | [diff] [blame] | 318 | |
bsalomon@google.com | 2db3ded | 2013-05-22 14:34:04 +0000 | [diff] [blame] | 319 | struct Entry; |
bsalomon@google.com | c1d2a58 | 2012-06-01 15:08:19 +0000 | [diff] [blame] | 320 | |
bsalomon@google.com | 2db3ded | 2013-05-22 14:34:04 +0000 | [diff] [blame] | 321 | // binary search for entry matching desc. returns index into fEntries that matches desc or ~ |
| 322 | // of the index of where it should be inserted. |
joshualitt | 79f8fae | 2014-10-28 17:59:26 -0700 | [diff] [blame] | 323 | int search(const GrProgramDesc& desc) const; |
bsalomon@google.com | c1d2a58 | 2012-06-01 15:08:19 +0000 | [diff] [blame] | 324 | |
Ethan Nicholas | 1b9924f | 2016-12-15 15:28:42 -0500 | [diff] [blame] | 325 | struct DescHash { |
| 326 | uint32_t operator()(const GrProgramDesc& desc) const { |
| 327 | return SkOpts::hash_fn(desc.asKey(), desc.keyLength(), 0); |
| 328 | } |
| 329 | }; |
bsalomon@google.com | c1d2a58 | 2012-06-01 15:08:19 +0000 | [diff] [blame] | 330 | |
Ethan Nicholas | 1b9924f | 2016-12-15 15:28:42 -0500 | [diff] [blame] | 331 | SkLRUCache<GrProgramDesc, std::unique_ptr<Entry>, DescHash> fMap; |
| 332 | |
bsalomon | 861e103 | 2014-12-16 07:33:49 -0800 | [diff] [blame] | 333 | GrGLGpu* fGpu; |
jvanverth@google.com | 9487877 | 2013-03-12 16:00:54 +0000 | [diff] [blame] | 334 | #ifdef PROGRAM_CACHE_STATS |
| 335 | int fTotalRequests; |
| 336 | int fCacheMisses; |
bsalomon@google.com | 2db3ded | 2013-05-22 14:34:04 +0000 | [diff] [blame] | 337 | int fHashMisses; // cache hit but hash table missed |
jvanverth@google.com | 9487877 | 2013-03-12 16:00:54 +0000 | [diff] [blame] | 338 | #endif |
bsalomon@google.com | c1d2a58 | 2012-06-01 15:08:19 +0000 | [diff] [blame] | 339 | }; |
bsalomon@google.com | 5739d2c | 2012-05-31 15:07:19 +0000 | [diff] [blame] | 340 | |
egdaniel | 080e673 | 2014-12-22 07:35:52 -0800 | [diff] [blame] | 341 | void flushColorWrite(bool writeColor); |
Brian Salomon | 805cc7a | 2019-01-28 09:52:34 -0500 | [diff] [blame] | 342 | void flushClearColor(GrGLfloat r, GrGLfloat g, GrGLfloat b, GrGLfloat a); |
bsalomon@google.com | c96cb3a | 2012-06-04 19:31:00 +0000 | [diff] [blame] | 343 | |
Brian Salomon | d818ebf | 2018-07-02 14:08:49 +0000 | [diff] [blame] | 344 | // flushes the scissor. see the note on flushBoundTextureAndParams about |
| 345 | // flushing the scissor after that function is called. |
| 346 | void flushScissor(const GrScissorState&, |
| 347 | const GrGLIRect& rtViewport, |
| 348 | GrSurfaceOrigin rtOrigin); |
| 349 | |
| 350 | // disables the scissor |
| 351 | void disableScissor(); |
bsalomon@google.com | a320194 | 2012-06-21 19:58:20 +0000 | [diff] [blame] | 352 | |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 353 | void flushWindowRectangles(const GrWindowRectsState&, const GrGLRenderTarget*, GrSurfaceOrigin); |
csmartdalton | 28341fa | 2016-08-17 10:00:21 -0700 | [diff] [blame] | 354 | void disableWindowRectangles(); |
| 355 | |
Brian Salomon | d978b90 | 2019-02-07 15:09:18 -0500 | [diff] [blame] | 356 | int numTextureUnits() const { return this->caps()->shaderCaps()->maxFragmentSamplers(); } |
| 357 | |
| 358 | // Binds a texture to a target on the "scratch" texture unit to use for texture operations |
| 359 | // other than usual draw flow (i.e. a GrGLProgram derived from a GrPipeline used to draw |
| 360 | // GrMesh). It ensures that such operations don't negatively interact with draws. |
| 361 | // The active texture unit and the binding for 'target' will change. |
| 362 | void bindTextureToScratchUnit(GrGLenum target, GrGLint textureID); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 363 | |
Brian Salomon | 1fabd51 | 2018-02-09 09:54:25 -0500 | [diff] [blame] | 364 | // The passed bounds contains the render target's color values that will subsequently be |
| 365 | // written. |
Chris Dalton | c8ece3d | 2018-07-30 15:03:45 -0600 | [diff] [blame] | 366 | void flushRenderTarget(GrGLRenderTarget*, GrSurfaceOrigin, const SkIRect& bounds); |
| 367 | // This version has an implicit bounds of the entire render target. |
| 368 | void flushRenderTarget(GrGLRenderTarget*); |
Brian Salomon | 1fabd51 | 2018-02-09 09:54:25 -0500 | [diff] [blame] | 369 | // This version can be used when the render target's colors will not be written. |
Brian Osman | 9aa30c6 | 2018-07-02 15:21:46 -0400 | [diff] [blame] | 370 | void flushRenderTargetNoColorWrites(GrGLRenderTarget*); |
bsalomon | 083617b | 2016-02-12 12:10:14 -0800 | [diff] [blame] | 371 | |
| 372 | // Need not be called if flushRenderTarget is used. |
| 373 | void flushViewport(const GrGLIRect&); |
bsalomon | b0bd4f6 | 2014-09-03 07:19:50 -0700 | [diff] [blame] | 374 | |
bsalomon | 3e79124 | 2014-12-17 13:43:13 -0800 | [diff] [blame] | 375 | void flushStencil(const GrStencilSettings&); |
csmartdalton | c7d8533 | 2016-10-26 10:13:46 -0700 | [diff] [blame] | 376 | void disableStencil(); |
bsalomon | 083617b | 2016-02-12 12:10:14 -0800 | [diff] [blame] | 377 | |
| 378 | // rt is used only if useHWAA is true. |
cdalton | af8bc7d | 2016-02-05 09:35:20 -0800 | [diff] [blame] | 379 | void flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool stencilEnabled); |
bsalomon@google.com | 0650e81 | 2011-04-08 18:07:53 +0000 | [diff] [blame] | 380 | |
brianosman | 33f6b3f | 2016-06-02 05:49:21 -0700 | [diff] [blame] | 381 | void flushFramebufferSRGB(bool enable); |
| 382 | |
bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 383 | // helper for onCreateTexture and writeTexturePixels |
jvanverth | 17aa047 | 2016-01-05 10:41:27 -0800 | [diff] [blame] | 384 | enum UploadType { |
Jim Van Verth | 2e5eaf0 | 2017-06-21 15:55:46 -0400 | [diff] [blame] | 385 | kNewTexture_UploadType, // we are creating a new texture |
| 386 | kWrite_UploadType, // we are using TexSubImage2D to copy data to an existing texture |
jvanverth | 17aa047 | 2016-01-05 10:41:27 -0800 | [diff] [blame] | 387 | }; |
Brian Salomon | a9b04b9 | 2018-06-01 15:04:28 -0400 | [diff] [blame] | 388 | bool uploadTexData(GrPixelConfig texConfig, int texWidth, int texHeight, GrGLenum target, |
| 389 | UploadType uploadType, int left, int top, int width, int height, |
| 390 | GrPixelConfig dataConfig, const GrMipLevel texels[], int mipLevelCount, |
Greg Daniel | 0fc4d2d | 2017-10-12 11:23:36 -0400 | [diff] [blame] | 391 | GrMipMapsStatus* mipMapsStatus = nullptr); |
bsalomon@google.com | 0650e81 | 2011-04-08 18:07:53 +0000 | [diff] [blame] | 392 | |
Jim Van Verth | 1676cb9 | 2019-01-15 13:24:45 -0500 | [diff] [blame] | 393 | // helper for onCreateCompressedTexture. Compressed textures are read-only so we |
| 394 | // only use this to populate a new texture. |
| 395 | bool uploadCompressedTexData(GrPixelConfig texConfig, int texWidth, int texHeight, |
| 396 | GrGLenum target, GrPixelConfig dataConfig, |
| 397 | const GrMipLevel texels[], int mipLevelCount, |
| 398 | GrMipMapsStatus* mipMapsStatus = nullptr); |
| 399 | |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 400 | bool createRenderTargetObjects(const GrSurfaceDesc&, const GrGLTextureInfo& texInfo, |
| 401 | GrGLRenderTarget::IDDesc*); |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 402 | |
egdaniel | d803f27 | 2015-03-18 13:01:52 -0700 | [diff] [blame] | 403 | enum TempFBOTarget { |
| 404 | kSrc_TempFBOTarget, |
| 405 | kDst_TempFBOTarget |
| 406 | }; |
egdaniel | 0f5f967 | 2015-02-03 11:10:51 -0800 | [diff] [blame] | 407 | |
Brian Salomon | d17b4a6 | 2017-05-23 16:53:47 -0400 | [diff] [blame] | 408 | // Binds a surface as a FBO for copying, reading, or clearing. If the surface already owns an |
| 409 | // FBO ID then that ID is bound. If not the surface is temporarily bound to a FBO and that FBO |
| 410 | // is bound. This must be paired with a call to unbindSurfaceFBOForPixelOps(). |
Brian Salomon | 71d9d84 | 2016-11-03 13:42:00 -0400 | [diff] [blame] | 411 | void bindSurfaceFBOForPixelOps(GrSurface* surface, GrGLenum fboTarget, GrGLIRect* viewport, |
| 412 | TempFBOTarget tempFBOTarget); |
egdaniel | 0f5f967 | 2015-02-03 11:10:51 -0800 | [diff] [blame] | 413 | |
Brian Salomon | 71d9d84 | 2016-11-03 13:42:00 -0400 | [diff] [blame] | 414 | // Must be called if bindSurfaceFBOForPixelOps was used to bind a surface for copying. |
| 415 | void unbindTextureFBOForPixelOps(GrGLenum fboTarget, GrSurface* surface); |
robertphillips | 754f4e9 | 2014-09-18 13:52:08 -0700 | [diff] [blame] | 416 | |
Kevin Lubick | f4def34 | 2018-10-04 12:52:50 -0400 | [diff] [blame] | 417 | #ifdef SK_ENABLE_DUMP_GPU |
Brian Osman | 71a1889 | 2017-08-10 10:23:25 -0400 | [diff] [blame] | 418 | void onDumpJSON(SkJSONWriter*) const override; |
Kevin Lubick | f4def34 | 2018-10-04 12:52:50 -0400 | [diff] [blame] | 419 | #endif |
Brian Osman | 71a1889 | 2017-08-10 10:23:25 -0400 | [diff] [blame] | 420 | |
Brian Salomon | bf7b620 | 2016-11-11 16:08:03 -0500 | [diff] [blame] | 421 | bool createCopyProgram(GrTexture* srcTexture); |
brianosman | 33f6b3f | 2016-06-02 05:49:21 -0700 | [diff] [blame] | 422 | bool createMipmapProgram(int progIdx); |
ethannicholas | 2279325 | 2016-01-30 09:59:10 -0800 | [diff] [blame] | 423 | |
Brian Salomon | 8ab1cc4 | 2017-12-07 12:40:00 -0500 | [diff] [blame] | 424 | std::unique_ptr<GrGLContext> fGLContext; |
| 425 | |
bsalomon@google.com | 5739d2c | 2012-05-31 15:07:19 +0000 | [diff] [blame] | 426 | // GL program-related state |
| 427 | ProgramCache* fProgramCache; |
bsalomon@google.com | 4920939 | 2012-06-05 15:13:46 +0000 | [diff] [blame] | 428 | |
| 429 | /////////////////////////////////////////////////////////////////////////// |
| 430 | ///@name Caching of GL State |
| 431 | ///@{ |
| 432 | int fHWActiveTextureUnitIdx; |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 433 | |
bsalomon@google.com | 5739d2c | 2012-05-31 15:07:19 +0000 | [diff] [blame] | 434 | GrGLuint fHWProgramID; |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 435 | sk_sp<GrGLProgram> fHWProgram; |
bsalomon@google.com | 9120748 | 2013-02-12 21:45:24 +0000 | [diff] [blame] | 436 | |
bsalomon@google.com | 4920939 | 2012-06-05 15:13:46 +0000 | [diff] [blame] | 437 | enum TriState { |
| 438 | kNo_TriState, |
| 439 | kYes_TriState, |
| 440 | kUnknown_TriState |
| 441 | }; |
| 442 | |
egdaniel | d803f27 | 2015-03-18 13:01:52 -0700 | [diff] [blame] | 443 | GrGLuint fTempSrcFBOID; |
| 444 | GrGLuint fTempDstFBOID; |
| 445 | |
| 446 | GrGLuint fStencilClearFBOID; |
bsalomon | dd3143b | 2015-02-23 09:27:45 -0800 | [diff] [blame] | 447 | |
bsalomon@google.com | a320194 | 2012-06-21 19:58:20 +0000 | [diff] [blame] | 448 | // last scissor / viewport scissor state seen by the GL. |
| 449 | struct { |
| 450 | TriState fEnabled; |
| 451 | GrGLIRect fRect; |
| 452 | void invalidate() { |
| 453 | fEnabled = kUnknown_TriState; |
| 454 | fRect.invalidate(); |
| 455 | } |
| 456 | } fHWScissorSettings; |
| 457 | |
csmartdalton | 28341fa | 2016-08-17 10:00:21 -0700 | [diff] [blame] | 458 | class { |
| 459 | public: |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 460 | bool valid() const { return kInvalidSurfaceOrigin != fRTOrigin; } |
| 461 | void invalidate() { fRTOrigin = kInvalidSurfaceOrigin; } |
| 462 | bool knownDisabled() const { return this->valid() && !fWindowState.enabled(); } |
mtklein | 8b4a202 | 2016-09-26 08:44:47 -0700 | [diff] [blame] | 463 | void setDisabled() { |
Robert Phillips | fb4a20c | 2017-08-29 14:46:43 -0400 | [diff] [blame] | 464 | fRTOrigin = kTopLeft_GrSurfaceOrigin; |
mtklein | 8b4a202 | 2016-09-26 08:44:47 -0700 | [diff] [blame] | 465 | fWindowState.setDisabled(); |
| 466 | } |
csmartdalton | 28341fa | 2016-08-17 10:00:21 -0700 | [diff] [blame] | 467 | |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 468 | void set(GrSurfaceOrigin rtOrigin, const GrGLIRect& viewport, |
| 469 | const GrWindowRectsState& windowState) { |
| 470 | fRTOrigin = rtOrigin; |
| 471 | fViewport = viewport; |
| 472 | fWindowState = windowState; |
csmartdalton | 28341fa | 2016-08-17 10:00:21 -0700 | [diff] [blame] | 473 | } |
csmartdalton | 28341fa | 2016-08-17 10:00:21 -0700 | [diff] [blame] | 474 | |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 475 | bool knownEqualTo(GrSurfaceOrigin rtOrigin, const GrGLIRect& viewport, |
| 476 | const GrWindowRectsState& windowState) const { |
csmartdalton | 28341fa | 2016-08-17 10:00:21 -0700 | [diff] [blame] | 477 | if (!this->valid()) { |
| 478 | return false; |
| 479 | } |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 480 | if (fWindowState.numWindows() && (fRTOrigin != rtOrigin || fViewport != viewport)) { |
csmartdalton | 28341fa | 2016-08-17 10:00:21 -0700 | [diff] [blame] | 481 | return false; |
| 482 | } |
Brian Salomon | 9a76772 | 2017-03-13 17:57:28 -0400 | [diff] [blame] | 483 | return fWindowState == windowState; |
csmartdalton | 28341fa | 2016-08-17 10:00:21 -0700 | [diff] [blame] | 484 | } |
| 485 | |
| 486 | private: |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 487 | enum { kInvalidSurfaceOrigin = -1 }; |
csmartdalton | 28341fa | 2016-08-17 10:00:21 -0700 | [diff] [blame] | 488 | |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 489 | int fRTOrigin; |
csmartdalton | 28341fa | 2016-08-17 10:00:21 -0700 | [diff] [blame] | 490 | GrGLIRect fViewport; |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 491 | GrWindowRectsState fWindowState; |
| 492 | } fHWWindowRectsState; |
csmartdalton | 28341fa | 2016-08-17 10:00:21 -0700 | [diff] [blame] | 493 | |
bsalomon | 424cc26 | 2015-05-22 10:37:30 -0700 | [diff] [blame] | 494 | GrGLIRect fHWViewport; |
bsalomon@google.com | a320194 | 2012-06-21 19:58:20 +0000 | [diff] [blame] | 495 | |
bsalomon@google.com | 880b8fc | 2013-02-19 20:17:28 +0000 | [diff] [blame] | 496 | /** |
cdalton | e2e71c2 | 2016-04-07 18:13:29 -0700 | [diff] [blame] | 497 | * Tracks vertex attrib array state. |
bsalomon@google.com | 880b8fc | 2013-02-19 20:17:28 +0000 | [diff] [blame] | 498 | */ |
cdalton | e2e71c2 | 2016-04-07 18:13:29 -0700 | [diff] [blame] | 499 | class HWVertexArrayState { |
bsalomon@google.com | 880b8fc | 2013-02-19 20:17:28 +0000 | [diff] [blame] | 500 | public: |
cdalton | e2e71c2 | 2016-04-07 18:13:29 -0700 | [diff] [blame] | 501 | HWVertexArrayState() : fCoreProfileVertexArray(nullptr) { this->invalidate(); } |
skia.committer@gmail.com | 754a3eb | 2013-03-08 07:01:25 +0000 | [diff] [blame] | 502 | |
cdalton | e2e71c2 | 2016-04-07 18:13:29 -0700 | [diff] [blame] | 503 | ~HWVertexArrayState() { delete fCoreProfileVertexArray; } |
bsalomon@google.com | 880b8fc | 2013-02-19 20:17:28 +0000 | [diff] [blame] | 504 | |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 505 | void invalidate() { |
| 506 | fBoundVertexArrayIDIsValid = false; |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 507 | fDefaultVertexArrayAttribState.invalidate(); |
cdalton | e2e71c2 | 2016-04-07 18:13:29 -0700 | [diff] [blame] | 508 | if (fCoreProfileVertexArray) { |
| 509 | fCoreProfileVertexArray->invalidateCachedState(); |
commit-bot@chromium.org | ce6da4d | 2013-09-09 14:55:37 +0000 | [diff] [blame] | 510 | } |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 511 | } |
| 512 | |
| 513 | void notifyVertexArrayDelete(GrGLuint id) { |
| 514 | if (fBoundVertexArrayIDIsValid && fBoundVertexArrayID == id) { |
| 515 | // Does implicit bind to 0 |
| 516 | fBoundVertexArrayID = 0; |
bsalomon@google.com | 880b8fc | 2013-02-19 20:17:28 +0000 | [diff] [blame] | 517 | } |
| 518 | } |
| 519 | |
bsalomon | 861e103 | 2014-12-16 07:33:49 -0800 | [diff] [blame] | 520 | void setVertexArrayID(GrGLGpu* gpu, GrGLuint arrayID) { |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 521 | if (!gpu->glCaps().vertexArrayObjectSupport()) { |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 522 | SkASSERT(0 == arrayID); |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 523 | return; |
| 524 | } |
| 525 | if (!fBoundVertexArrayIDIsValid || arrayID != fBoundVertexArrayID) { |
| 526 | GR_GL_CALL(gpu->glInterface(), BindVertexArray(arrayID)); |
| 527 | fBoundVertexArrayIDIsValid = true; |
| 528 | fBoundVertexArrayID = arrayID; |
bsalomon@google.com | 880b8fc | 2013-02-19 20:17:28 +0000 | [diff] [blame] | 529 | } |
| 530 | } |
| 531 | |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 532 | /** |
cdalton | e2e71c2 | 2016-04-07 18:13:29 -0700 | [diff] [blame] | 533 | * Binds the vertex array that should be used for internal draws, and returns its attrib |
| 534 | * state. This binds the default VAO (ID=zero) unless we are on a core profile, in which |
| 535 | * case we use a dummy array instead. |
| 536 | * |
| 537 | * If an index buffer is privided, it will be bound to the vertex array. Otherwise the |
| 538 | * index buffer binding will be left unchanged. |
| 539 | * |
| 540 | * The returned GrGLAttribArrayState should be used to set vertex attribute arrays. |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 541 | */ |
csmartdalton | 485a120 | 2016-07-13 10:16:32 -0700 | [diff] [blame] | 542 | GrGLAttribArrayState* bindInternalVertexArray(GrGLGpu*, const GrBuffer* ibuff = nullptr); |
bsalomon | 6df8640 | 2015-06-01 10:41:49 -0700 | [diff] [blame] | 543 | |
bsalomon@google.com | 880b8fc | 2013-02-19 20:17:28 +0000 | [diff] [blame] | 544 | private: |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 545 | GrGLuint fBoundVertexArrayID; |
| 546 | bool fBoundVertexArrayIDIsValid; |
mtklein | 044d3c1 | 2016-04-06 18:24:34 -0700 | [diff] [blame] | 547 | |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 548 | // We return a non-const pointer to this from bindArrayAndBuffersToDraw when vertex array 0 |
jvanverth | 39edf76 | 2014-12-22 11:44:19 -0800 | [diff] [blame] | 549 | // is bound. However, this class is internal to GrGLGpu and this object never leaks out of |
| 550 | // GrGLGpu. |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 551 | GrGLAttribArrayState fDefaultVertexArrayAttribState; |
bsalomon@google.com | 880b8fc | 2013-02-19 20:17:28 +0000 | [diff] [blame] | 552 | |
cdalton | e2e71c2 | 2016-04-07 18:13:29 -0700 | [diff] [blame] | 553 | // This is used when we're using a core profile. |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 554 | GrGLVertexArray* fCoreProfileVertexArray; |
| 555 | } fHWVertexArrayState; |
bsalomon@google.com | 5782d71 | 2011-01-21 21:03:59 +0000 | [diff] [blame] | 556 | |
cdalton | e2e71c2 | 2016-04-07 18:13:29 -0700 | [diff] [blame] | 557 | struct { |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 558 | GrGLenum fGLTarget; |
| 559 | GrGpuResource::UniqueID fBoundBufferUniqueID; |
| 560 | bool fBufferZeroKnownBound; |
cdalton | e2e71c2 | 2016-04-07 18:13:29 -0700 | [diff] [blame] | 561 | |
| 562 | void invalidate() { |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 563 | fBoundBufferUniqueID.makeInvalid(); |
cdalton | e2e71c2 | 2016-04-07 18:13:29 -0700 | [diff] [blame] | 564 | fBufferZeroKnownBound = false; |
| 565 | } |
Brian Salomon | ae64c19 | 2019-02-05 09:41:37 -0500 | [diff] [blame] | 566 | } fHWBufferState[kGrGpuBufferTypeCount]; |
| 567 | |
| 568 | auto* hwBufferState(GrGpuBufferType type) { |
| 569 | unsigned typeAsUInt = static_cast<unsigned>(type); |
| 570 | SkASSERT(typeAsUInt < SK_ARRAY_COUNT(fHWBufferState)); |
| 571 | return &fHWBufferState[typeAsUInt]; |
| 572 | } |
cdalton | c161310 | 2016-03-16 07:48:20 -0700 | [diff] [blame] | 573 | |
bsalomon@google.com | a4d8fc2 | 2012-05-21 13:21:46 +0000 | [diff] [blame] | 574 | struct { |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 575 | GrBlendEquation fEquation; |
bsalomon@google.com | a4d8fc2 | 2012-05-21 13:21:46 +0000 | [diff] [blame] | 576 | GrBlendCoeff fSrcCoeff; |
| 577 | GrBlendCoeff fDstCoeff; |
Brian Osman | 422f95b | 2018-11-05 16:49:04 -0500 | [diff] [blame] | 578 | SkPMColor4f fConstColor; |
bsalomon@google.com | a4d8fc2 | 2012-05-21 13:21:46 +0000 | [diff] [blame] | 579 | bool fConstColorValid; |
| 580 | TriState fEnabled; |
| 581 | |
| 582 | void invalidate() { |
Mike Klein | 3674336 | 2018-11-06 08:23:30 -0500 | [diff] [blame] | 583 | fEquation = kIllegal_GrBlendEquation; |
| 584 | fSrcCoeff = kIllegal_GrBlendCoeff; |
| 585 | fDstCoeff = kIllegal_GrBlendCoeff; |
bsalomon@google.com | a4d8fc2 | 2012-05-21 13:21:46 +0000 | [diff] [blame] | 586 | fConstColorValid = false; |
| 587 | fEnabled = kUnknown_TriState; |
| 588 | } |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 589 | } fHWBlendState; |
bsalomon@google.com | a4d8fc2 | 2012-05-21 13:21:46 +0000 | [diff] [blame] | 590 | |
Robert Phillips | 5b5d84c | 2018-08-09 15:12:18 -0400 | [diff] [blame] | 591 | TriState fMSAAEnabled; |
bsalomon | 54c6fe8 | 2015-12-16 11:51:22 -0800 | [diff] [blame] | 592 | |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 593 | GrStencilSettings fHWStencilSettings; |
| 594 | TriState fHWStencilTestEnabled; |
bsalomon | 54c6fe8 | 2015-12-16 11:51:22 -0800 | [diff] [blame] | 595 | |
| 596 | |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 597 | TriState fHWWriteToColor; |
| 598 | GrGpuResource::UniqueID fHWBoundRenderTargetUniqueID; |
| 599 | TriState fHWSRGBFramebuffer; |
Brian Salomon | d978b90 | 2019-02-07 15:09:18 -0500 | [diff] [blame] | 600 | |
| 601 | class TextureUnitBindings { |
| 602 | public: |
| 603 | TextureUnitBindings() = default; |
| 604 | TextureUnitBindings(const TextureUnitBindings&) = delete; |
| 605 | TextureUnitBindings& operator=(const TextureUnitBindings&) = delete; |
| 606 | |
| 607 | GrGpuResource::UniqueID boundID(GrGLenum target) const; |
Brian Salomon | 1f05d45 | 2019-02-08 12:33:08 -0500 | [diff] [blame] | 608 | bool hasBeenModified(GrGLenum target) const; |
Brian Salomon | d978b90 | 2019-02-07 15:09:18 -0500 | [diff] [blame] | 609 | void setBoundID(GrGLenum target, GrGpuResource::UniqueID); |
Brian Salomon | 1f05d45 | 2019-02-08 12:33:08 -0500 | [diff] [blame] | 610 | void invalidateForScratchUse(GrGLenum target); |
| 611 | void invalidateAllTargets(bool markUnmodified); |
Brian Salomon | d978b90 | 2019-02-07 15:09:18 -0500 | [diff] [blame] | 612 | |
| 613 | private: |
Brian Salomon | 1f05d45 | 2019-02-08 12:33:08 -0500 | [diff] [blame] | 614 | struct TargetBinding { |
| 615 | GrGpuResource::UniqueID fBoundResourceID; |
| 616 | bool fHasBeenModified = false; |
| 617 | }; |
| 618 | TargetBinding fTargetBindings[3]; |
Brian Salomon | d978b90 | 2019-02-07 15:09:18 -0500 | [diff] [blame] | 619 | }; |
| 620 | SkAutoTArray<TextureUnitBindings> fHWTextureUnitBindings; |
cdalton | af8bc7d | 2016-02-05 09:35:20 -0800 | [diff] [blame] | 621 | |
Brian Salomon | 805cc7a | 2019-01-28 09:52:34 -0500 | [diff] [blame] | 622 | GrGLfloat fHWClearColor[4]; |
| 623 | |
Adrienne Walker | 4ee8851 | 2018-05-17 11:37:14 -0700 | [diff] [blame] | 624 | GrGLuint fBoundDrawFramebuffer = 0; |
| 625 | |
cdalton | af8bc7d | 2016-02-05 09:35:20 -0800 | [diff] [blame] | 626 | // EXT_raster_multisample. |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 627 | TriState fHWRasterMultisampleEnabled; |
| 628 | int fHWNumRasterSamples; |
bsalomon | 54c6fe8 | 2015-12-16 11:51:22 -0800 | [diff] [blame] | 629 | ///@} |
| 630 | |
Brian Salomon | 5711133 | 2018-02-05 15:55:54 -0500 | [diff] [blame] | 631 | /** IDs for copy surface program. (3 sampler types) */ |
bsalomon | 6df8640 | 2015-06-01 10:41:49 -0700 | [diff] [blame] | 632 | struct { |
Brian Salomon | 43f8bf0 | 2017-10-18 08:33:29 -0400 | [diff] [blame] | 633 | GrGLuint fProgram = 0; |
| 634 | GrGLint fTextureUniform = 0; |
| 635 | GrGLint fTexCoordXformUniform = 0; |
| 636 | GrGLint fPosXformUniform = 0; |
Brian Salomon | 5711133 | 2018-02-05 15:55:54 -0500 | [diff] [blame] | 637 | } fCopyPrograms[3]; |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 638 | sk_sp<GrGLBuffer> fCopyProgramArrayBuffer; |
bsalomon | 7ea33f5 | 2015-11-22 14:51:00 -0800 | [diff] [blame] | 639 | |
brianosman | 33f6b3f | 2016-06-02 05:49:21 -0700 | [diff] [blame] | 640 | /** IDs for texture mipmap program. (4 filter configurations) */ |
| 641 | struct { |
Brian Salomon | 43f8bf0 | 2017-10-18 08:33:29 -0400 | [diff] [blame] | 642 | GrGLuint fProgram = 0; |
| 643 | GrGLint fTextureUniform = 0; |
| 644 | GrGLint fTexCoordXformUniform = 0; |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 645 | } fMipmapPrograms[4]; |
| 646 | sk_sp<GrGLBuffer> fMipmapProgramArrayBuffer; |
brianosman | 33f6b3f | 2016-06-02 05:49:21 -0700 | [diff] [blame] | 647 | |
Robert Phillips | 646e429 | 2017-06-13 12:44:56 -0400 | [diff] [blame] | 648 | static int TextureToCopyProgramIdx(GrTexture* texture); |
bsalomon | 6df8640 | 2015-06-01 10:41:49 -0700 | [diff] [blame] | 649 | |
brianosman | 33f6b3f | 2016-06-02 05:49:21 -0700 | [diff] [blame] | 650 | static int TextureSizeToMipmapProgramIdx(int width, int height) { |
| 651 | const bool wide = (width > 1) && SkToBool(width & 0x1); |
| 652 | const bool tall = (height > 1) && SkToBool(height & 0x1); |
| 653 | return (wide ? 0x2 : 0x0) | (tall ? 0x1 : 0x0); |
| 654 | } |
| 655 | |
Chris Dalton | da40cd2 | 2018-04-16 13:19:58 -0600 | [diff] [blame] | 656 | GrPrimitiveType fLastPrimitiveType; |
ethannicholas | 28ef445 | 2016-03-25 09:26:03 -0700 | [diff] [blame] | 657 | |
Brian Salomon | dc82994 | 2018-10-23 16:07:24 -0400 | [diff] [blame] | 658 | class SamplerObjectCache; |
| 659 | std::unique_ptr<SamplerObjectCache> fSamplerObjectCache; |
| 660 | |
Robert Phillips | 5b5d84c | 2018-08-09 15:12:18 -0400 | [diff] [blame] | 661 | std::unique_ptr<GrGLGpuRTCommandBuffer> fCachedRTCommandBuffer; |
| 662 | std::unique_ptr<GrGLGpuTextureCommandBuffer> fCachedTexCommandBuffer; |
| 663 | |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 664 | friend class GrGLPathRendering; // For accessing setTextureUnit. |
Robert Phillips | 5b5d84c | 2018-08-09 15:12:18 -0400 | [diff] [blame] | 665 | |
| 666 | typedef GrGpu INHERITED; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 667 | }; |
| 668 | |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 669 | #endif |