Skip to content

Commit

Permalink
[add] (api) exposed new io_low_level_vulkan_i interface
Browse files Browse the repository at this point in the history
[add] (api) exposed new `io_low_level_imgui_i` interface (and removed existing functions from `io_base_i` interface)
[change] (api) renamed `io_physx_i` to `io_low_level_physx_i`
  • Loading branch information
begla committed Jan 28, 2024
1 parent 90878f6 commit 1397787
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 41 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ iolite_c_api/sample_plugins/.cache
iolite_c_api/sample_plugins/linux/*.so
iolite_c_api/sample_plugins/windows/*.dll
iolite_c_api/sample_plugins/windows/*.pdb
iolite_c_api/sample_plugins/windows/*.ilk
iolite_plugins/build
iolite_plugins/.cache
iolite_plugins/linux/*.so
iolite_plugins/windows/*.dll
iolite_plugins/windows/*.pdb
iolite_plugins/windows/*.ilk

!iolite_plugins/**/OpenImageDenoise.*
!iolite_plugins/**/lua51.*
Expand Down
7 changes: 7 additions & 0 deletions .vscode/ltex.dictionary.en-US.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,10 @@ Denoiser
voxelized
matadata
Wrensch
PhysX
ptr
TLSF-backed
ImGui
Ptr
Vulkan
Vulkan-internal
1 change: 1 addition & 0 deletions .vscode/ltex.disabledRules.en-US.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ENGLISH_WORD_REPEAT_RULE
ENGLISH_WORD_REPEAT_BEGINNING_RULE
3 changes: 3 additions & 0 deletions .vscode/ltex.hiddenFalsePositives.en-US.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@
{"rule":"DOUBLE_PUNCTUATION","sentence":"^\\Q../_static/images/cow_voxel_shape.jpg\\E$"}
{"rule":"COMMA_PARENTHESIS_WHITESPACE","sentence":"^\\Qif (shape_bounds_center.y + shape_bounds_radius < kill_plane_position.y) {\r\ndespawn_voxel_shape();\r\n}\\E$"}
{"rule":"MORFOLOGIK_RULE_EN_US","sentence":"^\\Qif (shape_bounds_center.y + shape_bounds_radius < kill_plane_position.y) {\r\ndespawn_voxel_shape();\r\n}\\E$"}
{"rule":"ENGLISH_WORD_REPEAT_BEGINNING_RULE","sentence":"^\\QReturns the ptr to the physx::PxRigidActor instance for the given shape.\\E$"}
{"rule":"ENGLISH_WORD_REPEAT_BEGINNING_RULE","sentence":"^\\QPerforms a raycast.\\E$"}
{"rule":"ENGLISH_WORD_REPEAT_BEGINNING_RULE","sentence":"^\\QReturns the ptr to the \"physx::PxRigidActor\" instance for the given shape.\\E$"}
111 changes: 76 additions & 35 deletions iolite_c_api/iolite_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ typedef struct
} io_scheduler_task_t;

//----------------------------------------------------------------------------//
// Global helper functions and types
// Global helper functions, types, and type definitions
//----------------------------------------------------------------------------//

// Initializes a task with the given callback for the given amount of tasks
Expand Down Expand Up @@ -907,7 +907,7 @@ inline io_name_t io_to_name(const char* string)
}

//----------------------------------------------------------------------------//
// Interface types and typedefs
// Types and type definitions for API interfaces
//----------------------------------------------------------------------------//

// Called when a change to a file was detected.
Expand Down Expand Up @@ -1030,6 +1030,18 @@ typedef struct
io_vec2_t extent;
} io_ui_rect_t;

// Collection of Vulkan internal functions
//----------------------------------------------------------------------------//
typedef struct
{
// Ptr to function of type "PFN_vkGetInstanceProcAddr". Can be used to
// retrieve other Vulkan functions dynamically
void* vk_get_instance_proc_addr;
// Ptr to function of type "PFN_vkGetDeviceProcAddr". Can be used to retrieve
// other Vulkan functions dynamically
void* vk_get_device_proc_addr;
} io_low_level_vulkan_functions_t;

//----------------------------------------------------------------------------//
// Event data types
//----------------------------------------------------------------------------//
Expand Down Expand Up @@ -1403,15 +1415,6 @@ struct io_base_i // NOLINT
// Gets the value of the variant as an uvec4.
io_uvec4_t (*variant_get_uvec4)(io_variant_t variant);

// Dear ImGui

// Needed to use Dear ImGui in a plugin; use in combination with
// ImGui::SetCurrentContext().
void* (*imgui_get_context)();
// Needed to use Dear ImGui in a plugin; use in combination with
// ImGui::SetAllocatorFunctions().
void (*imgui_get_allocator_functions)(void** alloc_func, void** free_func);

// Memory management. Provides a TLSF-backed, thread-safe allocator which
// features allocation tracking.

Expand Down Expand Up @@ -1848,30 +1851,6 @@ struct io_physics_i // NOLINT
io_uint32_t group_mask);
};

//----------------------------------------------------------------------------//
#define IO_PHYSX_API_NAME "io_physx_i"
//----------------------------------------------------------------------------//

// Provides direct access to the internal low-level PhysX data structures
// Use this if you want to directly utilize PhysX in your plugin to add
// custom behavior and functionality
//----------------------------------------------------------------------------//
struct io_physx_i // NOLINT
{
// Returns the ptr to the global physx::PxPhysics instance.
void* (*get_px_physics)();
// Returns the ptr to the global physx::PxScene instance.
void* (*get_px_scene)();

// Returns the ptr to the physx::PxRigidActor instance for the given shape.
// Please note the following:
// 1. The actor can be *NULL* for shapes with pending voxelization or
// disabled collision.
// 2. The actor is replaced after the voxelization for a shape finishes
// and the previous one becomes *invalid*.
void* (*get_px_rigid_actor_for_shape)(io_ref_t shape);
};

//----------------------------------------------------------------------------//
#define IO_DEBUG_GEOMETRY_API_NAME "io_debug_geometry_i"
//----------------------------------------------------------------------------//
Expand Down Expand Up @@ -2608,4 +2587,66 @@ struct io_resource_palette_i // NOLINT
io_uint8_t palette_index);
};

//----------------------------------------------------------------------------//
#define IO_LOW_LEVEL_PHYSX_API_NAME "io_low_level_physx_i"
//----------------------------------------------------------------------------//

// Provides direct access to the internal low-level PhysX data structures
// Use this if you want to directly utilize PhysX in your plugin to add
// custom behavior and functionality
//----------------------------------------------------------------------------//
struct io_low_level_physx_i // NOLINT
{
// Returns the ptr to the global "physx::PxPhysics" instance.
void* (*get_px_physics)();
// Returns the ptr to the global "physx::PxScene" instance.
void* (*get_px_scene)();

// Returns the ptr to the "physx::PxRigidActor" instance for the given shape.
// Please note the following:
// 1. The actor can be *NULL* for shapes with pending voxelization or
// disabled collision
// 2. The actor is replaced after the voxelization for a shape finishes
// and the previous one becomes *invalid*
void* (*get_px_rigid_actor_for_shape)(io_ref_t shape);
};

//----------------------------------------------------------------------------//
#define IO_LOW_LEVEL_IMGUI_API_NAME "io_low_level_imgui_i"
//----------------------------------------------------------------------------//

// Provides direct access to the internal low-level Dear ImGui data structures
// Use this in conjunction with "ImGui::SetCurrentContext()" and
// "ImGui::SetAllocatorFunctions()" in your plugin
struct io_low_level_imgui_i // NOLINT
{
// Returns the ptr to the global "ImGui::ImGuiContext" instance
void* (*get_imgui_context)();
// Returns the ptrs to the global "ImGuiMemAllocFunc" and "ImGuiMemFreeFunc"
// functions
void (*get_imgui_allocator_functions)(void** alloc_func, void** free_func);
};

//----------------------------------------------------------------------------//
#define IO_LOW_LEVEL_VULKAN_API_NAME "io_low_level_vulkan_i"
//----------------------------------------------------------------------------//

// Provides direct access to the internal low-level Vulkan data structures
struct io_low_level_vulkan_i // NOLINT
{
// Returns the highest version of the API used. Constructed with
// "VK_MAKE_VERSION".
io_uint32_t (*get_vk_api_version)();

// Returns the ptr to the Vulkan physical device of type "VkPhysicalDevice".
void* (*get_vk_physical_device)();
// Returns the ptr to the Vulkan device of type "VkDevice".
void* (*get_vk_device)();
// Returns the ptr to the Vulkan instance of type "VkInstance".
void* (*get_vk_instance)();

// Returns a collection of Vulkan-internal functions.
void (*get_functions)(io_low_level_vulkan_functions_t* functions);
};

#endif
9 changes: 6 additions & 3 deletions iolite_c_api/sample_plugins/sample_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ static const io_editor_i* io_editor = nullptr;
static const io_custom_components_i* io_custom_components = nullptr;
static const io_resource_palette_i* io_resource_palette = nullptr;
static const io_debug_geometry_i* io_debug_geometry = nullptr;
static const io_low_level_imgui_i* io_low_level_imgui = nullptr;

// Sample variables
//----------------------------------------------------------------------------//
Expand Down Expand Up @@ -551,6 +552,8 @@ IO_API_EXPORT io_int32_t IO_API_CALL load_plugin(void* api_manager)
IO_RESOURCE_PALETTE_API_NAME);
io_debug_geometry = (const io_debug_geometry_i*)io_api_manager->find_first(
IO_DEBUG_GEOMETRY_API_NAME);
io_low_level_imgui = (const io_low_level_imgui_i*)io_api_manager->find_first(
IO_LOW_LEVEL_IMGUI_API_NAME);

// Create our boid custom component
boid_component_mgr = io_custom_components->request_manager();
Expand Down Expand Up @@ -593,13 +596,13 @@ IO_API_EXPORT io_int32_t IO_API_CALL load_plugin(void* api_manager)

// Set up Dear ImGui
{
auto ctxt = (ImGuiContext*)io_base->imgui_get_context();
auto ctxt = (ImGuiContext*)io_low_level_imgui->get_imgui_context();
ImGui::SetCurrentContext(ctxt);

ImGuiMemAllocFunc alloc_func;
ImGuiMemFreeFunc free_func;
io_base->imgui_get_allocator_functions((void**)&alloc_func,
(void**)&free_func);
io_low_level_imgui->get_imgui_allocator_functions((void**)&alloc_func,
(void**)&free_func);
ImGui::SetAllocatorFunctions(alloc_func, free_func);
}

Expand Down
1 change: 1 addition & 0 deletions iolite_plugins/voxel_editing_plugin/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ static const io_editor_i* io_editor = nullptr;
static const io_world_i* io_world = nullptr;
static const io_debug_geometry_i* io_debug_geometry = nullptr;
static const io_input_system_i* io_input_system = nullptr;
static const io_low_level_imgui_i* io_low_level_imgui = nullptr;

// Interfaces we provide
//----------------------------------------------------------------------------//
Expand Down
9 changes: 6 additions & 3 deletions iolite_plugins/voxel_editing_plugin/voxel_editing_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ IO_API_EXPORT int IO_API_CALL load_plugin(void* api_manager)
io_resource_palette =
(const io_resource_palette_i*)io_api_manager->find_first(
IO_RESOURCE_PALETTE_API_NAME);
io_low_level_imgui =
(const io_low_level_imgui_i*)io_api_manager->find_first(
IO_LOW_LEVEL_IMGUI_API_NAME);
}

// Register the edit tool
Expand All @@ -75,13 +78,13 @@ IO_API_EXPORT int IO_API_CALL load_plugin(void* api_manager)

// Set up Dear ImGui
{
auto ctxt = (ImGuiContext*)io_base->imgui_get_context();
auto ctxt = (ImGuiContext*)io_low_level_imgui->get_imgui_context();
ImGui::SetCurrentContext(ctxt);

ImGuiMemAllocFunc alloc_func;
ImGuiMemFreeFunc free_func;
io_base->imgui_get_allocator_functions((void**)&alloc_func,
(void**)&free_func);
io_low_level_imgui->get_imgui_allocator_functions((void**)&alloc_func,
(void**)&free_func);
ImGui::SetAllocatorFunctions(alloc_func, free_func);
}

Expand Down

0 comments on commit 1397787

Please sign in to comment.