vkr: use the cast functions

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
macos/master
Chia-I Wu 3 years ago
parent ab431feabe
commit c4060e32f7
  1. 6
      src/venus/vkr_buffer.c
  2. 22
      src/venus/vkr_command_buffer.c
  3. 8
      src/venus/vkr_common.h
  4. 2
      src/venus/vkr_descriptor_set.c
  5. 4
      src/venus/vkr_device.c
  6. 8
      src/venus/vkr_device_memory.c
  7. 3
      src/venus/vkr_device_object.py
  8. 4
      src/venus/vkr_image.c
  9. 2
      src/venus/vkr_instance.c
  10. 10
      src/venus/vkr_physical_device.c
  11. 4
      src/venus/vkr_pipeline.c
  12. 2
      src/venus/vkr_query_pool.c
  13. 10
      src/venus/vkr_queue.c
  14. 2
      src/venus/vkr_render_pass.c

@ -14,7 +14,7 @@ vkr_dispatch_vkCreateBuffer(struct vn_dispatch_context *dispatch,
{
struct vkr_context *ctx = dispatch->data;
struct vkr_device *dev = (struct vkr_device *)args->device;
struct vkr_device *dev = vkr_device_from_handle(args->device);
#ifdef FORCE_ENABLE_DMABUF
VkExternalMemoryBufferCreateInfo local_external_info;
@ -90,7 +90,7 @@ vkr_dispatch_vkGetBufferOpaqueCaptureAddress(
UNUSED struct vn_dispatch_context *dispatch,
struct vn_command_vkGetBufferOpaqueCaptureAddress *args)
{
struct vkr_device *dev = (struct vkr_device *)args->device;
struct vkr_device *dev = vkr_device_from_handle(args->device);
vn_replace_vkGetBufferOpaqueCaptureAddress_args_handle(args);
args->ret = dev->GetBufferOpaqueCaptureAddress(args->device, args->pInfo);
@ -100,7 +100,7 @@ static void
vkr_dispatch_vkGetBufferDeviceAddress(UNUSED struct vn_dispatch_context *dispatch,
struct vn_command_vkGetBufferDeviceAddress *args)
{
struct vkr_device *dev = (struct vkr_device *)args->device;
struct vkr_device *dev = vkr_device_from_handle(args->device);
vn_replace_vkGetBufferDeviceAddress_args_handle(args);
args->ret = dev->GetBufferDeviceAddress(args->device, args->pInfo);

@ -508,7 +508,7 @@ static void
vkr_dispatch_vkCmdBeginRenderPass2(UNUSED struct vn_dispatch_context *dispatch,
struct vn_command_vkCmdBeginRenderPass2 *args)
{
struct vkr_command_buffer *cmd = (struct vkr_command_buffer *)args->commandBuffer;
struct vkr_command_buffer *cmd = vkr_command_buffer_from_handle(args->commandBuffer);
vn_replace_vkCmdBeginRenderPass2_args_handle(args);
cmd->device->CmdBeginRenderPass2(args->commandBuffer, args->pRenderPassBegin,
@ -519,7 +519,7 @@ static void
vkr_dispatch_vkCmdNextSubpass2(UNUSED struct vn_dispatch_context *dispatch,
struct vn_command_vkCmdNextSubpass2 *args)
{
struct vkr_command_buffer *cmd = (struct vkr_command_buffer *)args->commandBuffer;
struct vkr_command_buffer *cmd = vkr_command_buffer_from_handle(args->commandBuffer);
vn_replace_vkCmdNextSubpass2_args_handle(args);
cmd->device->CmdNextSubpass2(args->commandBuffer, args->pSubpassBeginInfo,
@ -530,7 +530,7 @@ static void
vkr_dispatch_vkCmdEndRenderPass2(UNUSED struct vn_dispatch_context *dispatch,
struct vn_command_vkCmdEndRenderPass2 *args)
{
struct vkr_command_buffer *cmd = (struct vkr_command_buffer *)args->commandBuffer;
struct vkr_command_buffer *cmd = vkr_command_buffer_from_handle(args->commandBuffer);
vn_replace_vkCmdEndRenderPass2_args_handle(args);
cmd->device->CmdEndRenderPass2(args->commandBuffer, args->pSubpassEndInfo);
@ -540,7 +540,7 @@ static void
vkr_dispatch_vkCmdDrawIndirectCount(UNUSED struct vn_dispatch_context *dispatch,
struct vn_command_vkCmdDrawIndirectCount *args)
{
struct vkr_command_buffer *cmd = (struct vkr_command_buffer *)args->commandBuffer;
struct vkr_command_buffer *cmd = vkr_command_buffer_from_handle(args->commandBuffer);
vn_replace_vkCmdDrawIndirectCount_args_handle(args);
cmd->device->CmdDrawIndirectCount(args->commandBuffer, args->buffer, args->offset,
@ -553,7 +553,7 @@ vkr_dispatch_vkCmdDrawIndexedIndirectCount(
UNUSED struct vn_dispatch_context *dispatch,
struct vn_command_vkCmdDrawIndexedIndirectCount *args)
{
struct vkr_command_buffer *cmd = (struct vkr_command_buffer *)args->commandBuffer;
struct vkr_command_buffer *cmd = vkr_command_buffer_from_handle(args->commandBuffer);
vn_replace_vkCmdDrawIndexedIndirectCount_args_handle(args);
cmd->device->CmdDrawIndexedIndirectCount(
@ -566,7 +566,7 @@ vkr_dispatch_vkCmdBindTransformFeedbackBuffersEXT(
UNUSED struct vn_dispatch_context *dispatch,
struct vn_command_vkCmdBindTransformFeedbackBuffersEXT *args)
{
struct vkr_command_buffer *cmd = (struct vkr_command_buffer *)args->commandBuffer;
struct vkr_command_buffer *cmd = vkr_command_buffer_from_handle(args->commandBuffer);
vn_replace_vkCmdBindTransformFeedbackBuffersEXT_args_handle(args);
cmd->device->cmd_bind_transform_feedback_buffers(
@ -579,7 +579,7 @@ vkr_dispatch_vkCmdBeginTransformFeedbackEXT(
UNUSED struct vn_dispatch_context *dispatch,
struct vn_command_vkCmdBeginTransformFeedbackEXT *args)
{
struct vkr_command_buffer *cmd = (struct vkr_command_buffer *)args->commandBuffer;
struct vkr_command_buffer *cmd = vkr_command_buffer_from_handle(args->commandBuffer);
vn_replace_vkCmdBeginTransformFeedbackEXT_args_handle(args);
cmd->device->cmd_begin_transform_feedback(
@ -592,7 +592,7 @@ vkr_dispatch_vkCmdEndTransformFeedbackEXT(
UNUSED struct vn_dispatch_context *dispatch,
struct vn_command_vkCmdEndTransformFeedbackEXT *args)
{
struct vkr_command_buffer *cmd = (struct vkr_command_buffer *)args->commandBuffer;
struct vkr_command_buffer *cmd = vkr_command_buffer_from_handle(args->commandBuffer);
vn_replace_vkCmdEndTransformFeedbackEXT_args_handle(args);
cmd->device->cmd_end_transform_feedback(
@ -604,7 +604,7 @@ static void
vkr_dispatch_vkCmdBeginQueryIndexedEXT(UNUSED struct vn_dispatch_context *dispatch,
struct vn_command_vkCmdBeginQueryIndexedEXT *args)
{
struct vkr_command_buffer *cmd = (struct vkr_command_buffer *)args->commandBuffer;
struct vkr_command_buffer *cmd = vkr_command_buffer_from_handle(args->commandBuffer);
vn_replace_vkCmdBeginQueryIndexedEXT_args_handle(args);
cmd->device->cmd_begin_query_indexed(args->commandBuffer, args->queryPool, args->query,
@ -615,7 +615,7 @@ static void
vkr_dispatch_vkCmdEndQueryIndexedEXT(UNUSED struct vn_dispatch_context *dispatch,
struct vn_command_vkCmdEndQueryIndexedEXT *args)
{
struct vkr_command_buffer *cmd = (struct vkr_command_buffer *)args->commandBuffer;
struct vkr_command_buffer *cmd = vkr_command_buffer_from_handle(args->commandBuffer);
vn_replace_vkCmdEndQueryIndexedEXT_args_handle(args);
cmd->device->cmd_end_query_indexed(args->commandBuffer, args->queryPool, args->query,
@ -627,7 +627,7 @@ vkr_dispatch_vkCmdDrawIndirectByteCountEXT(
UNUSED struct vn_dispatch_context *dispatch,
struct vn_command_vkCmdDrawIndirectByteCountEXT *args)
{
struct vkr_command_buffer *cmd = (struct vkr_command_buffer *)args->commandBuffer;
struct vkr_command_buffer *cmd = vkr_command_buffer_from_handle(args->commandBuffer);
vn_replace_vkCmdDrawIndirectByteCountEXT_args_handle(args);
cmd->device->cmd_draw_indirect_byte_count(

@ -66,7 +66,7 @@
* These macros may shadow your variables. Use with care.
*/
#define CREATE_OBJECT(obj, vkr_type, vk_obj, vk_cmd, vk_arg) \
struct vkr_device *_dev = (struct vkr_device *)args->device; \
struct vkr_device *_dev = vkr_device_from_handle(args->device); \
\
struct vkr_##vkr_type *obj = vkr_##vkr_type##_create(ctx, args); \
if (!obj) \
@ -75,7 +75,7 @@
list_add(&obj->base.track_head, &_dev->objects)
#define DESTROY_OBJECT(obj, vkr_type, vk_obj, vk_cmd, vk_arg) \
struct vkr_##vkr_type *obj = (struct vkr_##vkr_type *)(uintptr_t)args->vk_arg; \
struct vkr_##vkr_type *obj = vkr_##vkr_type##_from_handle(args->vk_arg); \
if (!obj) \
return; \
\
@ -86,10 +86,10 @@
#define ALLOCATE_POOL_OBJECTS(vkr_type, vk_type, vk_obj, vk_cmd, arg_count, arg_pool, \
vkr_pool_type, vk_pool_type) \
do { \
struct vkr_device *dev = (struct vkr_device *)args->device; \
struct vkr_device *dev = vkr_device_from_handle(args->device); \
\
struct vkr_##vkr_pool_type *pool = \
(struct vkr_##vkr_pool_type *)(uintptr_t)args->pAllocateInfo->arg_pool; \
vkr_##vkr_pool_type##_from_handle(args->pAllocateInfo->arg_pool); \
if (!pool) { \
vkr_cs_decoder_set_fatal(&ctx->decoder); \
return; \

@ -76,7 +76,7 @@ vkr_dispatch_vkResetDescriptorPool(struct vn_dispatch_context *dispatch,
struct vkr_context *ctx = dispatch->data;
struct vkr_descriptor_pool *pool =
(struct vkr_descriptor_pool *)(uintptr_t)args->descriptorPool;
vkr_descriptor_pool_from_handle(args->descriptorPool);
if (!pool) {
vkr_cs_decoder_set_fatal(&ctx->decoder);
return;

@ -150,7 +150,7 @@ vkr_dispatch_vkCreateDevice(struct vn_dispatch_context *dispatch,
struct vkr_context *ctx = dispatch->data;
struct vkr_physical_device *physical_dev =
(struct vkr_physical_device *)args->physicalDevice;
vkr_physical_device_from_handle(args->physicalDevice);
/* append extensions for our own use */
const char **exts = NULL;
@ -365,7 +365,7 @@ vkr_dispatch_vkDestroyDevice(struct vn_dispatch_context *dispatch,
{
struct vkr_context *ctx = dispatch->data;
struct vkr_device *dev = (struct vkr_device *)args->device;
struct vkr_device *dev = vkr_device_from_handle(args->device);
/* this never happens */
if (!dev)
return;

@ -43,7 +43,7 @@ vkr_dispatch_vkAllocateMemory(struct vn_dispatch_context *dispatch,
{
struct vkr_context *ctx = dispatch->data;
struct vkr_device *dev = (struct vkr_device *)args->device;
struct vkr_device *dev = vkr_device_from_handle(args->device);
#ifdef FORCE_ENABLE_DMABUF
VkExportMemoryAllocateInfo local_export_info;
@ -155,7 +155,7 @@ vkr_dispatch_vkFreeMemory(struct vn_dispatch_context *dispatch,
{
struct vkr_context *ctx = dispatch->data;
struct vkr_device_memory *mem = (struct vkr_device_memory *)(uintptr_t)args->memory;
struct vkr_device_memory *mem = vkr_device_memory_from_handle(args->memory);
if (!mem)
return;
@ -182,7 +182,7 @@ vkr_dispatch_vkGetDeviceMemoryOpaqueCaptureAddress(
UNUSED struct vn_dispatch_context *dispatch,
struct vn_command_vkGetDeviceMemoryOpaqueCaptureAddress *args)
{
struct vkr_device *dev = (struct vkr_device *)args->device;
struct vkr_device *dev = vkr_device_from_handle(args->device);
vn_replace_vkGetDeviceMemoryOpaqueCaptureAddress_args_handle(args);
args->ret = dev->GetDeviceMemoryOpaqueCaptureAddress(args->device, args->pInfo);
@ -194,7 +194,7 @@ vkr_dispatch_vkGetMemoryResourcePropertiesMESA(
struct vn_command_vkGetMemoryResourcePropertiesMESA *args)
{
struct vkr_context *ctx = dispatch->data;
struct vkr_device *dev = (struct vkr_device *)args->device;
struct vkr_device *dev = vkr_device_from_handle(args->device);
struct vkr_resource_attachment *att =
util_hash_table_get(ctx->resource_table, uintptr_to_pointer(args->resourceId));

@ -81,7 +81,8 @@ vkr_{destroy_func_name}_destroy_driver_handles(
{{
list_inithead(free_list);
for (uint32_t i = 0; i < args->{destroy_count}; i++) {{
struct vkr_{vkr_type} *obj = (struct vkr_{vkr_type} *)args->{destroy_objs}[i];
struct vkr_{vkr_type} *obj =
vkr_{vkr_type}_from_handle(args->{destroy_objs}[i]);
if (!obj)
continue;

@ -14,7 +14,7 @@ vkr_dispatch_vkCreateImage(struct vn_dispatch_context *dispatch,
{
struct vkr_context *ctx = dispatch->data;
struct vkr_device *dev = (struct vkr_device *)args->device;
struct vkr_device *dev = vkr_device_from_handle(args->device);
#ifdef FORCE_ENABLE_DMABUF
/* Do not chain VkExternalMemoryImageCreateInfo with optimal tiling, so that
@ -126,7 +126,7 @@ vkr_dispatch_vkGetImageDrmFormatModifierPropertiesEXT(
UNUSED struct vn_dispatch_context *dispatch,
struct vn_command_vkGetImageDrmFormatModifierPropertiesEXT *args)
{
struct vkr_device *dev = (struct vkr_device *)args->device;
struct vkr_device *dev = vkr_device_from_handle(args->device);
vn_replace_vkGetImageDrmFormatModifierPropertiesEXT_args_handle(args);
args->ret = dev->get_image_drm_format_modifier_properties(args->device, args->image,

@ -252,7 +252,7 @@ vkr_dispatch_vkDestroyInstance(struct vn_dispatch_context *dispatch,
struct vn_command_vkDestroyInstance *args)
{
struct vkr_context *ctx = dispatch->data;
struct vkr_instance *instance = (struct vkr_instance *)args->instance;
struct vkr_instance *instance = vkr_instance_from_handle(args->instance);
if (ctx->instance != instance) {
vkr_cs_decoder_set_fatal(&ctx->decoder);

@ -158,7 +158,7 @@ vkr_dispatch_vkEnumeratePhysicalDevices(struct vn_dispatch_context *dispatch,
{
struct vkr_context *ctx = dispatch->data;
struct vkr_instance *instance = (struct vkr_instance *)args->instance;
struct vkr_instance *instance = vkr_instance_from_handle(args->instance);
if (instance != ctx->instance) {
vkr_cs_decoder_set_fatal(&ctx->decoder);
return;
@ -238,7 +238,7 @@ vkr_dispatch_vkEnumeratePhysicalDeviceGroups(
{
struct vkr_context *ctx = dispatch->data;
struct vkr_instance *instance = (struct vkr_instance *)args->instance;
struct vkr_instance *instance = vkr_instance_from_handle(args->instance);
if (instance != ctx->instance) {
vkr_cs_decoder_set_fatal(&ctx->decoder);
return;
@ -297,7 +297,7 @@ vkr_dispatch_vkEnumerateDeviceExtensionProperties(
struct vkr_context *ctx = dispatch->data;
struct vkr_physical_device *physical_dev =
(struct vkr_physical_device *)args->physicalDevice;
vkr_physical_device_from_handle(args->physicalDevice);
if (args->pLayerName) {
vkr_cs_decoder_set_fatal(&ctx->decoder);
return;
@ -337,7 +337,7 @@ vkr_dispatch_vkGetPhysicalDeviceProperties(
struct vn_command_vkGetPhysicalDeviceProperties *args)
{
struct vkr_physical_device *physical_dev =
(struct vkr_physical_device *)args->physicalDevice;
vkr_physical_device_from_handle(args->physicalDevice);
*args->pProperties = physical_dev->properties;
}
@ -410,7 +410,7 @@ vkr_dispatch_vkGetPhysicalDeviceProperties2(
struct vn_command_vkGetPhysicalDeviceProperties2 *args)
{
struct vkr_physical_device *physical_dev =
(struct vkr_physical_device *)args->physicalDevice;
vkr_physical_device_from_handle(args->physicalDevice);
vn_replace_vkGetPhysicalDeviceProperties2_args_handle(args);
vkGetPhysicalDeviceProperties2(args->physicalDevice, args->pProperties);

@ -100,7 +100,7 @@ vkr_dispatch_vkCreateGraphicsPipelines(struct vn_dispatch_context *dispatch,
struct vn_command_vkCreateGraphicsPipelines *args)
{
struct vkr_context *ctx = dispatch->data;
struct vkr_device *dev = (struct vkr_device *)args->device;
struct vkr_device *dev = vkr_device_from_handle(args->device);
struct object_array arr;
if (vkr_graphics_pipeline_create_array(ctx, args, &arr) != VK_SUCCESS)
@ -114,7 +114,7 @@ vkr_dispatch_vkCreateComputePipelines(struct vn_dispatch_context *dispatch,
struct vn_command_vkCreateComputePipelines *args)
{
struct vkr_context *ctx = dispatch->data;
struct vkr_device *dev = (struct vkr_device *)args->device;
struct vkr_device *dev = vkr_device_from_handle(args->device);
struct object_array arr;
if (vkr_compute_pipeline_create_array(ctx, args, &arr) != VK_SUCCESS)

@ -43,7 +43,7 @@ static void
vkr_dispatch_vkResetQueryPool(UNUSED struct vn_dispatch_context *dispatch,
struct vn_command_vkResetQueryPool *args)
{
struct vkr_device *dev = (struct vkr_device *)args->device;
struct vkr_device *dev = vkr_device_from_handle(args->device);
vn_replace_vkResetQueryPool_args_handle(args);
dev->ResetQueryPool(args->device, args->queryPool, args->firstQuery, args->queryCount);

@ -318,7 +318,7 @@ vkr_dispatch_vkGetDeviceQueue(struct vn_dispatch_context *dispatch,
{
struct vkr_context *ctx = dispatch->data;
struct vkr_device *dev = (struct vkr_device *)args->device;
struct vkr_device *dev = vkr_device_from_handle(args->device);
struct vkr_queue *queue = vkr_device_lookup_queue(
dev, 0 /* flags */, args->queueFamilyIndex, args->queueIndex);
@ -338,7 +338,7 @@ vkr_dispatch_vkGetDeviceQueue2(struct vn_dispatch_context *dispatch,
{
struct vkr_context *ctx = dispatch->data;
struct vkr_device *dev = (struct vkr_device *)args->device;
struct vkr_device *dev = vkr_device_from_handle(args->device);
struct vkr_queue *queue = vkr_device_lookup_queue(dev, args->pQueueInfo->flags,
args->pQueueInfo->queueFamilyIndex,
@ -464,7 +464,7 @@ static void
vkr_dispatch_vkGetSemaphoreCounterValue(UNUSED struct vn_dispatch_context *dispatch,
struct vn_command_vkGetSemaphoreCounterValue *args)
{
struct vkr_device *dev = (struct vkr_device *)args->device;
struct vkr_device *dev = vkr_device_from_handle(args->device);
vn_replace_vkGetSemaphoreCounterValue_args_handle(args);
args->ret = dev->GetSemaphoreCounterValue(args->device, args->semaphore, args->pValue);
@ -475,7 +475,7 @@ vkr_dispatch_vkWaitSemaphores(struct vn_dispatch_context *dispatch,
struct vn_command_vkWaitSemaphores *args)
{
struct vkr_context *ctx = dispatch->data;
struct vkr_device *dev = (struct vkr_device *)args->device;
struct vkr_device *dev = vkr_device_from_handle(args->device);
/* no blocking call */
if (args->timeout) {
@ -491,7 +491,7 @@ static void
vkr_dispatch_vkSignalSemaphore(UNUSED struct vn_dispatch_context *dispatch,
struct vn_command_vkSignalSemaphore *args)
{
struct vkr_device *dev = (struct vkr_device *)args->device;
struct vkr_device *dev = vkr_device_from_handle(args->device);
vn_replace_vkSignalSemaphore_args_handle(args);
args->ret = dev->SignalSemaphore(args->device, args->pSignalInfo);

@ -23,7 +23,7 @@ vkr_dispatch_vkCreateRenderPass2(struct vn_dispatch_context *dispatch,
struct vn_command_vkCreateRenderPass2 *args)
{
struct vkr_context *ctx = dispatch->data;
struct vkr_device *dev = (struct vkr_device *)args->device;
struct vkr_device *dev = vkr_device_from_handle(args->device);
struct vkr_render_pass *pass = vkr_context_alloc_object(
ctx, sizeof(*pass), VK_OBJECT_TYPE_RENDER_PASS, args->pRenderPass);

Loading…
Cancel
Save