class PlatformSemaphore

Defined at line 39 of file ../../src/graphics/magma/lib/magma/platform/platform_semaphore.h

Semantics of PlatformSemaphore match Vulkan semaphores. From:

https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#synchronization-semaphores

"Semaphores are a synchronization primitive that can be used to insert a dependency between

batches submitted to queues. Semaphores have two states - signaled and unsignaled. The state

of a semaphore can be signaled after execution of a batch of commands is completed. A batch

can wait for a semaphore to become signaled before it begins execution, and the semaphore is

also unsignaled before the batch begins execution."

"Unlike fences or events, the act of waiting for a semaphore also unsignals that semaphore.

If two operations are separately specified to wait for the same semaphore, and there are no

other execution dependencies between those operations, behaviour is undefined. An execution

dependency must be present that guarantees that the semaphore unsignal operation for the first

of those waits, happens-before the semaphore is signalled again, and before the second unsignal

operation. Semaphore waits and signals should thus occur in discrete 1:1 pairs."

Public Methods

void PlatformSemaphore (uint64_t flags)

Defined at line 43 of file ../../src/graphics/magma/lib/magma/platform/platform_semaphore.h

void ~PlatformSemaphore ()

Defined at line 51 of file ../../src/graphics/magma/lib/magma/platform/platform_semaphore.h

bool is_one_shot ()

Defined at line 53 of file ../../src/graphics/magma/lib/magma/platform/platform_semaphore.h

std::unique_ptr<PlatformSemaphore> Clone ()

Defined at line 59 of file ../../src/graphics/magma/lib/magma/platform/platform_semaphore.h

std::unique_ptr<PlatformSemaphore> Create ()

///////////////////////////////////////////////////////////////////////////////////////////////

Defined at line 73 of file ../../src/graphics/magma/lib/magma/platform/zircon/zircon_platform_semaphore.cc

std::unique_ptr<PlatformSemaphore> Import (uint32_t handle, uint64_t flags)

Imports and takes ownership of |handle|.

Defined at line 86 of file ../../src/graphics/magma/lib/magma/platform/zircon/zircon_platform_semaphore.cc

std::unique_ptr<PlatformSemaphore> Import (zx::handle handle, uint64_t flags)

Defined at line 90 of file ../../src/graphics/magma/lib/magma/platform/zircon/zircon_platform_semaphore.cc

zx_signals_t GetZxSignal ()
void Signal ()

Signal the semaphore. State must be unsignalled.

Called only by the driver device thread.

void Reset ()

Resets the state to unsignalled. State may be signalled or unsignalled.

Called by the client (apps thread) and by the driver device thread.

magma::Status WaitNoReset (uint64_t timeout_ms)

Returns MAGMA_STATUS_OK if the event is signaled before the timeout expires.

magma::Status Wait (uint64_t timeout_ms)

If the event is signaled before the timeout expires, resets the state to

unsignalled (if not one shot) and returns MAGMA_STATUS_OK. Only one thread

should ever wait on a given semaphore.

magma::Status Wait ()

Defined at line 82 of file ../../src/graphics/magma/lib/magma/platform/platform_semaphore.h

bool GetTimestamp (uint64_t * timestamp_ns_out)

Returns true if timestamps are supported; sets |timestamp_ns_out| to the time of the

last status change.

Defined at line 91 of file ../../src/graphics/magma/lib/magma/platform/platform_semaphore.h

bool WaitAsync (PlatformPort * port, uint64_t key)

Registers an async wait delivered on the given port when this semaphore is signalled.

Note that a port wait completion will not autoreset the semaphore.

On success returns true.