Vulkan: Unbind Uniform Buffers When Destroyed #108742
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue