Fix #105450: Resolve box selection issue in Metal

Occlusion query buffers not being cleared to zero resulted in
erroneoues selection in certain situations.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/107135
This commit is contained in:
Jason Fielder
2023-04-20 08:47:56 +02:00
committed by Jeroen Bakker
parent dda4c0721c
commit b69f8de5b5

View File

@@ -33,6 +33,11 @@ void MTLQueryPool::allocate()
gpu::MTLBuffer *buffer = MTLContext::get_global_memory_manager()->allocate(buffer_size_in_bytes,
true);
BLI_assert(buffer);
/* We must zero-initialize the query buffer as visibility queries with no draws between
* begin and end will not write any result to the buffer. */
memset(buffer->get_host_ptr(), 0, buffer_size_in_bytes);
buffer->flush();
buffer_.append(buffer);
}