[Vulkan] Cache clear: shared memory, scratch buffer

This commit is contained in:
Triang3l 2022-06-29 13:24:45 +03:00
parent d5815d9e6a
commit 7c2df55209
2 changed files with 28 additions and 8 deletions

View File

@ -979,10 +979,7 @@ void VulkanCommandProcessor::ShutdownContext() {
const ui::vulkan::VulkanProvider::DeviceFunctions& dfn = provider.dfn();
VkDevice device = provider.device();
ui::vulkan::util::DestroyAndNullHandle(dfn.vkDestroyBuffer, device,
scratch_buffer_);
ui::vulkan::util::DestroyAndNullHandle(dfn.vkFreeMemory, device,
scratch_buffer_memory_);
DestroyScratchBuffer();
for (SwapFramebuffer& swap_framebuffer : swap_framebuffers_) {
ui::vulkan::util::DestroyAndNullHandle(dfn.vkDestroyFramebuffer, device,
@ -3064,6 +3061,13 @@ bool VulkanCommandProcessor::EndSubmission(bool is_swap) {
if (cache_clear_requested_ && AwaitAllQueueOperationsCompletion()) {
cache_clear_requested_ = false;
DestroyScratchBuffer();
for (SwapFramebuffer& swap_framebuffer : swap_framebuffers_) {
ui::vulkan::util::DestroyAndNullHandle(dfn.vkDestroyFramebuffer, device,
swap_framebuffer.framebuffer);
}
assert_true(command_buffers_submitted_.empty());
for (const CommandBuffer& command_buffer : command_buffers_writable_) {
dfn.vkDestroyCommandPool(device, command_buffer.pool, nullptr);
@ -3083,10 +3087,7 @@ bool VulkanCommandProcessor::EndSubmission(bool is_swap) {
primitive_processor_->ClearCache();
for (SwapFramebuffer& swap_framebuffer : swap_framebuffers_) {
ui::vulkan::util::DestroyAndNullHandle(dfn.vkDestroyFramebuffer, device,
swap_framebuffer.framebuffer);
}
shared_memory_->ClearCache();
}
}
@ -3130,6 +3131,23 @@ void VulkanCommandProcessor::SplitPendingBarrier() {
pending_image_memory_barrier_count;
}
void VulkanCommandProcessor::DestroyScratchBuffer() {
assert_false(scratch_buffer_used_);
const ui::vulkan::VulkanProvider& provider = GetVulkanProvider();
const ui::vulkan::VulkanProvider::DeviceFunctions& dfn = provider.dfn();
VkDevice device = provider.device();
scratch_buffer_last_usage_submission_ = 0;
scratch_buffer_last_access_mask_ = 0;
scratch_buffer_last_stage_mask_ = 0;
scratch_buffer_size_ = 0;
ui::vulkan::util::DestroyAndNullHandle(dfn.vkDestroyBuffer, device,
scratch_buffer_);
ui::vulkan::util::DestroyAndNullHandle(dfn.vkFreeMemory, device,
scratch_buffer_memory_);
}
void VulkanCommandProcessor::UpdateDynamicState(
const draw_util::ViewportInfo& viewport_info, bool primitive_polygonal,
reg::RB_DEPTHCONTROL normalized_depth_control) {

View File

@ -447,6 +447,8 @@ class VulkanCommandProcessor : public CommandProcessor {
void SplitPendingBarrier();
void DestroyScratchBuffer();
void UpdateDynamicState(const draw_util::ViewportInfo& viewport_info,
bool primitive_polygonal,
reg::RB_DEPTHCONTROL normalized_depth_control);