KhronosGroup / MoltenVK

MoltenVK is a Vulkan Portability implementation. It layers a subset of the high-performance, industry-standard Vulkan graphics and compute API over Apple's Metal graphics framework, enabling Vulkan applications to run on macOS, iOS and tvOS.
Apache License 2.0
4.64k stars 402 forks source link

VK_EXT_metal_objects: vkCreateSemaphore() always creates timeline semaphore when exportObjectType == VK_EXPORT_METAL_OBJECT_TYPE_METAL_SHARED_EVENT_BIT_EXT #1631

Open bangnoise opened 2 years ago

bangnoise commented 2 years ago

I'm not sure what the intended use is of exporting a MTLSharedEvent from a binary semaphore, because the underlying mechanism to manage the MTLSharedEvent's increasing value is not exposed, rendering the MTLSharedEvent next to useless.

That said, if one does try to create an exportable binary semaphore, a timeline semaphore is erroneously created in MVKDevice::createSemaphore() whenever VkExportMetalObjectCreateInfoEXT::exportObjectType is VK_EXPORT_METAL_OBJECT_TYPE_METAL_SHARED_EVENT_BIT_EXT.

billhollings commented 1 year ago

a timeline semaphore is erroneously created

Hmmm...a timeline semaphore and its embedded MTLSharedEvent should behave like binaries...unless manipulated by the app setting timeline values or invoking timeline behavior. Perhaps that's not happening accurately, and we may need to rework some things.

What is the effect of this happening, and where do behavioral errors appear in your use case?

bangnoise commented 1 year ago

When a MVKTimelineSemaphoreMTLEvent is used as a binary semaphore, the value ultimately passed to -encodeSignalEvent:value: is always 0, meaning they are always signalled.