mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-12 10:41:15 +00:00
run clang format
This commit is contained in:
parent
4744142c9d
commit
7c15d4f9d8
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -102,7 +102,7 @@ jobs:
|
||||
- name: Configure (CMake)
|
||||
run: |
|
||||
if [ "${{ matrix.vita }}" = "true" ]; then
|
||||
PRESET=--preset vita-debug
|
||||
PRESET="--preset vita-debug"
|
||||
fi
|
||||
${{ matrix.cmake-wrapper || '' }} cmake $PRESET -S . -B build -GNinja \
|
||||
-DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \
|
||||
|
||||
@ -1,165 +1,166 @@
|
||||
#include "memory.h"
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#include <psp2/gxm.h>
|
||||
|
||||
#include <SDL3/SDL_stdinc.h>
|
||||
|
||||
#include <psp2/gxm.h>
|
||||
|
||||
static SceUID cdramPoolUID = -1;
|
||||
static SceClibMspace cdramPool = NULL;
|
||||
|
||||
|
||||
void *patcher_host_alloc(void *user_data, unsigned int size)
|
||||
void* patcher_host_alloc(void* user_data, unsigned int size)
|
||||
{
|
||||
void *mem = SDL_malloc(size);
|
||||
(void)user_data;
|
||||
return mem;
|
||||
void* mem = SDL_malloc(size);
|
||||
(void) user_data;
|
||||
return mem;
|
||||
}
|
||||
|
||||
void patcher_host_free(void *user_data, void *mem)
|
||||
void patcher_host_free(void* user_data, void* mem)
|
||||
{
|
||||
(void)user_data;
|
||||
SDL_free(mem);
|
||||
(void) user_data;
|
||||
SDL_free(mem);
|
||||
}
|
||||
|
||||
void* vita_mem_alloc(
|
||||
unsigned int type,
|
||||
size_t size,
|
||||
size_t alignment,
|
||||
int attribs,
|
||||
SceUID *uid
|
||||
) {
|
||||
void *mem;
|
||||
void* vita_mem_alloc(unsigned int type, size_t size, size_t alignment, int attribs, SceUID* uid)
|
||||
{
|
||||
void* mem;
|
||||
|
||||
if (type == SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW) {
|
||||
size = ALIGN(size, 256 * 1024);
|
||||
} else if (type == SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_NC_RW) {
|
||||
size = ALIGN(size, 1024 * 1024);
|
||||
} else {
|
||||
size = ALIGN(size, 4 * 1024);
|
||||
}
|
||||
if (type == SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW) {
|
||||
size = ALIGN(size, 256 * 1024);
|
||||
}
|
||||
else if (type == SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_NC_RW) {
|
||||
size = ALIGN(size, 1024 * 1024);
|
||||
}
|
||||
else {
|
||||
size = ALIGN(size, 4 * 1024);
|
||||
}
|
||||
|
||||
*uid = sceKernelAllocMemBlock("gpu_mem", type, size, NULL);
|
||||
*uid = sceKernelAllocMemBlock("gpu_mem", type, size, NULL);
|
||||
|
||||
if (*uid < 0) {
|
||||
if (*uid < 0) {
|
||||
SDL_Log("sceKernelAllocMemBlock: 0x%x", *uid);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (sceKernelGetMemBlockBase(*uid, &mem) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (sceGxmMapMemory(mem, size, (SceGxmMemoryAttribFlags)attribs) < 0) {
|
||||
SDL_Log("sceGxmMapMemory 0x%x 0x%x %d failed", mem, size, attribs);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return mem;
|
||||
if (sceKernelGetMemBlockBase(*uid, &mem) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (sceGxmMapMemory(mem, size, (SceGxmMemoryAttribFlags) attribs) < 0) {
|
||||
SDL_Log("sceGxmMapMemory 0x%x 0x%x %d failed", mem, size, attribs);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return mem;
|
||||
}
|
||||
|
||||
void vita_mem_free(SceUID uid)
|
||||
{
|
||||
void *mem = NULL;
|
||||
if (sceKernelGetMemBlockBase(uid, &mem) < 0) {
|
||||
return;
|
||||
}
|
||||
sceGxmUnmapMemory(mem);
|
||||
sceKernelFreeMemBlock(uid);
|
||||
void* mem = NULL;
|
||||
if (sceKernelGetMemBlockBase(uid, &mem) < 0) {
|
||||
return;
|
||||
}
|
||||
sceGxmUnmapMemory(mem);
|
||||
sceKernelFreeMemBlock(uid);
|
||||
}
|
||||
|
||||
void *vita_mem_vertex_usse_alloc(unsigned int size, SceUID *uid, unsigned int *usse_offset)
|
||||
void* vita_mem_vertex_usse_alloc(unsigned int size, SceUID* uid, unsigned int* usse_offset)
|
||||
{
|
||||
void *mem = NULL;
|
||||
void* mem = NULL;
|
||||
|
||||
size = ALIGN(size, 4096);
|
||||
*uid = sceKernelAllocMemBlock("vertex_usse", SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, size, NULL);
|
||||
size = ALIGN(size, 4096);
|
||||
*uid = sceKernelAllocMemBlock("vertex_usse", SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, size, NULL);
|
||||
|
||||
if (sceKernelGetMemBlockBase(*uid, &mem) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
if (sceGxmMapVertexUsseMemory(mem, size, usse_offset) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
if (sceKernelGetMemBlockBase(*uid, &mem) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
if (sceGxmMapVertexUsseMemory(mem, size, usse_offset) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return mem;
|
||||
return mem;
|
||||
}
|
||||
|
||||
void vita_mem_vertex_usse_free(SceUID uid)
|
||||
{
|
||||
void *mem = NULL;
|
||||
if (sceKernelGetMemBlockBase(uid, &mem) < 0) {
|
||||
return;
|
||||
}
|
||||
sceGxmUnmapVertexUsseMemory(mem);
|
||||
sceKernelFreeMemBlock(uid);
|
||||
void* mem = NULL;
|
||||
if (sceKernelGetMemBlockBase(uid, &mem) < 0) {
|
||||
return;
|
||||
}
|
||||
sceGxmUnmapVertexUsseMemory(mem);
|
||||
sceKernelFreeMemBlock(uid);
|
||||
}
|
||||
|
||||
void *vita_mem_fragment_usse_alloc(unsigned int size, SceUID *uid, unsigned int *usse_offset)
|
||||
void* vita_mem_fragment_usse_alloc(unsigned int size, SceUID* uid, unsigned int* usse_offset)
|
||||
{
|
||||
void *mem = NULL;
|
||||
void* mem = NULL;
|
||||
|
||||
size = ALIGN(size, 4096);
|
||||
*uid = sceKernelAllocMemBlock("fragment_usse", SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, size, NULL);
|
||||
size = ALIGN(size, 4096);
|
||||
*uid = sceKernelAllocMemBlock("fragment_usse", SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, size, NULL);
|
||||
|
||||
if (sceKernelGetMemBlockBase(*uid, &mem) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
if (sceGxmMapFragmentUsseMemory(mem, size, usse_offset) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
if (sceKernelGetMemBlockBase(*uid, &mem) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
if (sceGxmMapFragmentUsseMemory(mem, size, usse_offset) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return mem;
|
||||
return mem;
|
||||
}
|
||||
|
||||
void vita_mem_fragment_usse_free(SceUID uid)
|
||||
{
|
||||
void *mem = NULL;
|
||||
if (sceKernelGetMemBlockBase(uid, &mem) < 0) {
|
||||
return;
|
||||
}
|
||||
sceGxmUnmapFragmentUsseMemory(mem);
|
||||
sceKernelFreeMemBlock(uid);
|
||||
void* mem = NULL;
|
||||
if (sceKernelGetMemBlockBase(uid, &mem) < 0) {
|
||||
return;
|
||||
}
|
||||
sceGxmUnmapFragmentUsseMemory(mem);
|
||||
sceKernelFreeMemBlock(uid);
|
||||
}
|
||||
|
||||
bool cdramPool_init() {
|
||||
if(cdramPool) {
|
||||
return true;
|
||||
}
|
||||
int poolsize;
|
||||
int ret;
|
||||
void* mem;
|
||||
SceKernelFreeMemorySizeInfo info;
|
||||
info.size = sizeof(SceKernelFreeMemorySizeInfo);
|
||||
sceKernelGetFreeMemorySize(&info);
|
||||
bool cdramPool_init()
|
||||
{
|
||||
if (cdramPool) {
|
||||
return true;
|
||||
}
|
||||
int poolsize;
|
||||
int ret;
|
||||
void* mem;
|
||||
SceKernelFreeMemorySizeInfo info;
|
||||
info.size = sizeof(SceKernelFreeMemorySizeInfo);
|
||||
sceKernelGetFreeMemorySize(&info);
|
||||
|
||||
poolsize = ALIGN(info.size_cdram, 256 * 1024);
|
||||
if (poolsize > info.size_cdram) {
|
||||
poolsize = ALIGN(info.size_cdram - 256 * 1024, 256 * 1024);
|
||||
}
|
||||
poolsize -= 16 * 1024 * 1024;
|
||||
cdramPoolUID = sceKernelAllocMemBlock("gpu_cdram_pool", SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW, poolsize, NULL);
|
||||
if (cdramPool < 0) {
|
||||
return false;
|
||||
}
|
||||
poolsize = ALIGN(info.size_cdram, 256 * 1024);
|
||||
if (poolsize > info.size_cdram) {
|
||||
poolsize = ALIGN(info.size_cdram - 256 * 1024, 256 * 1024);
|
||||
}
|
||||
poolsize -= 16 * 1024 * 1024;
|
||||
cdramPoolUID = sceKernelAllocMemBlock("gpu_cdram_pool", SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW, poolsize, NULL);
|
||||
if (cdramPool < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = sceKernelGetMemBlockBase(cdramPoolUID, &mem);
|
||||
if (ret < 0) {
|
||||
return false;
|
||||
}
|
||||
cdramPool = sceClibMspaceCreate(mem, poolsize);
|
||||
ret = sceKernelGetMemBlockBase(cdramPoolUID, &mem);
|
||||
if (ret < 0) {
|
||||
return false;
|
||||
}
|
||||
cdramPool = sceClibMspaceCreate(mem, poolsize);
|
||||
|
||||
if (!cdramPool) {
|
||||
return false;
|
||||
}
|
||||
ret = sceGxmMapMemory(mem, poolsize, (SceGxmMemoryAttribFlags)(SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE));
|
||||
if (ret < 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
if (!cdramPool) {
|
||||
return false;
|
||||
}
|
||||
ret = sceGxmMapMemory(
|
||||
mem,
|
||||
poolsize,
|
||||
(SceGxmMemoryAttribFlags) (SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE)
|
||||
);
|
||||
if (ret < 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
SceClibMspace cdramPool_get() {
|
||||
return cdramPool;
|
||||
SceClibMspace cdramPool_get()
|
||||
{
|
||||
return cdramPool;
|
||||
}
|
||||
|
||||
@ -1,25 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <psp2/types.h>
|
||||
#include <psp2/kernel/sysmem.h>
|
||||
#include <psp2/kernel/clib.h>
|
||||
#include <SDL3/SDL_stdinc.h>
|
||||
#include <psp2/kernel/clib.h>
|
||||
#include <psp2/kernel/sysmem.h>
|
||||
#include <psp2/types.h>
|
||||
|
||||
void *patcher_host_alloc(void *user_data, unsigned int size);
|
||||
void patcher_host_free(void *user_data, void *mem);
|
||||
void* patcher_host_alloc(void* user_data, unsigned int size);
|
||||
void patcher_host_free(void* user_data, void* mem);
|
||||
|
||||
void* vita_mem_alloc(
|
||||
unsigned int type,
|
||||
size_t size,
|
||||
size_t alignment,
|
||||
int attribs,
|
||||
SceUID* uid
|
||||
);
|
||||
void* vita_mem_alloc(unsigned int type, size_t size, size_t alignment, int attribs, SceUID* uid);
|
||||
void vita_mem_free(SceUID uid);
|
||||
|
||||
void *vita_mem_vertex_usse_alloc(unsigned int size, SceUID *uid, unsigned int *usse_offset);
|
||||
void* vita_mem_vertex_usse_alloc(unsigned int size, SceUID* uid, unsigned int* usse_offset);
|
||||
void vita_mem_vertex_usse_free(SceUID uid);
|
||||
void *vita_mem_fragment_usse_alloc(unsigned int size, SceUID *uid, unsigned int *usse_offset);
|
||||
void* vita_mem_fragment_usse_alloc(unsigned int size, SceUID* uid, unsigned int* usse_offset);
|
||||
void vita_mem_fragment_usse_free(SceUID uid);
|
||||
|
||||
bool cdramPool_init();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -4,38 +4,39 @@
|
||||
#include <psp2/gxm.h>
|
||||
#include <psp2/kernel/clib.h>
|
||||
|
||||
#define SCE_ERR(func, ...) ({ \
|
||||
sceClibPrintf(#func "\n"); \
|
||||
int __sce_err_ret_val = func(__VA_ARGS__); \
|
||||
if (__sce_err_ret_val < 0) { \
|
||||
sceClibPrintf(#func " error: 0x%x\n", __sce_err_ret_val); \
|
||||
} \
|
||||
__sce_err_ret_val < 0; \
|
||||
})
|
||||
#define SCE_ERR(func, ...) \
|
||||
({ \
|
||||
sceClibPrintf(#func "\n"); \
|
||||
int __sce_err_ret_val = func(__VA_ARGS__); \
|
||||
if (__sce_err_ret_val < 0) { \
|
||||
sceClibPrintf(#func " error: 0x%x\n", __sce_err_ret_val); \
|
||||
} \
|
||||
__sce_err_ret_val < 0; \
|
||||
})
|
||||
|
||||
#define ALIGN(x, a) (((x) + ((a)-1)) & ~((a)-1))
|
||||
#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1))
|
||||
|
||||
#define ALIGNMENT(n, a) (((a) - ((n) % (a))) % (a))
|
||||
|
||||
#define SET_UNIFORM(buffer, param, value) \
|
||||
do { \
|
||||
size_t __offset = sceGxmProgramParameterGetResourceIndex(param); \
|
||||
void* __dst = (uint8_t*) (buffer) + (__offset * sizeof(uint32_t)); \
|
||||
memcpy(__dst, reinterpret_cast<const void*>(&(value)), sizeof(value)); \
|
||||
} while (0)
|
||||
|
||||
#define SET_UNIFORM(buffer, param, value) \
|
||||
do { \
|
||||
size_t __offset = sceGxmProgramParameterGetResourceIndex(param); \
|
||||
void* __dst = (uint8_t*)(buffer) + (__offset * sizeof(uint32_t)); \
|
||||
memcpy(__dst, reinterpret_cast<const void*>(&(value)), sizeof(value)); \
|
||||
} while (0)
|
||||
|
||||
#define GET_SHADER_PARAM(var, gxp, name, ret) \
|
||||
const SceGxmProgramParameter* var = sceGxmProgramFindParameterByName(gxp, name); \
|
||||
if(!var) { \
|
||||
SDL_Log("Failed to find param %s", name); \
|
||||
return ret; \
|
||||
#define GET_SHADER_PARAM(var, gxp, name, ret) \
|
||||
const SceGxmProgramParameter* var = sceGxmProgramFindParameterByName(gxp, name); \
|
||||
if (!var) { \
|
||||
SDL_Log("Failed to find param %s", name); \
|
||||
return ret; \
|
||||
}
|
||||
|
||||
static void printMatrix4x4(const float mat[4][4]) {
|
||||
sceClibPrintf("mat4{\n");
|
||||
for(int i = 0; i < 4; i++) {
|
||||
sceClibPrintf("%f %f %f %f\n", mat[i][0], mat[i][1], mat[i][2], mat[i][3]);
|
||||
}
|
||||
sceClibPrintf("}\n");
|
||||
}
|
||||
static void printMatrix4x4(const float mat[4][4])
|
||||
{
|
||||
sceClibPrintf("mat4{\n");
|
||||
for (int i = 0; i < 4; i++) {
|
||||
sceClibPrintf("%f %f %f %f\n", mat[i][0], mat[i][1], mat[i][2], mat[i][3]);
|
||||
}
|
||||
sceClibPrintf("}\n");
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user