anv: Add a real semaphore struct

It's just a dummy for now, but we'll flesh it out as needed for external
semaphores.

Reviewed-by: Chad Versace <chadversary@chromium.org>
This commit is contained in:
Jason Ekstrand
2017-02-15 15:35:38 -08:00
parent f466683cb0
commit 65aa89e75f
2 changed files with 55 additions and 7 deletions

View File

@@ -1706,6 +1706,33 @@ struct anv_event {
struct anv_state state;
};
enum anv_semaphore_type {
ANV_SEMAPHORE_TYPE_NONE = 0,
ANV_SEMAPHORE_TYPE_DUMMY
};
struct anv_semaphore_impl {
enum anv_semaphore_type type;
};
struct anv_semaphore {
/* Permanent semaphore state. Every semaphore has some form of permanent
* state (type != ANV_SEMAPHORE_TYPE_NONE). This may be a BO to fence on
* (for cross-process semaphores0 or it could just be a dummy for use
* internally.
*/
struct anv_semaphore_impl permanent;
/* Temporary semaphore state. A semaphore *may* have temporary state.
* That state is added to the semaphore by an import operation and is reset
* back to ANV_SEMAPHORE_TYPE_NONE when the semaphore is waited on. A
* semaphore with temporary state cannot be signaled because the semaphore
* must already be signaled before the temporary state can be exported from
* the semaphore in the other process and imported here.
*/
struct anv_semaphore_impl temporary;
};
struct anv_shader_module {
unsigned char sha1[20];
uint32_t size;
@@ -2316,6 +2343,7 @@ ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_pipeline_layout, VkPipelineLayout)
ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_query_pool, VkQueryPool)
ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_render_pass, VkRenderPass)
ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_sampler, VkSampler)
ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_semaphore, VkSemaphore)
ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_shader_module, VkShaderModule)
/* Gen-specific function declarations */

View File

@@ -493,23 +493,43 @@ done:
// Queue semaphore functions
VkResult anv_CreateSemaphore(
VkDevice device,
VkDevice _device,
const VkSemaphoreCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkSemaphore* pSemaphore)
{
/* The DRM execbuffer ioctl always execute in-oder, even between different
* rings. As such, there's nothing to do for the user space semaphore.
*/
ANV_FROM_HANDLE(anv_device, device, _device);
struct anv_semaphore *semaphore;
*pSemaphore = (VkSemaphore)1;
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO);
semaphore = vk_alloc2(&device->alloc, pAllocator, sizeof(*semaphore), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (semaphore == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
/* The DRM execbuffer ioctl always execute in-oder, even between
* different rings. As such, a dummy no-op semaphore is a perfectly
* valid implementation.
*/
semaphore->permanent.type = ANV_SEMAPHORE_TYPE_DUMMY;
semaphore->temporary.type = ANV_SEMAPHORE_TYPE_NONE;
*pSemaphore = anv_semaphore_to_handle(semaphore);
return VK_SUCCESS;
}
void anv_DestroySemaphore(
VkDevice device,
VkSemaphore semaphore,
VkDevice _device,
VkSemaphore _semaphore,
const VkAllocationCallbacks* pAllocator)
{
ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(anv_semaphore, semaphore, _semaphore);
if (semaphore == NULL)
return;
vk_free2(&device->alloc, pAllocator, semaphore);
}