mirror of
https://github.com/wiiu-env/WiiUPluginSystem.git
synced 2024-12-24 17:11:58 +01:00
Add support for video memory alloc/free
This commit is contained in:
parent
b29787896c
commit
0ca7b8a344
34
src/memory.cpp
Normal file
34
src/memory.cpp
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#include <wups.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static VideoMemoryAllocFunction vid_mem_alloc_ptr __attribute__((section(".data"))) = NULL;
|
||||||
|
static VideoMemoryFreeFunction vid_mem_free_ptr __attribute__((section(".data"))) = NULL;
|
||||||
|
|
||||||
|
void WUPS_InitVidMem(wups_loader_init_vid_mem_args_t args) {
|
||||||
|
vid_mem_alloc_ptr = args.vid_mem_alloc_ptr;
|
||||||
|
vid_mem_free_ptr = args.vid_mem_free_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void * WUPS_VideoMemMemalign(uint32_t size, int32_t align) {
|
||||||
|
if(vid_mem_alloc_ptr != NULL) {
|
||||||
|
return vid_mem_alloc_ptr(size, align);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void * WUPS_VideoMemAlloc(uint32_t size) {
|
||||||
|
return WUPS_VideoMemMemalign(size, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WUPS_VideoMemFree(void *addr) {
|
||||||
|
if(vid_mem_free_ptr != NULL) {
|
||||||
|
vid_mem_free_ptr(addr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
@ -46,6 +46,7 @@ typedef enum wups_loader_hook_type_t {
|
|||||||
|
|
||||||
WUPS_LOADER_HOOK_INIT_KERNEL, /* Only for internal usage */
|
WUPS_LOADER_HOOK_INIT_KERNEL, /* Only for internal usage */
|
||||||
WUPS_LOADER_HOOK_GET_CONFIG, /* Called when the config-menu will be loaded */
|
WUPS_LOADER_HOOK_GET_CONFIG, /* Called when the config-menu will be loaded */
|
||||||
|
WUPS_LOADER_HOOK_INIT_VID_MEM, /* Only for internal usage */
|
||||||
} wups_loader_hook_type_t;
|
} wups_loader_hook_type_t;
|
||||||
|
|
||||||
typedef struct wups_loader_hook_t {
|
typedef struct wups_loader_hook_t {
|
||||||
@ -80,6 +81,13 @@ typedef struct wups_loader_app_started_args_t {
|
|||||||
WUPS_InitOverlay(args);\
|
WUPS_InitOverlay(args);\
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define WUPS_USE_VIDEO_MEMORY() \
|
||||||
|
void init_vid_mem(wups_loader_init_vid_mem_args_t);\
|
||||||
|
WUPS_HOOK_EX(WUPS_LOADER_HOOK_INIT_VID_MEM,init_vid_mem); \
|
||||||
|
void init_vid_mem(wups_loader_init_vid_mem_args_t args){ \
|
||||||
|
WUPS_InitVidMem(args);\
|
||||||
|
}
|
||||||
|
|
||||||
#define WUPS_ALLOW_KERNEL() \
|
#define WUPS_ALLOW_KERNEL() \
|
||||||
void init_kernel(wups_loader_init_kernel_args_t);\
|
void init_kernel(wups_loader_init_kernel_args_t);\
|
||||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_INIT_KERNEL,init_kernel); \
|
WUPS_HOOK_EX(WUPS_LOADER_HOOK_INIT_KERNEL,init_kernel); \
|
||||||
|
@ -77,6 +77,14 @@ typedef struct wups_loader_init_kernel_args_t_ {
|
|||||||
KernelCopyDataFunction kern_copy_data_ptr;
|
KernelCopyDataFunction kern_copy_data_ptr;
|
||||||
} wups_loader_init_kernel_args_t;
|
} wups_loader_init_kernel_args_t;
|
||||||
|
|
||||||
|
typedef void* (*VideoMemoryAllocFunction)(uint32_t size, int32_t align);
|
||||||
|
typedef void (*VideoMemoryFreeFunction)(void *addr);
|
||||||
|
|
||||||
|
typedef struct wups_loader_init_vid_mem_args_t_ {
|
||||||
|
VideoMemoryAllocFunction vid_mem_alloc_ptr;
|
||||||
|
VideoMemoryFreeFunction vid_mem_free_ptr;
|
||||||
|
} wups_loader_init_vid_mem_args_t;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Gets called by the framework
|
Gets called by the framework
|
||||||
*/
|
*/
|
||||||
@ -100,6 +108,12 @@ void WUPS_InitOverlay(wups_loader_init_overlay_args_t args);
|
|||||||
**/
|
**/
|
||||||
void WUPS_InitKernel(wups_loader_init_kernel_args_t args);
|
void WUPS_InitKernel(wups_loader_init_kernel_args_t args);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets the function pointers for video mem functions.
|
||||||
|
If none or NULL pointers is provided, calling the corresponding function has no effect.
|
||||||
|
**/
|
||||||
|
void WUPS_InitVidMem(wups_loader_init_vid_mem_args_t args);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Can be called by the user.
|
Can be called by the user.
|
||||||
*/
|
*/
|
||||||
@ -132,6 +146,12 @@ void WUPS_KernelWrite(void *addr, uint32_t value);
|
|||||||
**/
|
**/
|
||||||
void WUPS_KernelCopyDataFunction(uint32_t addr, uint32_t src, uint32_t len);
|
void WUPS_KernelCopyDataFunction(uint32_t addr, uint32_t src, uint32_t len);
|
||||||
|
|
||||||
|
void * WUPS_VideoMemAlloc(uint32_t size);
|
||||||
|
|
||||||
|
void * WUPS_VideoMemMemalign(uint32_t size, int32_t align);
|
||||||
|
|
||||||
|
void WUPS_VideoMemFree(void *addr);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user