static const uint32_t BATCH_SIZE = 8192;
VkResult anv_CreateDevice(
- VkPhysicalDevice _physicalDevice,
+ VkPhysicalDevice physicalDevice,
const VkDeviceCreateInfo* pCreateInfo,
VkDevice* pDevice)
{
- struct anv_physical_device *physicalDevice =
- (struct anv_physical_device *) _physicalDevice;
- struct anv_instance *instance = physicalDevice->instance;
+ ANV_FROM_HANDLE(anv_physical_device, physical_device, physicalDevice);
+ struct anv_instance *instance = physical_device->instance;
struct anv_device *device;
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO);
if (!device)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
- device->no_hw = physicalDevice->no_hw;
+ device->no_hw = physical_device->no_hw;
parse_debug_flags(device);
- device->instance = physicalDevice->instance;
- device->fd = open(physicalDevice->path, O_RDWR | O_CLOEXEC);
+ device->instance = physical_device->instance;
+ device->fd = open(physical_device->path, O_RDWR | O_CLOEXEC);
if (device->fd == -1)
goto fail_device;
anv_block_pool_init(&device->scratch_block_pool, device, 0x10000);
- device->info = *physicalDevice->info;
+ device->info = *physical_device->info;
device->compiler = anv_compiler_create(device);
device->aub_writer = NULL;
VkResult anv_DestroyDevice(
VkDevice _device)
{
- struct anv_device *device = (struct anv_device *) _device;
+ ANV_FROM_HANDLE(anv_device, device, _device);
anv_compiler_destroy(device->compiler);
uint32_t queueIndex,
VkQueue* pQueue)
{
- struct anv_device *device = (struct anv_device *) _device;
+ ANV_FROM_HANDLE(anv_device, device, _device);
assert(queueIndex == 0);
const VkCmdBuffer* pCmdBuffers,
VkFence _fence)
{
- struct anv_queue *queue = (struct anv_queue *) _queue;
+ ANV_FROM_HANDLE(anv_queue, queue, _queue);
+ ANV_FROM_HANDLE(anv_fence, fence, _fence);
struct anv_device *device = queue->device;
- struct anv_fence *fence = (struct anv_fence *) _fence;
int ret;
for (uint32_t i = 0; i < cmdBufferCount; i++) {
- struct anv_cmd_buffer *cmd_buffer =
- (struct anv_cmd_buffer *) pCmdBuffers[i];
+ ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, pCmdBuffers[i]);
if (device->dump_aub)
anv_cmd_buffer_dump(cmd_buffer);
VkResult anv_QueueWaitIdle(
VkQueue _queue)
{
- struct anv_queue *queue = (struct anv_queue *) _queue;
+ ANV_FROM_HANDLE(anv_queue, queue, _queue);
return vkDeviceWaitIdle((VkDevice) queue->device);
}
VkResult anv_DeviceWaitIdle(
VkDevice _device)
{
- struct anv_device *device = (struct anv_device *) _device;
+ ANV_FROM_HANDLE(anv_device, device, _device);
struct anv_state state;
struct anv_batch batch;
struct drm_i915_gem_execbuffer2 execbuf;
const VkMemoryAllocInfo* pAllocInfo,
VkDeviceMemory* pMem)
{
- struct anv_device *device = (struct anv_device *) _device;
+ ANV_FROM_HANDLE(anv_device, device, _device);
struct anv_device_memory *mem;
VkResult result;
*pMem = (VkDeviceMemory) mem;
- return VK_SUCCESS;
+ return VK_SUCCESS;
fail:
anv_device_free(device, mem);
VkDevice _device,
VkDeviceMemory _mem)
{
- struct anv_device *device = (struct anv_device *) _device;
- struct anv_device_memory *mem = (struct anv_device_memory *) _mem;
+ ANV_FROM_HANDLE(anv_device, device, _device);
+ ANV_FROM_HANDLE(anv_device_memory, mem, _mem);
if (mem->bo.map)
anv_gem_munmap(mem->bo.map, mem->bo.size);
VkMemoryMapFlags flags,
void** ppData)
{
- struct anv_device *device = (struct anv_device *) _device;
- struct anv_device_memory *mem = (struct anv_device_memory *) _mem;
+ ANV_FROM_HANDLE(anv_device, device, _device);
+ ANV_FROM_HANDLE(anv_device_memory, mem, _mem);
/* FIXME: Is this supposed to be thread safe? Since vkUnmapMemory() only
* takes a VkDeviceMemory pointer, it seems like only one map of the memory
VkDevice _device,
VkDeviceMemory _mem)
{
- struct anv_device_memory *mem = (struct anv_device_memory *) _mem;
+ ANV_FROM_HANDLE(anv_device_memory, mem, _mem);
anv_gem_munmap(mem->map, mem->map_size);
VkObjectType objType,
VkObject _object)
{
- struct anv_device *device = (struct anv_device *) _device;
+ ANV_FROM_HANDLE(anv_device, device, _device);
struct anv_object *object = (struct anv_object *) _object;
switch (objType) {
VkDeviceMemory _mem,
VkDeviceSize memOffset)
{
+ ANV_FROM_HANDLE(anv_device_memory, mem, _mem);
struct anv_buffer *buffer;
struct anv_image *image;
- struct anv_device_memory *mem = (struct anv_device_memory *) _mem;
switch (objType) {
case VK_OBJECT_TYPE_BUFFER:
const VkFenceCreateInfo* pCreateInfo,
VkFence* pFence)
{
- struct anv_device *device = (struct anv_device *) _device;
+ ANV_FROM_HANDLE(anv_device, device, _device);
struct anv_fence *fence;
struct anv_batch batch;
VkResult result;
VkDevice _device,
VkFence _fence)
{
- struct anv_device *device = (struct anv_device *) _device;
- struct anv_fence *fence = (struct anv_fence *) _fence;
+ ANV_FROM_HANDLE(anv_device, device, _device);
+ ANV_FROM_HANDLE(anv_fence, fence, _fence);
int64_t t = 0;
int ret;
const VkDynamicVpStateCreateInfo* pCreateInfo,
VkDynamicVpState* pState)
{
- struct anv_device *device = (struct anv_device *) _device;
+ ANV_FROM_HANDLE(anv_device, device, _device);
struct anv_dynamic_vp_state *state;
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_DYNAMIC_VP_STATE_CREATE_INFO);
const VkDynamicRsStateCreateInfo* pCreateInfo,
VkDynamicRsState* pState)
{
- struct anv_device *device = (struct anv_device *) _device;
+ ANV_FROM_HANDLE(anv_device, device, _device);
struct anv_dynamic_rs_state *state;
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_DYNAMIC_RS_STATE_CREATE_INFO);
const VkDynamicCbStateCreateInfo* pCreateInfo,
VkDynamicCbState* pState)
{
- struct anv_device *device = (struct anv_device *) _device;
+ ANV_FROM_HANDLE(anv_device, device, _device);
struct anv_dynamic_cb_state *state;
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_DYNAMIC_CB_STATE_CREATE_INFO);
const VkDynamicDsStateCreateInfo* pCreateInfo,
VkDynamicDsState* pState)
{
- struct anv_device *device = (struct anv_device *) _device;
+ ANV_FROM_HANDLE(anv_device, device, _device);
struct anv_dynamic_ds_state *state;
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_DYNAMIC_DS_STATE_CREATE_INFO);
const VkCmdBufferCreateInfo* pCreateInfo,
VkCmdBuffer* pCmdBuffer)
{
- struct anv_device *device = (struct anv_device *) _device;
+ ANV_FROM_HANDLE(anv_device, device, _device);
struct anv_cmd_buffer *cmd_buffer;
VkResult result;
VkCmdBuffer cmdBuffer,
const VkCmdBufferBeginInfo* pBeginInfo)
{
- struct anv_cmd_buffer *cmd_buffer = (struct anv_cmd_buffer *) cmdBuffer;
+ ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer);
anv_cmd_buffer_emit_state_base_address(cmd_buffer);
cmd_buffer->current_pipeline = UINT32_MAX;
VkResult anv_EndCommandBuffer(
VkCmdBuffer cmdBuffer)
{
- struct anv_cmd_buffer *cmd_buffer = (struct anv_cmd_buffer *) cmdBuffer;
+ ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer);
struct anv_device *device = cmd_buffer->device;
struct anv_batch *batch = &cmd_buffer->batch;
VkResult anv_ResetCommandBuffer(
VkCmdBuffer cmdBuffer)
{
- struct anv_cmd_buffer *cmd_buffer = (struct anv_cmd_buffer *) cmdBuffer;
+ ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer);
/* Delete all but the first batch bo */
while (cmd_buffer->last_batch_bo->prev_batch_bo) {
VkPipelineBindPoint pipelineBindPoint,
VkPipeline _pipeline)
{
- struct anv_cmd_buffer *cmd_buffer = (struct anv_cmd_buffer *) cmdBuffer;
- struct anv_pipeline *pipeline = (struct anv_pipeline *) _pipeline;
+ ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer);
+ ANV_FROM_HANDLE(anv_pipeline, pipeline, _pipeline);
switch (pipelineBindPoint) {
case VK_PIPELINE_BIND_POINT_COMPUTE:
VkStateBindPoint stateBindPoint,
VkDynamicStateObject dynamicState)
{
- struct anv_cmd_buffer *cmd_buffer = (struct anv_cmd_buffer *) cmdBuffer;
+ ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer);
switch (stateBindPoint) {
case VK_STATE_BIND_POINT_VIEWPORT:
uint32_t dynamicOffsetCount,
const uint32_t* pDynamicOffsets)
{
- struct anv_cmd_buffer *cmd_buffer = (struct anv_cmd_buffer *) cmdBuffer;
- struct anv_pipeline_layout *layout = (struct anv_pipeline_layout *) _layout;
- struct anv_descriptor_set *set;
+ ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer);
+ ANV_FROM_HANDLE(anv_pipeline_layout, layout, _layout);
struct anv_descriptor_set_layout *set_layout;
assert(firstSet + setCount < MAX_SETS);
uint32_t dynamic_slot = 0;
for (uint32_t i = 0; i < setCount; i++) {
- set = (struct anv_descriptor_set *) pDescriptorSets[i];
+ ANV_FROM_HANDLE(anv_descriptor_set, set, pDescriptorSets[i]);
set_layout = layout->set[firstSet + i].layout;
cmd_buffer->descriptors[firstSet + i].set = set;
VkDeviceSize offset,
VkIndexType indexType)
{
- struct anv_cmd_buffer *cmd_buffer = (struct anv_cmd_buffer *) cmdBuffer;
- struct anv_buffer *buffer = (struct anv_buffer *) _buffer;
+ ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer);
+ ANV_FROM_HANDLE(anv_buffer, buffer, _buffer);
static const uint32_t vk_to_gen_index_type[] = {
[VK_INDEX_TYPE_UINT16] = INDEX_WORD,
const VkBuffer* pBuffers,
const VkDeviceSize* pOffsets)
{
- struct anv_cmd_buffer *cmd_buffer = (struct anv_cmd_buffer *) cmdBuffer;
+ ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer);
struct anv_vertex_binding *vb = cmd_buffer->vertex_bindings;
/* We have to defer setting up vertex buffer since we need the buffer
uint32_t firstInstance,
uint32_t instanceCount)
{
- struct anv_cmd_buffer *cmd_buffer = (struct anv_cmd_buffer *) cmdBuffer;
+ ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer);
anv_cmd_buffer_flush_state(cmd_buffer);
uint32_t firstInstance,
uint32_t instanceCount)
{
- struct anv_cmd_buffer *cmd_buffer = (struct anv_cmd_buffer *) cmdBuffer;
+ ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer);
anv_cmd_buffer_flush_state(cmd_buffer);
uint32_t count,
uint32_t stride)
{
- struct anv_cmd_buffer *cmd_buffer = (struct anv_cmd_buffer *) cmdBuffer;
- struct anv_buffer *buffer = (struct anv_buffer *) _buffer;
+ ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer);
+ ANV_FROM_HANDLE(anv_buffer, buffer, _buffer);
struct anv_bo *bo = buffer->bo;
uint32_t bo_offset = buffer->offset + offset;
uint32_t count,
uint32_t stride)
{
- struct anv_cmd_buffer *cmd_buffer = (struct anv_cmd_buffer *) cmdBuffer;
- struct anv_buffer *buffer = (struct anv_buffer *) _buffer;
+ ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer);
+ ANV_FROM_HANDLE(anv_buffer, buffer, _buffer);
struct anv_bo *bo = buffer->bo;
uint32_t bo_offset = buffer->offset + offset;
uint32_t y,
uint32_t z)
{
- struct anv_cmd_buffer *cmd_buffer = (struct anv_cmd_buffer *) cmdBuffer;
+ ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer);
struct anv_pipeline *pipeline = cmd_buffer->compute_pipeline;
struct brw_cs_prog_data *prog_data = &pipeline->cs_prog_data;
VkBuffer _buffer,
VkDeviceSize offset)
{
- struct anv_cmd_buffer *cmd_buffer = (struct anv_cmd_buffer *) cmdBuffer;
+ ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer);
+ ANV_FROM_HANDLE(anv_buffer, buffer, _buffer);
struct anv_pipeline *pipeline = cmd_buffer->compute_pipeline;
struct brw_cs_prog_data *prog_data = &pipeline->cs_prog_data;
- struct anv_buffer *buffer = (struct anv_buffer *) _buffer;
struct anv_bo *bo = buffer->bo;
uint32_t bo_offset = buffer->offset + offset;
uint32_t memBarrierCount,
const void* const* ppMemBarriers)
{
- struct anv_cmd_buffer *cmd_buffer = (struct anv_cmd_buffer *)cmdBuffer;
+ ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer);
uint32_t b, *dw;
struct GEN8_PIPE_CONTROL cmd = {
const VkFramebufferCreateInfo* pCreateInfo,
VkFramebuffer* pFramebuffer)
{
- struct anv_device *device = (struct anv_device *) _device;
+ ANV_FROM_HANDLE(anv_device, device, _device);
struct anv_framebuffer *framebuffer;
static const struct anv_depth_stencil_view null_view =
const VkRenderPassCreateInfo* pCreateInfo,
VkRenderPass* pRenderPass)
{
- struct anv_device *device = (struct anv_device *) _device;
+ ANV_FROM_HANDLE(anv_device, device, _device);
struct anv_render_pass *pass;
size_t size;
VkCmdBuffer cmdBuffer,
const VkRenderPassBegin* pRenderPassBegin)
{
- struct anv_cmd_buffer *cmd_buffer = (struct anv_cmd_buffer *) cmdBuffer;
- struct anv_render_pass *pass = (struct anv_render_pass *) pRenderPassBegin->renderPass;
- struct anv_framebuffer *framebuffer =
- (struct anv_framebuffer *) pRenderPassBegin->framebuffer;
+ ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer);
+ ANV_FROM_HANDLE(anv_render_pass, pass, pRenderPassBegin->renderPass);
+ ANV_FROM_HANDLE(anv_framebuffer, framebuffer, pRenderPassBegin->framebuffer);
assert(pRenderPassBegin->contents == VK_RENDER_PASS_CONTENTS_INLINE);
void anv_CmdEndRenderPass(
VkCmdBuffer cmdBuffer)
{
+ ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer);
+
/* Emit a flushing pipe control at the end of a pass. This is kind of a
* hack but it ensures that render targets always actually get written.
* Eventually, we should do flushing based on image format transitions
* or something of that nature.
*/
- struct anv_cmd_buffer *cmd_buffer = (struct anv_cmd_buffer *)cmdBuffer;
anv_batch_emit(&cmd_buffer->batch, GEN8_PIPE_CONTROL,
.PostSyncOperation = NoWrite,
.RenderTargetCacheFlushEnable = true,