Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 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. |
| 6 | */ |
| 7 | |
| 8 | #ifndef GrVkGpu_DEFINED |
| 9 | #define GrVkGpu_DEFINED |
| 10 | |
| 11 | #include "GrGpu.h" |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 12 | #include "GrVkCaps.h" |
egdaniel | bc9b296 | 2016-09-27 08:00:53 -0700 | [diff] [blame] | 13 | #include "GrVkCopyManager.h" |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 14 | #include "GrVkIndexBuffer.h" |
jvanverth | 6b6ffc4 | 2016-06-13 14:28:07 -0700 | [diff] [blame] | 15 | #include "GrVkMemory.h" |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 16 | #include "GrVkResourceProvider.h" |
Greg Daniel | 6be3523 | 2017-03-01 17:01:09 -0500 | [diff] [blame] | 17 | #include "GrVkSemaphore.h" |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 18 | #include "GrVkVertexBuffer.h" |
| 19 | #include "GrVkUtil.h" |
Greg Daniel | 487132b | 2018-12-20 14:09:36 -0500 | [diff] [blame] | 20 | #include "vk/GrVkBackendContext.h" |
| 21 | #include "vk/GrVkTypes.h" |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 22 | |
| 23 | class GrPipeline; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 24 | |
| 25 | class GrVkBufferImpl; |
Ethan Nicholas | 8e265a7 | 2018-12-12 16:22:40 -0500 | [diff] [blame] | 26 | class GrVkCommandPool; |
Robert Phillips | 5b5d84c | 2018-08-09 15:12:18 -0400 | [diff] [blame] | 27 | class GrVkGpuRTCommandBuffer; |
| 28 | class GrVkGpuTextureCommandBuffer; |
Greg Daniel | 81df041 | 2018-05-31 13:13:33 -0400 | [diff] [blame] | 29 | class GrVkMemoryAllocator; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 30 | class GrVkPipeline; |
egdaniel | 22281c1 | 2016-03-23 13:49:40 -0700 | [diff] [blame] | 31 | class GrVkPipelineState; |
egdaniel | 066df7c | 2016-06-08 14:02:27 -0700 | [diff] [blame] | 32 | class GrVkPrimaryCommandBuffer; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 33 | class GrVkRenderPass; |
egdaniel | 066df7c | 2016-06-08 14:02:27 -0700 | [diff] [blame] | 34 | class GrVkSecondaryCommandBuffer; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 35 | class GrVkTexture; |
| 36 | struct GrVkInterface; |
| 37 | |
Ethan Nicholas | 941e7e2 | 2016-12-12 15:33:30 -0500 | [diff] [blame] | 38 | namespace SkSL { |
| 39 | class Compiler; |
| 40 | } |
| 41 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 42 | class GrVkGpu : public GrGpu { |
| 43 | public: |
Greg Daniel | f730c18 | 2018-07-02 20:15:37 +0000 | [diff] [blame] | 44 | static sk_sp<GrGpu> Make(const GrVkBackendContext&, const GrContextOptions&, GrContext*); |
jvanverth | 633b356 | 2016-03-23 11:01:22 -0700 | [diff] [blame] | 45 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 46 | ~GrVkGpu() override; |
| 47 | |
Greg Daniel | 8606cf8 | 2017-05-08 16:17:53 -0400 | [diff] [blame] | 48 | void disconnect(DisconnectType) override; |
| 49 | |
Greg Daniel | f730c18 | 2018-07-02 20:15:37 +0000 | [diff] [blame] | 50 | const GrVkInterface* vkInterface() const { return fInterface.get(); } |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 51 | const GrVkCaps& vkCaps() const { return *fVkCaps; } |
| 52 | |
Greg Daniel | 81df041 | 2018-05-31 13:13:33 -0400 | [diff] [blame] | 53 | GrVkMemoryAllocator* memoryAllocator() const { return fMemoryAllocator.get(); } |
| 54 | |
Greg Daniel | 637c06a | 2018-09-12 09:44:25 -0400 | [diff] [blame] | 55 | VkPhysicalDevice physicalDevice() const { return fPhysicalDevice; } |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 56 | VkDevice device() const { return fDevice; } |
| 57 | VkQueue queue() const { return fQueue; } |
Greg Daniel | ecddbc0 | 2018-08-30 16:39:34 -0400 | [diff] [blame] | 58 | uint32_t queueIndex() const { return fQueueIndex; } |
Ethan Nicholas | 8e265a7 | 2018-12-12 16:22:40 -0500 | [diff] [blame] | 59 | GrVkCommandPool* cmdPool() const { return fCmdPool; } |
Greg Daniel | a870b46 | 2019-01-08 15:49:46 -0500 | [diff] [blame] | 60 | const VkPhysicalDeviceProperties& physicalDeviceProperties() const { |
Greg Daniel | 8385a8a | 2018-02-26 13:29:37 -0500 | [diff] [blame] | 61 | return fPhysDevProps; |
| 62 | } |
Greg Daniel | a870b46 | 2019-01-08 15:49:46 -0500 | [diff] [blame] | 63 | const VkPhysicalDeviceMemoryProperties& physicalDeviceMemoryProperties() const { |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 64 | return fPhysDevMemProps; |
| 65 | } |
| 66 | |
egdaniel | bc9b296 | 2016-09-27 08:00:53 -0700 | [diff] [blame] | 67 | GrVkResourceProvider& resourceProvider() { return fResourceProvider; } |
| 68 | |
| 69 | GrVkPrimaryCommandBuffer* currentCommandBuffer() { return fCurrentCmdBuffer; } |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 70 | |
| 71 | enum SyncQueue { |
| 72 | kForce_SyncQueue, |
| 73 | kSkip_SyncQueue |
| 74 | }; |
| 75 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 76 | void xferBarrier(GrRenderTarget*, GrXferBarrierType) override {} |
| 77 | |
Brian Salomon | f865b05 | 2018-03-09 09:01:53 -0500 | [diff] [blame] | 78 | #if GR_TEST_UTILS |
Brian Salomon | 52e943a | 2018-03-13 09:32:39 -0400 | [diff] [blame] | 79 | GrBackendTexture createTestingOnlyBackendTexture(const void* pixels, int w, int h, |
Robert Phillips | 646f637 | 2018-09-25 09:31:10 -0400 | [diff] [blame] | 80 | GrColorType colorType, bool isRenderTarget, |
| 81 | GrMipMapped, size_t rowBytes = 0) override; |
Robert Phillips | d21b2a5 | 2017-12-12 13:01:25 -0500 | [diff] [blame] | 82 | bool isTestingOnlyBackendTexture(const GrBackendTexture&) const override; |
Brian Salomon | 26102cb | 2018-03-09 09:33:19 -0500 | [diff] [blame] | 83 | void deleteTestingOnlyBackendTexture(const GrBackendTexture&) override; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 84 | |
Brian Osman | 2d010b6 | 2018-08-09 10:55:09 -0400 | [diff] [blame] | 85 | GrBackendRenderTarget createTestingOnlyBackendRenderTarget(int w, int h, GrColorType) override; |
Brian Salomon | f865b05 | 2018-03-09 09:01:53 -0500 | [diff] [blame] | 86 | void deleteTestingOnlyBackendRenderTarget(const GrBackendRenderTarget&) override; |
| 87 | |
Greg Daniel | 26b50a4 | 2018-03-08 09:49:58 -0500 | [diff] [blame] | 88 | void testingOnly_flushGpuAndSync() override; |
Brian Salomon | f865b05 | 2018-03-09 09:01:53 -0500 | [diff] [blame] | 89 | #endif |
Greg Daniel | 26b50a4 | 2018-03-08 09:49:58 -0500 | [diff] [blame] | 90 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 91 | GrStencilAttachment* createStencilAttachmentForRenderTarget(const GrRenderTarget*, |
| 92 | int width, |
| 93 | int height) override; |
| 94 | |
Robert Phillips | 5b5d84c | 2018-08-09 15:12:18 -0400 | [diff] [blame] | 95 | GrGpuRTCommandBuffer* getCommandBuffer( |
Ethan Nicholas | 56d19a5 | 2018-10-15 11:26:20 -0400 | [diff] [blame] | 96 | GrRenderTarget*, GrSurfaceOrigin, const SkRect&, |
Greg Daniel | 500d58b | 2017-08-24 15:59:33 -0400 | [diff] [blame] | 97 | const GrGpuRTCommandBuffer::LoadAndStoreInfo&, |
| 98 | const GrGpuRTCommandBuffer::StencilLoadAndStoreInfo&) override; |
| 99 | |
Robert Phillips | 5b5d84c | 2018-08-09 15:12:18 -0400 | [diff] [blame] | 100 | GrGpuTextureCommandBuffer* getCommandBuffer(GrTexture*, GrSurfaceOrigin) override; |
| 101 | |
egdaniel | 066df7c | 2016-06-08 14:02:27 -0700 | [diff] [blame] | 102 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 103 | void addMemoryBarrier(VkPipelineStageFlags srcStageMask, |
| 104 | VkPipelineStageFlags dstStageMask, |
| 105 | bool byRegion, |
| 106 | VkMemoryBarrier* barrier) const; |
| 107 | void addBufferMemoryBarrier(VkPipelineStageFlags srcStageMask, |
| 108 | VkPipelineStageFlags dstStageMask, |
| 109 | bool byRegion, |
| 110 | VkBufferMemoryBarrier* barrier) const; |
| 111 | void addImageMemoryBarrier(VkPipelineStageFlags srcStageMask, |
| 112 | VkPipelineStageFlags dstStageMask, |
| 113 | bool byRegion, |
| 114 | VkImageMemoryBarrier* barrier) const; |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 115 | |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 116 | SkSL::Compiler* shaderCompiler() const { |
| 117 | return fCompiler; |
| 118 | } |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 119 | |
Brian Salomon | 930f939 | 2018-06-20 16:25:26 -0400 | [diff] [blame] | 120 | bool onRegenerateMipMapLevels(GrTexture* tex) override; |
| 121 | |
Greg Daniel | 0a77f43 | 2018-12-06 11:23:32 -0500 | [diff] [blame] | 122 | void resolveRenderTargetNoFlush(GrRenderTarget* target) { |
| 123 | this->internalResolveRenderTarget(target, false); |
| 124 | } |
| 125 | |
Brian Salomon | 1fabd51 | 2018-02-09 09:54:25 -0500 | [diff] [blame] | 126 | void onResolveRenderTarget(GrRenderTarget* target) override { |
Greg Daniel | 0a77f43 | 2018-12-06 11:23:32 -0500 | [diff] [blame] | 127 | // This resolve is called when we are preparing an msaa surface for external I/O. It is |
| 128 | // called after flushing, so we need to make sure we submit the command buffer after doing |
| 129 | // the resolve so that the resolve actually happens. |
Brian Salomon | 1fabd51 | 2018-02-09 09:54:25 -0500 | [diff] [blame] | 130 | this->internalResolveRenderTarget(target, true); |
Greg Daniel | 69d4992 | 2017-02-23 09:44:02 -0500 | [diff] [blame] | 131 | } |
egdaniel | 6693355 | 2016-08-24 07:22:19 -0700 | [diff] [blame] | 132 | |
Greg Daniel | 22bc865 | 2017-03-22 15:45:43 -0400 | [diff] [blame] | 133 | void submitSecondaryCommandBuffer(const SkTArray<GrVkSecondaryCommandBuffer*>&, |
egdaniel | 9cb6340 | 2016-06-23 08:37:05 -0700 | [diff] [blame] | 134 | const GrVkRenderPass*, |
Robert Phillips | 8c326e9 | 2017-08-10 13:50:17 -0400 | [diff] [blame] | 135 | const VkClearValue* colorClear, |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 136 | GrVkRenderTarget*, GrSurfaceOrigin, |
egdaniel | 9cb6340 | 2016-06-23 08:37:05 -0700 | [diff] [blame] | 137 | const SkIRect& bounds); |
egdaniel | 066df7c | 2016-06-08 14:02:27 -0700 | [diff] [blame] | 138 | |
Robert Phillips | 5b5d84c | 2018-08-09 15:12:18 -0400 | [diff] [blame] | 139 | void submit(GrGpuCommandBuffer*) override; |
| 140 | |
Greg Daniel | 6be3523 | 2017-03-01 17:01:09 -0500 | [diff] [blame] | 141 | GrFence SK_WARN_UNUSED_RESULT insertFence() override; |
| 142 | bool waitFence(GrFence, uint64_t timeout) override; |
jvanverth | 84741b3 | 2016-09-30 08:39:02 -0700 | [diff] [blame] | 143 | void deleteFence(GrFence) const override; |
| 144 | |
Greg Daniel | a5cb781 | 2017-06-16 09:45:32 -0400 | [diff] [blame] | 145 | sk_sp<GrSemaphore> SK_WARN_UNUSED_RESULT makeSemaphore(bool isOwned) override; |
Greg Daniel | 48661b8 | 2018-01-22 16:11:35 -0500 | [diff] [blame] | 146 | sk_sp<GrSemaphore> wrapBackendSemaphore(const GrBackendSemaphore& semaphore, |
| 147 | GrResourceProvider::SemaphoreWrapType wrapType, |
| 148 | GrWrapOwnership ownership) override; |
Greg Daniel | 858e12c | 2018-12-06 11:11:37 -0500 | [diff] [blame] | 149 | void insertSemaphore(sk_sp<GrSemaphore> semaphore) override; |
Greg Daniel | 48661b8 | 2018-01-22 16:11:35 -0500 | [diff] [blame] | 150 | void waitSemaphore(sk_sp<GrSemaphore> semaphore) override; |
| 151 | |
Greg Daniel | 64cc9aa | 2018-10-19 13:54:56 -0400 | [diff] [blame] | 152 | // These match the definitions in SkDrawable, from whence they came |
| 153 | typedef void* SubmitContext; |
| 154 | typedef void (*SubmitProc)(SubmitContext submitContext); |
| 155 | |
| 156 | // Adds an SkDrawable::GpuDrawHandler that we will delete the next time we submit the primary |
| 157 | // command buffer to the gpu. |
| 158 | void addDrawable(std::unique_ptr<SkDrawable::GpuDrawHandler> drawable); |
| 159 | |
Brian Osman | 13dddce | 2017-05-09 13:19:50 -0400 | [diff] [blame] | 160 | sk_sp<GrSemaphore> prepareTextureForCrossContextUsage(GrTexture*) override; |
| 161 | |
Greg Daniel | 6888c0d | 2017-08-25 11:55:50 -0400 | [diff] [blame] | 162 | void copyBuffer(GrVkBuffer* srcBuffer, GrVkBuffer* dstBuffer, VkDeviceSize srcOffset, |
| 163 | VkDeviceSize dstOffset, VkDeviceSize size); |
jvanverth | db37909 | 2016-07-07 11:18:46 -0700 | [diff] [blame] | 164 | bool updateBuffer(GrVkBuffer* buffer, const void* src, VkDeviceSize offset, VkDeviceSize size); |
jvanverth | a584de9 | 2016-06-30 09:10:52 -0700 | [diff] [blame] | 165 | |
Greg Daniel | 7a82edf | 2018-12-04 10:54:34 -0500 | [diff] [blame] | 166 | uint32_t getExtraSamplerKeyForProgram(const GrSamplerState&, |
| 167 | const GrBackendFormat& format) override; |
| 168 | |
Greg Daniel | a870b46 | 2019-01-08 15:49:46 -0500 | [diff] [blame] | 169 | enum PersistentCacheKeyType : uint32_t { |
| 170 | kShader_PersistentCacheKeyType = 0, |
| 171 | kPipelineCache_PersistentCacheKeyType = 1, |
| 172 | }; |
| 173 | |
| 174 | void storeVkPipelineCacheData() override; |
| 175 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 176 | private: |
Greg Daniel | 98bffae | 2018-08-01 13:25:41 -0400 | [diff] [blame] | 177 | GrVkGpu(GrContext*, const GrContextOptions&, const GrVkBackendContext&, |
Greg Daniel | 41f0e28 | 2019-01-28 13:15:05 -0500 | [diff] [blame] | 178 | sk_sp<const GrVkInterface>, uint32_t instanceVersion, uint32_t physicalDeviceVersion); |
jvanverth | 633b356 | 2016-03-23 11:01:22 -0700 | [diff] [blame] | 179 | |
egdaniel | cfcd181 | 2016-03-22 07:16:10 -0700 | [diff] [blame] | 180 | void onResetContext(uint32_t resetBits) override {} |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 181 | |
Greg Daniel | 8606cf8 | 2017-05-08 16:17:53 -0400 | [diff] [blame] | 182 | void destroyResources(); |
| 183 | |
Brian Salomon | 58389b9 | 2018-03-07 13:01:25 -0500 | [diff] [blame] | 184 | sk_sp<GrTexture> onCreateTexture(const GrSurfaceDesc&, SkBudgeted, const GrMipLevel[], |
Brian Salomon | 2a4f983 | 2018-03-03 22:43:43 -0500 | [diff] [blame] | 185 | int mipLevelCount) override; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 186 | |
Brian Salomon | fa2ebea | 2019-01-24 15:58:58 -0500 | [diff] [blame] | 187 | sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&, GrWrapOwnership, GrWrapCacheable, |
| 188 | GrIOType) override; |
Brian Salomon | d17f658 | 2017-07-19 18:28:58 -0400 | [diff] [blame] | 189 | sk_sp<GrTexture> onWrapRenderableBackendTexture(const GrBackendTexture&, |
Brian Salomon | d17f658 | 2017-07-19 18:28:58 -0400 | [diff] [blame] | 190 | int sampleCnt, |
Brian Salomon | aa6ca0a | 2019-01-24 16:03:07 -0500 | [diff] [blame] | 191 | GrWrapOwnership, |
| 192 | GrWrapCacheable) override; |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 193 | sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTarget&) override; |
Greg Daniel | 7ef28f3 | 2017-04-20 16:41:55 +0000 | [diff] [blame] | 194 | |
| 195 | sk_sp<GrRenderTarget> onWrapBackendTextureAsRenderTarget(const GrBackendTexture&, |
Greg Daniel | 7ef28f3 | 2017-04-20 16:41:55 +0000 | [diff] [blame] | 196 | int sampleCnt) override; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 197 | |
Greg Daniel | b46add8 | 2019-01-02 14:51:29 -0500 | [diff] [blame] | 198 | sk_sp<GrRenderTarget> onWrapVulkanSecondaryCBAsRenderTarget(const SkImageInfo&, |
| 199 | const GrVkDrawableInfo&) override; |
| 200 | |
Brian Salomon | dbf7072 | 2019-02-07 11:31:24 -0500 | [diff] [blame] | 201 | sk_sp<GrGpuBuffer> onCreateBuffer(size_t size, GrGpuBufferType type, GrAccessPattern, |
| 202 | const void* data) override; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 203 | |
Brian Salomon | a694870 | 2018-06-01 15:33:20 -0400 | [diff] [blame] | 204 | bool onReadPixels(GrSurface* surface, int left, int top, int width, int height, GrColorType, |
| 205 | void* buffer, size_t rowBytes) override; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 206 | |
Brian Salomon | a9b04b9 | 2018-06-01 15:04:28 -0400 | [diff] [blame] | 207 | bool onWritePixels(GrSurface* surface, int left, int top, int width, int height, GrColorType, |
| 208 | const GrMipLevel texels[], int mipLevelCount) override; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 209 | |
Brian Salomon | c320b15 | 2018-02-20 14:05:36 -0500 | [diff] [blame] | 210 | bool onTransferPixels(GrTexture*, int left, int top, int width, int height, GrColorType, |
Brian Salomon | dbf7072 | 2019-02-07 11:31:24 -0500 | [diff] [blame] | 211 | GrGpuBuffer* transferBuffer, size_t offset, size_t rowBytes) override; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 212 | |
Brian Salomon | 9b009bb | 2018-02-14 13:53:55 -0500 | [diff] [blame] | 213 | bool onCopySurface(GrSurface* dst, GrSurfaceOrigin dstOrigin, GrSurface* src, |
| 214 | GrSurfaceOrigin srcOrigin, const SkIRect& srcRect, |
Greg Daniel | 55fa647 | 2018-03-16 16:13:10 -0400 | [diff] [blame] | 215 | const SkIPoint& dstPoint, bool canDiscardOutsideDstRect) override; |
Brian Salomon | 9b009bb | 2018-02-14 13:53:55 -0500 | [diff] [blame] | 216 | |
Greg Daniel | 5131678 | 2017-08-02 15:10:09 +0000 | [diff] [blame] | 217 | void onFinishFlush(bool insertedSemaphores) override; |
| 218 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 219 | // Ends and submits the current command buffer to the queue and then creates a new command |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 220 | // buffer and begins it. If sync is set to kForce_SyncQueue, the function will wait for all |
Greg Daniel | a5cb781 | 2017-06-16 09:45:32 -0400 | [diff] [blame] | 221 | // work in the queue to finish before returning. If this GrVkGpu object has any semaphores in |
| 222 | // fSemaphoreToSignal, we will add those signal semaphores to the submission of this command |
| 223 | // buffer. If this GrVkGpu object has any semaphores in fSemaphoresToWaitOn, we will add those |
| 224 | // wait semaphores to the submission of this command buffer. |
| 225 | void submitCommandBuffer(SyncQueue sync); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 226 | |
Brian Salomon | 1fabd51 | 2018-02-09 09:54:25 -0500 | [diff] [blame] | 227 | void internalResolveRenderTarget(GrRenderTarget*, bool requiresSubmit); |
Greg Daniel | 69d4992 | 2017-02-23 09:44:02 -0500 | [diff] [blame] | 228 | |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 229 | void copySurfaceAsCopyImage(GrSurface* dst, GrSurfaceOrigin dstOrigin, |
| 230 | GrSurface* src, GrSurfaceOrigin srcOrigin, |
| 231 | GrVkImage* dstImage, GrVkImage* srcImage, |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 232 | const SkIRect& srcRect, |
| 233 | const SkIPoint& dstPoint); |
| 234 | |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 235 | void copySurfaceAsBlit(GrSurface* dst, GrSurfaceOrigin dstOrigin, |
| 236 | GrSurface* src, GrSurfaceOrigin srcOrigin, |
| 237 | GrVkImage* dstImage, GrVkImage* srcImage, |
egdaniel | 17b8925 | 2016-04-05 07:23:38 -0700 | [diff] [blame] | 238 | const SkIRect& srcRect, |
| 239 | const SkIPoint& dstPoint); |
| 240 | |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 241 | void copySurfaceAsResolve(GrSurface* dst, GrSurfaceOrigin dstOrigin, |
| 242 | GrSurface* src, GrSurfaceOrigin srcOrigin, |
egdaniel | 4bcd62e | 2016-08-31 07:37:31 -0700 | [diff] [blame] | 243 | const SkIRect& srcRect, |
| 244 | const SkIPoint& dstPoint); |
| 245 | |
jvanverth | 900bd4a | 2016-04-29 13:53:12 -0700 | [diff] [blame] | 246 | // helpers for onCreateTexture and writeTexturePixels |
Brian Salomon | a9b04b9 | 2018-06-01 15:04:28 -0400 | [diff] [blame] | 247 | bool uploadTexDataLinear(GrVkTexture* tex, int left, int top, int width, int height, |
| 248 | GrColorType colorType, const void* data, size_t rowBytes); |
| 249 | bool uploadTexDataOptimal(GrVkTexture* tex, int left, int top, int width, int height, |
| 250 | GrColorType colorType, const GrMipLevel texels[], int mipLevelCount); |
Jim Van Verth | 1676cb9 | 2019-01-15 13:24:45 -0500 | [diff] [blame] | 251 | bool uploadTexDataCompressed(GrVkTexture* tex, int left, int top, int width, int height, |
| 252 | GrColorType dataColorType, const GrMipLevel texels[], |
| 253 | int mipLevelCount); |
Brian Salomon | 1fabd51 | 2018-02-09 09:54:25 -0500 | [diff] [blame] | 254 | void resolveImage(GrSurface* dst, GrVkRenderTarget* src, const SkIRect& srcRect, |
| 255 | const SkIPoint& dstPoint); |
egdaniel | 4bcd62e | 2016-08-31 07:37:31 -0700 | [diff] [blame] | 256 | |
Brian Salomon | 52e943a | 2018-03-13 09:32:39 -0400 | [diff] [blame] | 257 | #if GR_TEST_UTILS |
| 258 | bool createTestingOnlyVkImage(GrPixelConfig config, int w, int h, bool texturable, |
| 259 | bool renderable, GrMipMapped mipMapped, const void* srcData, |
Robert Phillips | 646f637 | 2018-09-25 09:31:10 -0400 | [diff] [blame] | 260 | size_t srcRowBytes, GrVkImageInfo* info); |
Brian Salomon | 52e943a | 2018-03-13 09:32:39 -0400 | [diff] [blame] | 261 | #endif |
| 262 | |
Greg Daniel | 64cc9aa | 2018-10-19 13:54:56 -0400 | [diff] [blame] | 263 | sk_sp<const GrVkInterface> fInterface; |
| 264 | sk_sp<GrVkMemoryAllocator> fMemoryAllocator; |
| 265 | sk_sp<GrVkCaps> fVkCaps; |
jvanverth | 633b356 | 2016-03-23 11:01:22 -0700 | [diff] [blame] | 266 | |
Greg Daniel | 64cc9aa | 2018-10-19 13:54:56 -0400 | [diff] [blame] | 267 | VkInstance fInstance; |
| 268 | VkPhysicalDevice fPhysicalDevice; |
| 269 | VkDevice fDevice; |
| 270 | VkQueue fQueue; // Must be Graphics queue |
| 271 | uint32_t fQueueIndex; |
jvanverth | 633b356 | 2016-03-23 11:01:22 -0700 | [diff] [blame] | 272 | |
| 273 | // Created by GrVkGpu |
Greg Daniel | 64cc9aa | 2018-10-19 13:54:56 -0400 | [diff] [blame] | 274 | GrVkResourceProvider fResourceProvider; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 275 | |
Ethan Nicholas | 8e265a7 | 2018-12-12 16:22:40 -0500 | [diff] [blame] | 276 | GrVkCommandPool* fCmdPool; |
| 277 | |
| 278 | // just a raw pointer; object's lifespan is managed by fCmdPool |
Greg Daniel | 64cc9aa | 2018-10-19 13:54:56 -0400 | [diff] [blame] | 279 | GrVkPrimaryCommandBuffer* fCurrentCmdBuffer; |
jvanverth | 6b6ffc4 | 2016-06-13 14:28:07 -0700 | [diff] [blame] | 280 | |
Greg Daniel | 64cc9aa | 2018-10-19 13:54:56 -0400 | [diff] [blame] | 281 | SkSTArray<1, GrVkSemaphore::Resource*> fSemaphoresToWaitOn; |
| 282 | SkSTArray<1, GrVkSemaphore::Resource*> fSemaphoresToSignal; |
Greg Daniel | 6be3523 | 2017-03-01 17:01:09 -0500 | [diff] [blame] | 283 | |
Greg Daniel | 64cc9aa | 2018-10-19 13:54:56 -0400 | [diff] [blame] | 284 | SkTArray<std::unique_ptr<SkDrawable::GpuDrawHandler>> fDrawables; |
Greg Daniel | 6be3523 | 2017-03-01 17:01:09 -0500 | [diff] [blame] | 285 | |
Greg Daniel | 64cc9aa | 2018-10-19 13:54:56 -0400 | [diff] [blame] | 286 | VkPhysicalDeviceProperties fPhysDevProps; |
| 287 | VkPhysicalDeviceMemoryProperties fPhysDevMemProps; |
| 288 | |
| 289 | GrVkCopyManager fCopyManager; |
egdaniel | bc9b296 | 2016-09-27 08:00:53 -0700 | [diff] [blame] | 290 | |
Ethan Nicholas | 941e7e2 | 2016-12-12 15:33:30 -0500 | [diff] [blame] | 291 | // compiler used for compiling sksl into spirv. We only want to create the compiler once since |
| 292 | // there is significant overhead to the first compile of any compiler. |
Greg Daniel | 64cc9aa | 2018-10-19 13:54:56 -0400 | [diff] [blame] | 293 | SkSL::Compiler* fCompiler; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 294 | |
Greg Daniel | 8606cf8 | 2017-05-08 16:17:53 -0400 | [diff] [blame] | 295 | // We need a bool to track whether or not we've already disconnected all the gpu resources from |
| 296 | // vulkan context. |
Greg Daniel | 64cc9aa | 2018-10-19 13:54:56 -0400 | [diff] [blame] | 297 | bool fDisconnected; |
Greg Daniel | 8606cf8 | 2017-05-08 16:17:53 -0400 | [diff] [blame] | 298 | |
Greg Daniel | 64cc9aa | 2018-10-19 13:54:56 -0400 | [diff] [blame] | 299 | std::unique_ptr<GrVkGpuRTCommandBuffer> fCachedRTCommandBuffer; |
| 300 | std::unique_ptr<GrVkGpuTextureCommandBuffer> fCachedTexCommandBuffer; |
Robert Phillips | 5b5d84c | 2018-08-09 15:12:18 -0400 | [diff] [blame] | 301 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 302 | typedef GrGpu INHERITED; |
| 303 | }; |
| 304 | |
| 305 | #endif |