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

Unified Diff: src/gpu/vk/GrVkPipelineState.cpp

Issue 2163673002: Setup system in Vulkan to reuse VkDescriptorSet allocations. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nit Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/vk/GrVkPipelineState.h ('k') | src/gpu/vk/GrVkResource.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/vk/GrVkPipelineState.cpp
diff --git a/src/gpu/vk/GrVkPipelineState.cpp b/src/gpu/vk/GrVkPipelineState.cpp
index 94d6305bc951a5eba89a6bc8839d94f7a6e15990..700dc4b4cf72c1f7cea456de44fbe481ffdd2ae7 100644
--- a/src/gpu/vk/GrVkPipelineState.cpp
+++ b/src/gpu/vk/GrVkPipelineState.cpp
@@ -11,6 +11,7 @@
#include "GrTexturePriv.h"
#include "GrVkCommandBuffer.h"
#include "GrVkDescriptorPool.h"
+#include "GrVkDescriptorSet.h"
#include "GrVkGpu.h"
#include "GrVkImageView.h"
#include "GrVkMemory.h"
@@ -39,6 +40,7 @@ GrVkPipelineState::GrVkPipelineState(GrVkGpu* gpu,
const GrGLSLFragProcs& fragmentProcessors)
: fPipeline(pipeline)
, fPipelineLayout(layout)
+ , fUniformDescriptorSet(nullptr)
, fStartDS(SK_MaxS32)
, fDSCount(0)
, fBuiltinUniformHandles(builtinUniformHandles)
@@ -48,8 +50,7 @@ GrVkPipelineState::GrVkPipelineState(GrVkGpu* gpu,
, fDesc(desc)
, fDataManager(uniforms, vertexUniformSize, fragmentUniformSize)
, fSamplerPoolManager(dsSamplerLayout, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
- numSamplers, gpu)
- , fCurrentUniformDescPool(nullptr) {
+ numSamplers, gpu) {
fSamplers.setReserve(numSamplers);
fTextureViews.setReserve(numSamplers);
fTextures.setReserve(numSamplers);
@@ -124,9 +125,10 @@ void GrVkPipelineState::freeGPUResources(const GrVkGpu* gpu) {
}
fSamplerPoolManager.freeGPUResources(gpu);
- if (fCurrentUniformDescPool) {
- fCurrentUniformDescPool->unref(gpu);
- fCurrentUniformDescPool = nullptr;
+
+ if (fUniformDescriptorSet) {
+ fUniformDescriptorSet->recycle(const_cast<GrVkGpu*>(gpu));
+ fUniformDescriptorSet = nullptr;
}
this->freeTempResources(gpu);
@@ -157,9 +159,10 @@ void GrVkPipelineState::abandonGPUResources() {
fTextures.rewind();
fSamplerPoolManager.abandonGPUResources();
- if (fCurrentUniformDescPool) {
- fCurrentUniformDescPool->unrefAndAbandon();
- fCurrentUniformDescPool = nullptr;
+
+ if (fUniformDescriptorSet) {
+ fUniformDescriptorSet->unrefAndAbandon();
+ fUniformDescriptorSet = nullptr;
}
}
@@ -208,18 +211,13 @@ void GrVkPipelineState::setData(GrVkGpu* gpu,
if (fVertexUniformBuffer.get() || fFragmentUniformBuffer.get()) {
if (fDataManager.uploadUniformBuffers(gpu, fVertexUniformBuffer, fFragmentUniformBuffer) ||
- VK_NULL_HANDLE == fDescriptorSets[GrVkUniformHandler::kUniformBufferDescSet]) {
- const GrVkDescriptorPool* pool;
- int uniformDSIdx = GrVkUniformHandler::kUniformBufferDescSet;
- gpu->resourceProvider().getUniformDescriptorSet(&fDescriptorSets[uniformDSIdx],
- &pool);
- if (pool != fCurrentUniformDescPool) {
- if (fCurrentUniformDescPool) {
- fCurrentUniformDescPool->unref(gpu);
- }
- fCurrentUniformDescPool = pool;
- fCurrentUniformDescPool->ref();
+ !fUniformDescriptorSet) {
+ if (fUniformDescriptorSet) {
+ fUniformDescriptorSet->recycle(gpu);
}
+ fUniformDescriptorSet = gpu->resourceProvider().getUniformDescriptorSet();
+ int uniformDSIdx = GrVkUniformHandler::kUniformBufferDescSet;
+ fDescriptorSets[uniformDSIdx] = fUniformDescriptorSet->descriptorSet();
this->writeUniformBuffers(gpu);
}
}
@@ -370,8 +368,9 @@ void GrVkPipelineState::addUniformResources(GrVkCommandBuffer& commandBuffer) {
if (fSamplerPoolManager.fPool) {
commandBuffer.addResource(fSamplerPoolManager.fPool);
}
- if (fCurrentUniformDescPool) {
- commandBuffer.addResource(fCurrentUniformDescPool);
+
+ if (fUniformDescriptorSet) {
+ commandBuffer.addRecycledResource(fUniformDescriptorSet);
}
if (fVertexUniformBuffer.get()) {
« no previous file with comments | « src/gpu/vk/GrVkPipelineState.h ('k') | src/gpu/vk/GrVkResource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698