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

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

Issue 2172873003: Reuse sampler descriptor set allocations in Vulkan (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nits 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/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 ab9cff8d1b73459b413abb6deb5c1926f50f92fe..5b3fa8f0568321cdbfc7724f287af350699e8000 100644
--- a/src/gpu/vk/GrVkPipelineState.cpp
+++ b/src/gpu/vk/GrVkPipelineState.cpp
@@ -29,7 +29,7 @@ GrVkPipelineState::GrVkPipelineState(GrVkGpu* gpu,
const GrVkPipelineState::Desc& desc,
GrVkPipeline* pipeline,
VkPipelineLayout layout,
- VkDescriptorSetLayout dsSamplerLayout,
+ const GrVkDescriptorSetManager::Handle& samplerDSHandle,
const BuiltinUniformHandles& builtinUniformHandles,
const UniformInfoArray& uniforms,
uint32_t vertexUniformSize,
@@ -41,6 +41,8 @@ GrVkPipelineState::GrVkPipelineState(GrVkGpu* gpu,
: fPipeline(pipeline)
, fPipelineLayout(layout)
, fUniformDescriptorSet(nullptr)
+ , fSamplerDescriptorSet(nullptr)
+ , fSamplerDSHandle(samplerDSHandle)
, fStartDS(SK_MaxS32)
, fDSCount(0)
, fBuiltinUniformHandles(builtinUniformHandles)
@@ -48,9 +50,7 @@ GrVkPipelineState::GrVkPipelineState(GrVkGpu* gpu,
, fXferProcessor(xferProcessor)
, fFragmentProcessors(fragmentProcessors)
, fDesc(desc)
- , fDataManager(uniforms, vertexUniformSize, fragmentUniformSize)
- , fSamplerPoolManager(dsSamplerLayout, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
- numSamplers, gpu) {
+ , fDataManager(uniforms, vertexUniformSize, fragmentUniformSize) {
fSamplers.setReserve(numSamplers);
fTextureViews.setReserve(numSamplers);
fTextures.setReserve(numSamplers);
@@ -124,13 +124,16 @@ void GrVkPipelineState::freeGPUResources(const GrVkGpu* gpu) {
fFragmentUniformBuffer->release(gpu);
}
- fSamplerPoolManager.freeGPUResources(gpu);
-
if (fUniformDescriptorSet) {
fUniformDescriptorSet->recycle(const_cast<GrVkGpu*>(gpu));
fUniformDescriptorSet = nullptr;
}
+ if (fSamplerDescriptorSet) {
+ fSamplerDescriptorSet->recycle(const_cast<GrVkGpu*>(gpu));
+ fSamplerDescriptorSet = nullptr;
+ }
+
this->freeTempResources(gpu);
}
@@ -158,12 +161,15 @@ void GrVkPipelineState::abandonGPUResources() {
}
fTextures.rewind();
- fSamplerPoolManager.abandonGPUResources();
-
if (fUniformDescriptorSet) {
fUniformDescriptorSet->unrefAndAbandon();
fUniformDescriptorSet = nullptr;
}
+
+ if (fSamplerDescriptorSet) {
+ fSamplerDescriptorSet->unrefAndAbandon();
+ fSamplerDescriptorSet = nullptr;
+ }
}
static void append_texture_bindings(const GrProcessor& processor,
@@ -204,8 +210,12 @@ void GrVkPipelineState::setData(GrVkGpu* gpu,
// Get new descriptor sets
if (fNumSamplers) {
- fSamplerPoolManager.getNewDescriptorSet(gpu,
- &fDescriptorSets[GrVkUniformHandler::kSamplerDescSet]);
+ if (fSamplerDescriptorSet) {
+ fSamplerDescriptorSet->recycle(gpu);
+ }
+ fSamplerDescriptorSet = gpu->resourceProvider().getSamplerDescriptorSet(fSamplerDSHandle);
+ int samplerDSIdx = GrVkUniformHandler::kSamplerDescSet;
+ fDescriptorSets[samplerDSIdx] = fSamplerDescriptorSet->descriptorSet();
this->writeSamplers(gpu, textureBindings, pipeline.getAllowSRGBInputs());
}
@@ -365,13 +375,13 @@ void GrVkPipelineState::bind(const GrVkGpu* gpu, GrVkCommandBuffer* commandBuffe
}
void GrVkPipelineState::addUniformResources(GrVkCommandBuffer& commandBuffer) {
- if (fSamplerPoolManager.fPool) {
- commandBuffer.addResource(fSamplerPoolManager.fPool);
- }
-
if (fUniformDescriptorSet) {
commandBuffer.addRecycledResource(fUniformDescriptorSet);
}
+ if (fSamplerDescriptorSet) {
+ commandBuffer.addRecycledResource(fSamplerDescriptorSet);
+ }
+
if (fVertexUniformBuffer.get()) {
commandBuffer.addResource(fVertexUniformBuffer->resource());
« 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