Skip to content

Commit

Permalink
Fix a handful of issues:
Browse files Browse the repository at this point in the history
1. Return RMT_ERROR_NONE instead of NULL from rmt_BindVulkan if Vulkan is not enabled
2. Explicitly cast function pointers to void* in README since this is potentially required by some compilers
3. Use rmtMakeError in rmt_BindVulkan to describe what parameter/function pointer is missing
  • Loading branch information
Valakor committed Jan 17, 2024
1 parent 2e56a7b commit 2f28ede
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions lib/Remotery.c
Original file line number Diff line number Diff line change
Expand Up @@ -10410,26 +10410,26 @@ RMT_API rmtError _rmt_BindVulkan(void* instance, void* physical_device, void* de
return RMT_ERROR_REMOTERY_NOT_CREATED;

if (instance == NULL)
return RMT_ERROR_INVALID_INPUT;
return rmtMakeError(RMT_ERROR_INVALID_INPUT, "Missing instance");

if (physical_device == NULL)
return RMT_ERROR_INVALID_INPUT;
return rmtMakeError(RMT_ERROR_INVALID_INPUT, "Missing physical_device");

if (device == NULL)
return RMT_ERROR_INVALID_INPUT;
return rmtMakeError(RMT_ERROR_INVALID_INPUT, "Missing device");

if (queue == NULL)
return RMT_ERROR_INVALID_INPUT;
return rmtMakeError(RMT_ERROR_INVALID_INPUT, "Missing queue");

if (funcs == NULL)
return RMT_ERROR_INVALID_INPUT;
return rmtMakeError(RMT_ERROR_INVALID_INPUT, "Missing funcs");

if (out_bind == NULL)
return RMT_ERROR_INVALID_INPUT;
return rmtMakeError(RMT_ERROR_INVALID_INPUT, "Missing out_bind");

#define CHECK_VK_FUNC(fn) \
if (funcs->fn == NULL) \
return RMT_ERROR_INVALID_INPUT;
return rmtMakeError(RMT_ERROR_INVALID_INPUT, "Missing " #fn)

CHECK_VK_FUNC(vkGetPhysicalDeviceProperties);
CHECK_VK_FUNC(vkQueueSubmit);
Expand Down
2 changes: 1 addition & 1 deletion lib/Remotery.h
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ typedef struct rmtVulkanBind

// Create a Vulkan binding for the given device/queue pair
#define rmt_BindVulkan(instance, physical_device, device, queue, funcs, out_bind) \
RMT_OPTIONAL_RET(RMT_USE_VULKAN, _rmt_BindVulkan(instance, physical_device, device, queue, funcs, out_bind), NULL)
RMT_OPTIONAL_RET(RMT_USE_VULKAN, _rmt_BindVulkan(instance, physical_device, device, queue, funcs, out_bind), RMT_ERROR_NONE)

#define rmt_UnbindVulkan(bind) \
RMT_OPTIONAL(RMT_USE_VULKAN, _rmt_UnbindVulkan(bind))
Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ must be submitted to the same queue as the samples are issued to. Multiple queue
Vulkan bind objects.

rmtVulkanFunctions vulkan_funcs;
vulkan_funcs.vkGetPhysicalDeviceProperties = my_vulkan_instance_table->vkGetPhysicalDeviceProperties;
vulkan_funcs.vkQueueSubmit = my_vulkan_device_table->vkQueueSubmit;
vulkan_funcs.vkGetPhysicalDeviceProperties = (void*)my_vulkan_instance_table->vkGetPhysicalDeviceProperties;
vulkan_funcs.vkQueueSubmit = (void*)my_vulkan_device_table->vkQueueSubmit;
// ... All other function pointers

// Parameters are VkInstance, VkPhysicalDevice, VkDevice, VkQueue, rmtVulkanFunctions*, rmtVulkanBind**
Expand Down

0 comments on commit 2f28ede

Please sign in to comment.