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

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

Issue 1927943002: Unify DescriptorPools for vulkan uniform descriptor sets (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: use enum Created 4 years, 8 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/GrVkPipelineStateBuilder.cpp » ('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 2821483ca6ecc9fbc1edc2c20d55521c737ec0be..83c8b3b3e86dd078cd88d38b6ce3a4ac10749bbb 100644
--- a/src/gpu/vk/GrVkPipelineState.cpp
+++ b/src/gpu/vk/GrVkPipelineState.cpp
@@ -28,7 +28,7 @@ GrVkPipelineState::GrVkPipelineState(GrVkGpu* gpu,
const GrVkPipelineState::Desc& desc,
GrVkPipeline* pipeline,
VkPipelineLayout layout,
- VkDescriptorSetLayout dsLayout[2],
+ VkDescriptorSetLayout dsSamplerLayout,
const BuiltinUniformHandles& builtinUniformHandles,
const UniformInfoArray& uniforms,
uint32_t vertexUniformSize,
@@ -47,11 +47,9 @@ GrVkPipelineState::GrVkPipelineState(GrVkGpu* gpu,
, fFragmentProcessors(fragmentProcessors)
, fDesc(desc)
, fDataManager(uniforms, vertexUniformSize, fragmentUniformSize)
- , fSamplerPoolManager(dsLayout[GrVkUniformHandler::kSamplerDescSet],
- VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, numSamplers, gpu)
- , fUniformPoolManager(dsLayout[GrVkUniformHandler::kUniformBufferDescSet],
- VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
- (vertexUniformSize || fragmentUniformSize) ? 2 : 0, gpu) {
+ , fSamplerPoolManager(dsSamplerLayout, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
+ numSamplers, gpu)
+ , fCurrentUniformDescPool(nullptr) {
fSamplers.setReserve(numSamplers);
fTextureViews.setReserve(numSamplers);
fTextures.setReserve(numSamplers);
@@ -126,7 +124,10 @@ void GrVkPipelineState::freeGPUResources(const GrVkGpu* gpu) {
}
fSamplerPoolManager.freeGPUResources(gpu);
- fUniformPoolManager.freeGPUResources(gpu);
+ if (fCurrentUniformDescPool) {
+ fCurrentUniformDescPool->unref(gpu);
+ fCurrentUniformDescPool = nullptr;
+ }
this->freeTempResources(gpu);
}
@@ -156,7 +157,10 @@ void GrVkPipelineState::abandonGPUResources() {
fTextures.rewind();
fSamplerPoolManager.abandonGPUResources();
- fUniformPoolManager.abandonGPUResources();
+ if (fCurrentUniformDescPool) {
+ fCurrentUniformDescPool->unrefAndAbandon();
+ fCurrentUniformDescPool = nullptr;
+ }
}
static void append_texture_bindings(const GrProcessor& processor,
@@ -205,8 +209,17 @@ void GrVkPipelineState::setData(GrVkGpu* gpu,
if (fVertexUniformBuffer.get() || fFragmentUniformBuffer.get()) {
if (fDataManager.uploadUniformBuffers(gpu, fVertexUniformBuffer, fFragmentUniformBuffer) ||
VK_NULL_HANDLE == fDescriptorSets[GrVkUniformHandler::kUniformBufferDescSet]) {
- fUniformPoolManager.getNewDescriptorSet(gpu,
- &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();
+ }
this->writeUniformBuffers(gpu);
}
}
@@ -376,8 +389,8 @@ void GrVkPipelineState::addUniformResources(GrVkCommandBuffer& commandBuffer) {
if (fSamplerPoolManager.fPool) {
commandBuffer.addResource(fSamplerPoolManager.fPool);
}
- if (fUniformPoolManager.fPool) {
- commandBuffer.addResource(fUniformPoolManager.fPool);
+ if (fCurrentUniformDescPool) {
+ commandBuffer.addResource(fCurrentUniformDescPool);
}
if (fVertexUniformBuffer.get()) {
@@ -418,7 +431,8 @@ void GrVkPipelineState::DescriptorPoolManager::getNewPool(GrVkGpu* gpu) {
SkASSERT(fPool || !fMaxDescriptors);
}
-void GrVkPipelineState::DescriptorPoolManager::getNewDescriptorSet(GrVkGpu* gpu, VkDescriptorSet* ds) {
+void GrVkPipelineState::DescriptorPoolManager::getNewDescriptorSet(GrVkGpu* gpu,
+ VkDescriptorSet* ds) {
if (!fMaxDescriptors) {
return;
}
« no previous file with comments | « src/gpu/vk/GrVkPipelineState.h ('k') | src/gpu/vk/GrVkPipelineStateBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698