The current Vulkan resource management has some issues as context that are not active can still use resources that are freed via another context. When this happens incorrect data can be read on the GPU and even crash Blender. When trying to bind something that now contains other memory pointers. This change introduces that contexts are tracked via the device. Context will be registered/unregistered with the device instance. Unbinding of resources must pass the device and the device will check all registered contexts. Binding of resources will happen via the active context only. On user perspective this now allowes: - Opening/switching files - Switching workspaces - Switching render engines Pull Request: https://projects.blender.org/blender/blender/pulls/108968
36 lines
574 B
C++
36 lines
574 B
C++
/* SPDX-FileCopyrightText: 2023 Blender Foundation
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/** \file
|
|
* \ingroup gpu
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "gpu_shader_private.hh"
|
|
|
|
#include "vk_common.hh"
|
|
|
|
#include "BLI_utility_mixins.hh"
|
|
|
|
namespace blender::gpu {
|
|
class VKContext;
|
|
|
|
class VKSampler : public NonCopyable {
|
|
VkSampler vk_sampler_ = VK_NULL_HANDLE;
|
|
|
|
public:
|
|
virtual ~VKSampler();
|
|
void create();
|
|
void free();
|
|
|
|
VkSampler vk_handle() const
|
|
{
|
|
BLI_assert(vk_sampler_ != VK_NULL_HANDLE);
|
|
return vk_sampler_;
|
|
}
|
|
};
|
|
|
|
} // namespace blender::gpu
|