#include <ggi/ggi.h> int ggiResourceAcquire(ggi_resource_t res, uint32_t actype); int ggiResourceRelease(ggi_resource_t res); int ggiResourceMustAcquire(ggi_resource_t res);
ggiResourceRelease releases (unlocks) an already-acquired resource.
ggiResourceMustAcquire determines whether or not the specified resource needs to be acquired before using.
ggiResourceMustAcquire is simply a macro that returns true if the resource must be explicitly acquired and released, or false if not. However, it is still safe to call ggiResourceAcquire or ggiResourceRelease even in the latter case; it would be a no-op.
const ggi_directbuffer *dbuf; /* Acquire DirectBuffer before we use it. */ if (ggiResourceAcquire(dbuf->resource, GGI_ACTYPE_WRITE) != 0) { fail("Error acquiring DirectBuffer\n"); } /* Do framebuffer rendering here... */ /* Release DirectBuffer when done with it. */ ggiResourceRelease(dbuf->resource);