Vulkan: Unbind Uniform Buffers When Destroyed #108742

Merged
Jeroen Bakker merged 1 commits from Jeroen-Bakker/blender:vulkan-unbind-deleted-uniform-buffers into main 2023-06-08 09:46:05 +02:00
3 changed files with 13 additions and 5 deletions
Showing only changes of commit 381a8387e8 - Show all commits

View File

@ -14,6 +14,11 @@
namespace blender::gpu {
VKUniformBuffer::~VKUniformBuffer()
{
unbind();
}
void VKUniformBuffer::update(const void *data)
{
if (!buffer_.is_allocated()) {
@ -68,8 +73,10 @@ void VKUniformBuffer::bind_as_ssbo(int slot)
void VKUniformBuffer::unbind()
{
VKContext &context = *VKContext::get();
context.state_manager_get().uniform_buffer_unbind(this);
VKContext *context = VKContext::get();
if (context) {
context->state_manager_get().uniform_buffer_unbind(this);
}
}
} // namespace blender::gpu

View File

@ -21,6 +21,7 @@ class VKUniformBuffer : public UniformBuf, NonCopyable {
public:
VKUniformBuffer(int size, const char *name) : UniformBuf(size, name) {}
~VKUniformBuffer();
void update(const void *data) override;
void clear_to_zero() override;

View File

@ -119,9 +119,9 @@ void VKVertexBuffer::resize_data()
void VKVertexBuffer::release_data()
{
if (should_unbind_) {
VKContext &context = *VKContext::get();
context.state_manager_get().texel_buffer_unbind(this);
VKContext *context = VKContext::get();
if (should_unbind_ && context) {
context->state_manager_get().texel_buffer_unbind(this);
}
if (vk_buffer_view_ != VK_NULL_HANDLE) {