diff options
author | jvanverth <jvanverth@google.com> | 2016-03-02 13:19:47 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-02 13:19:47 -0800 |
commit | 03509eafa3e25819ff69f4d4f339d46264820c38 (patch) | |
tree | 8811b4aa483e5da02d0404ff1004a9c66bc7d4f3 /src | |
parent | e2b0a0a0349b1c2acbd1eb5c1da7eed012f0980d (diff) |
Use VkPipelineCaches during VkPipeline creation
BUG=skia:5037
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1756493002
Review URL: https://codereview.chromium.org/1756493002
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/vk/GrVkGpu.cpp | 7 | ||||
-rw-r--r-- | src/gpu/vk/GrVkPipeline.cpp | 5 | ||||
-rw-r--r-- | src/gpu/vk/GrVkPipeline.h | 3 | ||||
-rw-r--r-- | src/gpu/vk/GrVkResourceProvider.cpp | 28 | ||||
-rw-r--r-- | src/gpu/vk/GrVkResourceProvider.h | 6 |
5 files changed, 42 insertions, 7 deletions
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp index 6b36cdb7c8..a208aed456 100644 --- a/src/gpu/vk/GrVkGpu.cpp +++ b/src/gpu/vk/GrVkGpu.cpp @@ -180,6 +180,8 @@ GrVkGpu::GrVkGpu(GrContext* context, const GrContextOptions& options, fVkCaps.reset(new GrVkCaps(options, fInterface, physDev)); fCaps.reset(SkRef(fVkCaps.get())); + fResourceProvider.init(); + fCurrentCmdBuffer = fResourceProvider.createCommandBuffer(); SkASSERT(fCurrentCmdBuffer); fCurrentCmdBuffer->begin(this); @@ -267,6 +269,9 @@ bool GrVkGpu::onWritePixels(GrSurface* surface, } // TODO: We're ignoring MIP levels here. + if (texels.empty() || !texels.begin()->fPixels) { + return false; + } // We assume Vulkan doesn't do sRGB <-> linear conversions when reading and writing pixels. if (GrPixelConfigIsSRGB(surface->config()) != GrPixelConfigIsSRGB(config)) { @@ -537,7 +542,7 @@ GrTexture* GrVkGpu::onCreateTexture(const GrSurfaceDesc& desc, GrGpuResource::Li } // TODO: We're ignoring MIP levels here. - if (!texels.empty()) { + if (!texels.empty() && texels.begin()->fPixels) { if (!this->uploadTexData(tex, 0, 0, desc.fWidth, desc.fHeight, desc.fConfig, texels.begin()->fPixels, texels.begin()->fRowBytes)) { tex->unref(); diff --git a/src/gpu/vk/GrVkPipeline.cpp b/src/gpu/vk/GrVkPipeline.cpp index becebac269..c0197cd735 100644 --- a/src/gpu/vk/GrVkPipeline.cpp +++ b/src/gpu/vk/GrVkPipeline.cpp @@ -435,7 +435,8 @@ GrVkPipeline* GrVkPipeline::Create(GrVkGpu* gpu, const GrPipeline& pipeline, int shaderStageCount, GrPrimitiveType primitiveType, const GrVkRenderPass& renderPass, - VkPipelineLayout layout) { + VkPipelineLayout layout, + VkPipelineCache cache) { VkPipelineVertexInputStateCreateInfo vertexInputInfo; VkVertexInputBindingDescription bindingDesc; // TODO: allocate this based on VkPhysicalDeviceLimits::maxVertexInputAttributes @@ -495,7 +496,7 @@ GrVkPipeline* GrVkPipeline::Create(GrVkGpu* gpu, const GrPipeline& pipeline, VkPipeline vkPipeline; VkResult err = GR_VK_CALL(gpu->vkInterface(), CreateGraphicsPipelines(gpu->device(), - VK_NULL_HANDLE, 1, + cache, 1, &pipelineCreateInfo, nullptr, &vkPipeline)); if (err) { diff --git a/src/gpu/vk/GrVkPipeline.h b/src/gpu/vk/GrVkPipeline.h index 6bab127916..e1c946a7e7 100644 --- a/src/gpu/vk/GrVkPipeline.h +++ b/src/gpu/vk/GrVkPipeline.h @@ -29,7 +29,8 @@ public: int shaderStageCount, GrPrimitiveType primitiveType, const GrVkRenderPass& renderPass, - VkPipelineLayout layout); + VkPipelineLayout layout, + VkPipelineCache cache); VkPipeline pipeline() const { return fPipeline; } diff --git a/src/gpu/vk/GrVkResourceProvider.cpp b/src/gpu/vk/GrVkResourceProvider.cpp index f4cfa27224..19bda41525 100644 --- a/src/gpu/vk/GrVkResourceProvider.cpp +++ b/src/gpu/vk/GrVkResourceProvider.cpp @@ -17,11 +17,30 @@ SkTDynamicHash<GrVkResource, uint32_t> GrVkResource::fTrace; SkRandom GrVkResource::fRandom; #endif -GrVkResourceProvider::GrVkResourceProvider(GrVkGpu* gpu) : fGpu(gpu) { +GrVkResourceProvider::GrVkResourceProvider(GrVkGpu* gpu) : fGpu(gpu) + , fPipelineCache(VK_NULL_HANDLE) { } GrVkResourceProvider::~GrVkResourceProvider() { SkASSERT(0 == fSimpleRenderPasses.count()); + SkASSERT(VK_NULL_HANDLE == fPipelineCache); +} + +void GrVkResourceProvider::init() { + VkPipelineCacheCreateInfo createInfo; + memset(&createInfo, 0, sizeof(VkPipelineCacheCreateInfo)); + createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; + createInfo.pNext = nullptr; + createInfo.flags = 0; + createInfo.initialDataSize = 0; + createInfo.pInitialData = nullptr; + VkResult result = GR_VK_CALL(fGpu->vkInterface(), + CreatePipelineCache(fGpu->device(), &createInfo, nullptr, + &fPipelineCache)); + SkASSERT(VK_SUCCESS == result); + if (VK_SUCCESS != result) { + fPipelineCache = VK_NULL_HANDLE; + } } GrVkPipeline* GrVkResourceProvider::createPipeline(const GrPipeline& pipeline, @@ -33,7 +52,7 @@ GrVkPipeline* GrVkResourceProvider::createPipeline(const GrPipeline& pipeline, VkPipelineLayout layout) { return GrVkPipeline::Create(fGpu, pipeline, primProc, shaderStageInfo, shaderStageCount, - primitiveType, renderPass, layout); + primitiveType, renderPass, layout, fPipelineCache); } @@ -97,6 +116,8 @@ void GrVkResourceProvider::destroyResources() { SkASSERT(0 == GrVkResource::fTrace.count()); #endif + GR_VK_CALL(fGpu->vkInterface(), DestroyPipelineCache(fGpu->device(), fPipelineCache, nullptr)); + fPipelineCache = VK_NULL_HANDLE; } void GrVkResourceProvider::abandonResources() { @@ -115,4 +136,5 @@ void GrVkResourceProvider::abandonResources() { #ifdef SK_TRACE_VK_RESOURCES SkASSERT(0 == GrVkResource::fTrace.count()); #endif -}
\ No newline at end of file + fPipelineCache = VK_NULL_HANDLE; +} diff --git a/src/gpu/vk/GrVkResourceProvider.h b/src/gpu/vk/GrVkResourceProvider.h index 245062ea8d..38d6c40187 100644 --- a/src/gpu/vk/GrVkResourceProvider.h +++ b/src/gpu/vk/GrVkResourceProvider.h @@ -28,6 +28,9 @@ public: GrVkResourceProvider(GrVkGpu* gpu); ~GrVkResourceProvider(); + // Set up any initial vk objects + void init(); + GrVkPipeline* createPipeline(const GrPipeline& pipeline, const GrPrimitiveProcessor& primProc, VkPipelineShaderStageCreateInfo* shaderStageInfo, @@ -66,6 +69,9 @@ public: private: GrVkGpu* fGpu; + // Central cache for creating pipelines + VkPipelineCache fPipelineCache; + // Array of RenderPasses that only have a single color attachment, optional stencil attachment, // optional resolve attachment, and only one subpass SkSTArray<4, GrVkRenderPass*> fSimpleRenderPasses; |