@@ -1226,10 +1226,12 @@ void vk_gltf_viewer::vulkan::Frame::recordScenePrepassCommands(vk::CommandBuffer
1226
1226
const bool makeMousePickingResultBufferAvailableToHost = renderingNodes && visit (multilambda {
1227
1227
[&](const vk::Offset2D &offset) {
1228
1228
if (sharedData.gpu .supportShaderBufferInt64Atomics ) {
1229
- cb.updateBuffer <std::uint64_t >(gltfAsset->mousePickingResultBuffer , 0 , NO_INDEX);
1229
+ constexpr std::uint64_t initialValue = NO_INDEX;
1230
+ sharedData.gpu .allocator .copyMemoryToAllocation (&initialValue, gltfAsset->mousePickingResultBuffer .allocation , 0 , sizeof (initialValue));
1230
1231
}
1231
1232
else {
1232
- cb.updateBuffer <std::uint32_t >(gltfAsset->mousePickingResultBuffer , 0 , NO_INDEX);
1233
+ constexpr std::uint32_t initialValue = NO_INDEX;
1234
+ sharedData.gpu .allocator .copyMemoryToAllocation (&initialValue, gltfAsset->mousePickingResultBuffer .allocation , 0 , sizeof (initialValue));
1233
1235
}
1234
1236
1235
1237
if (renderingNodes->startMousePickingRenderPass ) {
@@ -1303,7 +1305,13 @@ void vk_gltf_viewer::vulkan::Frame::recordScenePrepassCommands(vk::CommandBuffer
1303
1305
},
1304
1306
[&](const vk::Rect2D &rect) {
1305
1307
// Clear mousePickingResultBuffer as zeros.
1308
+ #if __APPLE__
1309
+ // Filling buffer with a value needs MTLBlitCommandEncoder in Metal, and it breaks the render pass.
1310
+ // It is better to use host memset for this purpose.
1311
+ std::memset (gltfAsset->mousePickingResultBuffer .data , 0 , gltfAsset->mousePickingResultBuffer .size );
1312
+ #else
1306
1313
cb.fillBuffer (gltfAsset->mousePickingResultBuffer , 0 , gltfAsset->mousePickingResultBuffer .size , 0U );
1314
+ #endif
1307
1315
1308
1316
if (rect.extent .width == 0 || rect.extent .height == 0 ) {
1309
1317
// Do nothing.
0 commit comments