vkr: remove manual device validation

The decoder makes sure the device pointer is non-NULL since 0f12c460
("vkr: make sure the first dispatchable handle is non-NULL").  And
vkr_cs_decoder_lookup_object is just fixed to validate the object type.

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 03fe8686e3
commit 71ccab4f27
  1. 18
      src/venus/vkr_buffer.c
  2. 12
      src/venus/vkr_common.h
  3. 6
      src/venus/vkr_device.c
  4. 15
      src/venus/vkr_device_memory.c
  5. 11
      src/venus/vkr_image.c
  6. 7
      src/venus/vkr_query_pool.c
  7. 27
      src/venus/vkr_queue.c
  8. 4
      src/venus/vkr_render_pass.c

@ -19,10 +19,6 @@ vkr_dispatch_vkCreateBuffer(struct vn_dispatch_context *dispatch,
struct vkr_context *ctx = dispatch->data; struct vkr_context *ctx = dispatch->data;
struct vkr_device *dev = (struct vkr_device *)args->device; struct vkr_device *dev = (struct vkr_device *)args->device;
if (!dev || dev->base.type != VK_OBJECT_TYPE_DEVICE) {
vkr_cs_decoder_set_fatal(&ctx->decoder);
return;
}
#ifdef FORCE_ENABLE_DMABUF #ifdef FORCE_ENABLE_DMABUF
VkExternalMemoryBufferCreateInfo local_external_info; VkExternalMemoryBufferCreateInfo local_external_info;
@ -95,30 +91,20 @@ vkr_dispatch_vkBindBufferMemory2(UNUSED struct vn_dispatch_context *dispatch,
static void static void
vkr_dispatch_vkGetBufferOpaqueCaptureAddress( vkr_dispatch_vkGetBufferOpaqueCaptureAddress(
struct vn_dispatch_context *dispatch, UNUSED struct vn_dispatch_context *dispatch,
struct vn_command_vkGetBufferOpaqueCaptureAddress *args) struct vn_command_vkGetBufferOpaqueCaptureAddress *args)
{ {
struct vkr_context *ctx = dispatch->data;
struct vkr_device *dev = (struct vkr_device *)args->device; struct vkr_device *dev = (struct vkr_device *)args->device;
if (!dev || dev->base.type != VK_OBJECT_TYPE_DEVICE) {
vkr_cs_decoder_set_fatal(&ctx->decoder);
return;
}
vn_replace_vkGetBufferOpaqueCaptureAddress_args_handle(args); vn_replace_vkGetBufferOpaqueCaptureAddress_args_handle(args);
args->ret = dev->GetBufferOpaqueCaptureAddress(args->device, args->pInfo); args->ret = dev->GetBufferOpaqueCaptureAddress(args->device, args->pInfo);
} }
static void static void
vkr_dispatch_vkGetBufferDeviceAddress(struct vn_dispatch_context *dispatch, vkr_dispatch_vkGetBufferDeviceAddress(UNUSED struct vn_dispatch_context *dispatch,
struct vn_command_vkGetBufferDeviceAddress *args) struct vn_command_vkGetBufferDeviceAddress *args)
{ {
struct vkr_context *ctx = dispatch->data;
struct vkr_device *dev = (struct vkr_device *)args->device; struct vkr_device *dev = (struct vkr_device *)args->device;
if (!dev || dev->base.type != VK_OBJECT_TYPE_DEVICE) {
vkr_cs_decoder_set_fatal(&ctx->decoder);
return;
}
vn_replace_vkGetBufferDeviceAddress_args_handle(args); vn_replace_vkGetBufferDeviceAddress_args_handle(args);
args->ret = dev->GetBufferDeviceAddress(args->device, args->pInfo); args->ret = dev->GetBufferDeviceAddress(args->device, args->pInfo);

@ -53,10 +53,6 @@
*/ */
#define CREATE_OBJECT(obj, vkr_type, vk_obj, vk_cmd, vk_arg) \ #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 = (struct vkr_device *)args->device; \
if (!_dev || _dev->base.type != VK_OBJECT_TYPE_DEVICE) { \
vkr_cs_decoder_set_fatal(&ctx->decoder); \
return; \
} \
\ \
struct vkr_##vkr_type *obj = calloc(1, sizeof(*obj)); \ struct vkr_##vkr_type *obj = calloc(1, sizeof(*obj)); \
if (!obj) { \ if (!obj) { \
@ -93,10 +89,6 @@
vkr_pool_type, vk_pool_type) \ vkr_pool_type, vk_pool_type) \
do { \ do { \
struct vkr_device *dev = (struct vkr_device *)args->device; \ struct vkr_device *dev = (struct vkr_device *)args->device; \
if (!dev || dev->base.type != VK_OBJECT_TYPE_DEVICE) { \
vkr_cs_decoder_set_fatal(&ctx->decoder); \
return; \
} \
\ \
struct vkr_##vkr_pool_type *pool = \ struct vkr_##vkr_pool_type *pool = \
(struct vkr_##vkr_pool_type *)(uintptr_t)args->pAllocateInfo->arg_pool; \ (struct vkr_##vkr_pool_type *)(uintptr_t)args->pAllocateInfo->arg_pool; \
@ -163,10 +155,6 @@
#define CREATE_PIPELINES(vk_cmd) \ #define CREATE_PIPELINES(vk_cmd) \
do { \ do { \
struct vkr_device *dev = (struct vkr_device *)args->device; \ struct vkr_device *dev = (struct vkr_device *)args->device; \
if (!dev || dev->base.type != VK_OBJECT_TYPE_DEVICE) { \
vkr_cs_decoder_set_fatal(&ctx->decoder); \
return; \
} \
\ \
struct object_array arr; \ struct object_array arr; \
if (!object_array_init(&arr, args->createInfoCount, VK_OBJECT_TYPE_PIPELINE, \ if (!object_array_init(&arr, args->createInfoCount, VK_OBJECT_TYPE_PIPELINE, \

@ -368,11 +368,9 @@ vkr_dispatch_vkDestroyDevice(struct vn_dispatch_context *dispatch,
struct vkr_context *ctx = dispatch->data; struct vkr_context *ctx = dispatch->data;
struct vkr_device *dev = (struct vkr_device *)args->device; struct vkr_device *dev = (struct vkr_device *)args->device;
if (!dev || dev->base.type != VK_OBJECT_TYPE_DEVICE) { /* this never happens */
if (dev) if (!dev)
vkr_cs_decoder_set_fatal(&ctx->decoder);
return; return;
}
vkr_device_destroy(ctx, dev); vkr_device_destroy(ctx, dev);
} }

@ -46,10 +46,6 @@ vkr_dispatch_vkAllocateMemory(struct vn_dispatch_context *dispatch,
struct vkr_context *ctx = dispatch->data; struct vkr_context *ctx = dispatch->data;
struct vkr_device *dev = (struct vkr_device *)args->device; struct vkr_device *dev = (struct vkr_device *)args->device;
if (!dev || dev->base.type != VK_OBJECT_TYPE_DEVICE) {
vkr_cs_decoder_set_fatal(&ctx->decoder);
return;
}
#ifdef FORCE_ENABLE_DMABUF #ifdef FORCE_ENABLE_DMABUF
VkExportMemoryAllocateInfo local_export_info; VkExportMemoryAllocateInfo local_export_info;
@ -190,15 +186,10 @@ vkr_dispatch_vkGetDeviceMemoryCommitment(
static void static void
vkr_dispatch_vkGetDeviceMemoryOpaqueCaptureAddress( vkr_dispatch_vkGetDeviceMemoryOpaqueCaptureAddress(
struct vn_dispatch_context *dispatch, UNUSED struct vn_dispatch_context *dispatch,
struct vn_command_vkGetDeviceMemoryOpaqueCaptureAddress *args) struct vn_command_vkGetDeviceMemoryOpaqueCaptureAddress *args)
{ {
struct vkr_context *ctx = dispatch->data;
struct vkr_device *dev = (struct vkr_device *)args->device; struct vkr_device *dev = (struct vkr_device *)args->device;
if (!dev || dev->base.type != VK_OBJECT_TYPE_DEVICE) {
vkr_cs_decoder_set_fatal(&ctx->decoder);
return;
}
vn_replace_vkGetDeviceMemoryOpaqueCaptureAddress_args_handle(args); vn_replace_vkGetDeviceMemoryOpaqueCaptureAddress_args_handle(args);
args->ret = dev->GetDeviceMemoryOpaqueCaptureAddress(args->device, args->pInfo); args->ret = dev->GetDeviceMemoryOpaqueCaptureAddress(args->device, args->pInfo);
@ -211,10 +202,6 @@ vkr_dispatch_vkGetMemoryResourcePropertiesMESA(
{ {
struct vkr_context *ctx = dispatch->data; struct vkr_context *ctx = dispatch->data;
struct vkr_device *dev = (struct vkr_device *)args->device; struct vkr_device *dev = (struct vkr_device *)args->device;
if (!dev || dev->base.type != VK_OBJECT_TYPE_DEVICE) {
vkr_cs_decoder_set_fatal(&ctx->decoder);
return;
}
struct vkr_resource_attachment *att = struct vkr_resource_attachment *att =
util_hash_table_get(ctx->resource_table, uintptr_to_pointer(args->resourceId)); util_hash_table_get(ctx->resource_table, uintptr_to_pointer(args->resourceId));

@ -21,10 +21,6 @@ vkr_dispatch_vkCreateImage(struct vn_dispatch_context *dispatch,
struct vkr_context *ctx = dispatch->data; struct vkr_context *ctx = dispatch->data;
struct vkr_device *dev = (struct vkr_device *)args->device; struct vkr_device *dev = (struct vkr_device *)args->device;
if (!dev || dev->base.type != VK_OBJECT_TYPE_DEVICE) {
vkr_cs_decoder_set_fatal(&ctx->decoder);
return;
}
#ifdef FORCE_ENABLE_DMABUF #ifdef FORCE_ENABLE_DMABUF
/* Do not chain VkExternalMemoryImageCreateInfo with optimal tiling, so that /* Do not chain VkExternalMemoryImageCreateInfo with optimal tiling, so that
@ -133,15 +129,10 @@ vkr_dispatch_vkGetImageSubresourceLayout(
static void static void
vkr_dispatch_vkGetImageDrmFormatModifierPropertiesEXT( vkr_dispatch_vkGetImageDrmFormatModifierPropertiesEXT(
struct vn_dispatch_context *dispatch, UNUSED struct vn_dispatch_context *dispatch,
struct vn_command_vkGetImageDrmFormatModifierPropertiesEXT *args) struct vn_command_vkGetImageDrmFormatModifierPropertiesEXT *args)
{ {
struct vkr_context *ctx = dispatch->data;
struct vkr_device *dev = (struct vkr_device *)args->device; struct vkr_device *dev = (struct vkr_device *)args->device;
if (!dev || dev->base.type != VK_OBJECT_TYPE_DEVICE) {
vkr_cs_decoder_set_fatal(&ctx->decoder);
return;
}
vn_replace_vkGetImageDrmFormatModifierPropertiesEXT_args_handle(args); vn_replace_vkGetImageDrmFormatModifierPropertiesEXT_args_handle(args);
args->ret = dev->get_image_drm_format_modifier_properties(args->device, args->image, args->ret = dev->get_image_drm_format_modifier_properties(args->device, args->image,

@ -43,15 +43,10 @@ vkr_dispatch_vkGetQueryPoolResults(UNUSED struct vn_dispatch_context *dispatch,
} }
static void static void
vkr_dispatch_vkResetQueryPool(struct vn_dispatch_context *dispatch, vkr_dispatch_vkResetQueryPool(UNUSED struct vn_dispatch_context *dispatch,
struct vn_command_vkResetQueryPool *args) struct vn_command_vkResetQueryPool *args)
{ {
struct vkr_context *ctx = dispatch->data;
struct vkr_device *dev = (struct vkr_device *)args->device; struct vkr_device *dev = (struct vkr_device *)args->device;
if (!dev || dev->base.type != VK_OBJECT_TYPE_DEVICE) {
vkr_cs_decoder_set_fatal(&ctx->decoder);
return;
}
vn_replace_vkResetQueryPool_args_handle(args); vn_replace_vkResetQueryPool_args_handle(args);
dev->ResetQueryPool(args->device, args->queryPool, args->firstQuery, args->queryCount); dev->ResetQueryPool(args->device, args->queryPool, args->firstQuery, args->queryCount);

@ -299,10 +299,6 @@ vkr_dispatch_vkGetDeviceQueue(struct vn_dispatch_context *dispatch,
struct vkr_context *ctx = dispatch->data; struct vkr_context *ctx = dispatch->data;
struct vkr_device *dev = (struct vkr_device *)args->device; struct vkr_device *dev = (struct vkr_device *)args->device;
if (!dev || dev->base.type != VK_OBJECT_TYPE_DEVICE) {
vkr_cs_decoder_set_fatal(&ctx->decoder);
return;
}
struct vkr_queue *queue = vkr_device_lookup_queue( struct vkr_queue *queue = vkr_device_lookup_queue(
dev, 0 /* flags */, args->queueFamilyIndex, args->queueIndex); dev, 0 /* flags */, args->queueFamilyIndex, args->queueIndex);
@ -323,10 +319,6 @@ vkr_dispatch_vkGetDeviceQueue2(struct vn_dispatch_context *dispatch,
struct vkr_context *ctx = dispatch->data; struct vkr_context *ctx = dispatch->data;
struct vkr_device *dev = (struct vkr_device *)args->device; struct vkr_device *dev = (struct vkr_device *)args->device;
if (!dev || dev->base.type != VK_OBJECT_TYPE_DEVICE) {
vkr_cs_decoder_set_fatal(&ctx->decoder);
return;
}
struct vkr_queue *queue = vkr_device_lookup_queue(dev, args->pQueueInfo->flags, struct vkr_queue *queue = vkr_device_lookup_queue(dev, args->pQueueInfo->flags,
args->pQueueInfo->queueFamilyIndex, args->pQueueInfo->queueFamilyIndex,
@ -449,15 +441,10 @@ vkr_dispatch_vkDestroySemaphore(struct vn_dispatch_context *dispatch,
} }
static void static void
vkr_dispatch_vkGetSemaphoreCounterValue(struct vn_dispatch_context *dispatch, vkr_dispatch_vkGetSemaphoreCounterValue(UNUSED struct vn_dispatch_context *dispatch,
struct vn_command_vkGetSemaphoreCounterValue *args) struct vn_command_vkGetSemaphoreCounterValue *args)
{ {
struct vkr_context *ctx = dispatch->data;
struct vkr_device *dev = (struct vkr_device *)args->device; struct vkr_device *dev = (struct vkr_device *)args->device;
if (!dev || dev->base.type != VK_OBJECT_TYPE_DEVICE) {
vkr_cs_decoder_set_fatal(&ctx->decoder);
return;
}
vn_replace_vkGetSemaphoreCounterValue_args_handle(args); vn_replace_vkGetSemaphoreCounterValue_args_handle(args);
args->ret = dev->GetSemaphoreCounterValue(args->device, args->semaphore, args->pValue); args->ret = dev->GetSemaphoreCounterValue(args->device, args->semaphore, args->pValue);
@ -470,11 +457,6 @@ vkr_dispatch_vkWaitSemaphores(struct vn_dispatch_context *dispatch,
struct vkr_context *ctx = dispatch->data; struct vkr_context *ctx = dispatch->data;
struct vkr_device *dev = (struct vkr_device *)args->device; struct vkr_device *dev = (struct vkr_device *)args->device;
if (!dev || dev->base.type != VK_OBJECT_TYPE_DEVICE) {
vkr_cs_decoder_set_fatal(&ctx->decoder);
return;
}
/* no blocking call */ /* no blocking call */
if (args->timeout) { if (args->timeout) {
vkr_cs_decoder_set_fatal(&ctx->decoder); vkr_cs_decoder_set_fatal(&ctx->decoder);
@ -486,15 +468,10 @@ vkr_dispatch_vkWaitSemaphores(struct vn_dispatch_context *dispatch,
} }
static void static void
vkr_dispatch_vkSignalSemaphore(struct vn_dispatch_context *dispatch, vkr_dispatch_vkSignalSemaphore(UNUSED struct vn_dispatch_context *dispatch,
struct vn_command_vkSignalSemaphore *args) struct vn_command_vkSignalSemaphore *args)
{ {
struct vkr_context *ctx = dispatch->data;
struct vkr_device *dev = (struct vkr_device *)args->device; struct vkr_device *dev = (struct vkr_device *)args->device;
if (!dev || dev->base.type != VK_OBJECT_TYPE_DEVICE) {
vkr_cs_decoder_set_fatal(&ctx->decoder);
return;
}
vn_replace_vkSignalSemaphore_args_handle(args); vn_replace_vkSignalSemaphore_args_handle(args);
args->ret = dev->SignalSemaphore(args->device, args->pSignalInfo); args->ret = dev->SignalSemaphore(args->device, args->pSignalInfo);

@ -28,10 +28,6 @@ vkr_dispatch_vkCreateRenderPass2(struct vn_dispatch_context *dispatch,
{ {
struct vkr_context *ctx = dispatch->data; struct vkr_context *ctx = dispatch->data;
struct vkr_device *dev = (struct vkr_device *)args->device; struct vkr_device *dev = (struct vkr_device *)args->device;
if (!dev || dev->base.type != VK_OBJECT_TYPE_DEVICE) {
vkr_cs_decoder_set_fatal(&ctx->decoder);
return;
}
struct vkr_render_pass *pass = calloc(1, sizeof(*pass)); struct vkr_render_pass *pass = calloc(1, sizeof(*pass));
if (!pass) { if (!pass) {

Loading…
Cancel
Save