core: Fix dynamic texture resource management (#4337)

This commit is contained in:
Adrian Cojocaru
2026-06-23 18:39:50 +03:00
committed by GitHub
parent 0724dcf58d
commit e7a373b013
16 changed files with 120 additions and 69 deletions

View File

@@ -146,7 +146,11 @@ void Context::initFrameResources() {
void Context::destroyResources() {
MBGL_VERIFY_THREAD(tid);
backend.getDevice()->waitIdle(backend.getDispatcher());
try {
backend.getDevice()->waitIdle(backend.getDispatcher());
} catch (const vk::DeviceLostError& error) {
Log::Error(mbgl::Event::Render, "Vulkan device lost during context shutdown");
}
for (auto& frame : frameResources) {
frame.runDeletionQueue(*this);
@@ -767,8 +771,23 @@ const vk::UniquePipelineLayout& Context::getPushConstantPipelineLayout() {
const auto stages = vk::ShaderStageFlags() | vk::ShaderStageFlagBits::eVertex | vk::ShaderStageFlagBits::eFragment;
const auto pushConstant = vk::PushConstantRange().setSize(sizeof(matf4)).setStageFlags(stages);
auto layoutInfo = vk::PipelineLayoutCreateInfo().setPushConstantRanges(pushConstant);
#ifdef ENABLE_VULKAN_GPU_ASSISTED_VALIDATION
// GPU assisted validation crashes when using a pipeline without descriptors.
// Use a compatible layout with the general pipeline when enabled
const std::vector<vk::DescriptorSetLayout> layouts = {
globalUniformDescriptorSetLayout.get(),
layerUniformDescriptorSetLayout.get(),
drawableUniformDescriptorSetLayout.get(),
drawableImageDescriptorSetLayout.get(),
};
layoutInfo.setSetLayouts(layouts);
#endif
pushConstantPipelineLayout = backend.getDevice()->createPipelineLayoutUnique(
vk::PipelineLayoutCreateInfo().setPushConstantRanges(pushConstant), nullptr, backend.getDispatcher());
layoutInfo, nullptr, backend.getDispatcher());
backend.setDebugName(pushConstantPipelineLayout.get(), "PipelineLayout_pushConstants");