Skip to content

Commit

Permalink
reset descriptor pools if empty when exceeded
Browse files Browse the repository at this point in the history
  • Loading branch information
fabmax committed Feb 4, 2025
1 parent a1e9786 commit 63dedcd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class ReflectionDenoisePass(reflectionPass: OffscreenPass2d) :
}

fun setPositionInput(materialPass: MaterialPass) {
denoiseShader.createdPipeline?.swapPipelineData(materialPass)
denoiseShader.depthTex = materialPass.positionFlags
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class ReflectionPass(val baseReflectionStep: Float) :
}

fun setInput(lightingPass: PbrLightingPass, materialPass: MaterialPass) {
ssrShader.createdPipeline?.swapPipelineData(materialPass)
ssrShader.positionFlags = materialPass.positionFlags
ssrShader.normalRoughness = materialPass.normalRoughness
ssrShader.lightingPass = lightingPass.colorTexture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class BindGroupDataVk(
return
}

backend.descriptorPools.releaseSets(poolLayout, descriptorSets)
descriptorSets = backend.descriptorPools.allocateSets(poolLayout, gpuLayout, this)
val numBindings = uboBindings.size + storageBufferBindings.size + textureBindings.size
val descriptorWrite = callocVkWriteDescriptorSetN(Swapchain.MAX_FRAMES_IN_FLIGHT * numBindings) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,17 @@ class DescriptorPoolManager(val backend: RenderBackendVk) : BaseReleasable() {
sets = pool.allocateSets(layout, numSets, stack)
if (sets == null) {
openPools -= pool
exceededPools += pool

logD { "Descriptor pool exceeded" }
if (pool.allocatedSets.isEmpty()) {
ReleaseQueue.enqueue {
pool.resetPool()
openPools += pool
}
} else {
exceededPools += pool
}

} else {
sets.forEach { allocatedSets[it] = pool }
}
Expand Down Expand Up @@ -121,6 +130,7 @@ class DescriptorPoolManager(val backend: RenderBackendVk) : BaseReleasable() {
}

fun resetPool() {
logD { "Reset descriptor pool" }
backend.device.resetDescriptorPool(descriptorPool)
allocatedSets.clear()
isExceeded = false
Expand Down

0 comments on commit 63dedcd

Please sign in to comment.