mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-17 04:41:16 +00:00
run clang-format
This commit is contained in:
parent
13c269eacf
commit
3e47c9a779
@ -1,8 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL3/SDL_stdinc.h>
|
#include <SDL3/SDL_stdinc.h>
|
||||||
#include <psp2/kernel/clib.h>
|
|
||||||
#include <psp2/kernel/sysmem.h>
|
|
||||||
#include <psp2/types.h>
|
#include <psp2/types.h>
|
||||||
|
|
||||||
void* patcher_host_alloc(void* user_data, unsigned int size);
|
void* patcher_host_alloc(void* user_data, unsigned int size);
|
||||||
@ -16,3 +14,6 @@ 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);
|
void vita_mem_fragment_usse_free(SceUID uid);
|
||||||
|
|
||||||
|
bool cdram_allocator_create();
|
||||||
|
void* cdram_alloc(size_t size, size_t align);
|
||||||
|
void cdram_free(void* ptr);
|
||||||
|
|||||||
@ -9,31 +9,18 @@
|
|||||||
#ifndef INCBIN_HDR
|
#ifndef INCBIN_HDR
|
||||||
#define INCBIN_HDR
|
#define INCBIN_HDR
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#if defined(__AVX512BW__) || \
|
#if defined(__AVX512BW__) || defined(__AVX512CD__) || defined(__AVX512DQ__) || defined(__AVX512ER__) || \
|
||||||
defined(__AVX512CD__) || \
|
defined(__AVX512PF__) || defined(__AVX512VL__) || defined(__AVX512F__)
|
||||||
defined(__AVX512DQ__) || \
|
#define INCBIN_ALIGNMENT_INDEX 6
|
||||||
defined(__AVX512ER__) || \
|
#elif defined(__AVX__) || defined(__AVX2__)
|
||||||
defined(__AVX512PF__) || \
|
#define INCBIN_ALIGNMENT_INDEX 5
|
||||||
defined(__AVX512VL__) || \
|
#elif defined(__SSE__) || defined(__SSE2__) || defined(__SSE3__) || defined(__SSSE3__) || defined(__SSE4_1__) || \
|
||||||
defined(__AVX512F__)
|
defined(__SSE4_2__) || defined(__neon__) || defined(__ARM_NEON) || defined(__ALTIVEC__)
|
||||||
# define INCBIN_ALIGNMENT_INDEX 6
|
#define INCBIN_ALIGNMENT_INDEX 4
|
||||||
#elif defined(__AVX__) || \
|
|
||||||
defined(__AVX2__)
|
|
||||||
# define INCBIN_ALIGNMENT_INDEX 5
|
|
||||||
#elif defined(__SSE__) || \
|
|
||||||
defined(__SSE2__) || \
|
|
||||||
defined(__SSE3__) || \
|
|
||||||
defined(__SSSE3__) || \
|
|
||||||
defined(__SSE4_1__) || \
|
|
||||||
defined(__SSE4_2__) || \
|
|
||||||
defined(__neon__) || \
|
|
||||||
defined(__ARM_NEON) || \
|
|
||||||
defined(__ALTIVEC__)
|
|
||||||
# define INCBIN_ALIGNMENT_INDEX 4
|
|
||||||
#elif ULONG_MAX != 0xffffffffu
|
#elif ULONG_MAX != 0xffffffffu
|
||||||
# define INCBIN_ALIGNMENT_INDEX 3
|
#define INCBIN_ALIGNMENT_INDEX 3
|
||||||
# else
|
#else
|
||||||
# define INCBIN_ALIGNMENT_INDEX 2
|
#define INCBIN_ALIGNMENT_INDEX 2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Lookup table of (1 << n) where `n' is `INCBIN_ALIGNMENT_INDEX' */
|
/* Lookup table of (1 << n) where `n' is `INCBIN_ALIGNMENT_INDEX' */
|
||||||
@ -46,79 +33,69 @@
|
|||||||
#define INCBIN_ALIGN_SHIFT_6 64
|
#define INCBIN_ALIGN_SHIFT_6 64
|
||||||
|
|
||||||
/* Actual alignment value */
|
/* Actual alignment value */
|
||||||
#define INCBIN_ALIGNMENT \
|
#define INCBIN_ALIGNMENT INCBIN_CONCATENATE(INCBIN_CONCATENATE(INCBIN_ALIGN_SHIFT, _), INCBIN_ALIGNMENT_INDEX)
|
||||||
INCBIN_CONCATENATE( \
|
|
||||||
INCBIN_CONCATENATE(INCBIN_ALIGN_SHIFT, _), \
|
|
||||||
INCBIN_ALIGNMENT_INDEX)
|
|
||||||
|
|
||||||
/* Stringize */
|
/* Stringize */
|
||||||
#define INCBIN_STR(X) \
|
#define INCBIN_STR(X) #X
|
||||||
#X
|
#define INCBIN_STRINGIZE(X) INCBIN_STR(X)
|
||||||
#define INCBIN_STRINGIZE(X) \
|
|
||||||
INCBIN_STR(X)
|
|
||||||
/* Concatenate */
|
/* Concatenate */
|
||||||
#define INCBIN_CAT(X, Y) \
|
#define INCBIN_CAT(X, Y) X##Y
|
||||||
X ## Y
|
#define INCBIN_CONCATENATE(X, Y) INCBIN_CAT(X, Y)
|
||||||
#define INCBIN_CONCATENATE(X, Y) \
|
|
||||||
INCBIN_CAT(X, Y)
|
|
||||||
/* Deferred macro expansion */
|
/* Deferred macro expansion */
|
||||||
#define INCBIN_EVAL(X) \
|
#define INCBIN_EVAL(X) X
|
||||||
X
|
#define INCBIN_INVOKE(N, ...) INCBIN_EVAL(N(__VA_ARGS__))
|
||||||
#define INCBIN_INVOKE(N, ...) \
|
|
||||||
INCBIN_EVAL(N(__VA_ARGS__))
|
|
||||||
/* Variable argument count for overloading by arity */
|
/* Variable argument count for overloading by arity */
|
||||||
#define INCBIN_VA_ARG_COUNTER(_1, _2, _3, N, ...) N
|
#define INCBIN_VA_ARG_COUNTER(_1, _2, _3, N, ...) N
|
||||||
#define INCBIN_VA_ARGC(...) INCBIN_VA_ARG_COUNTER(__VA_ARGS__, 3, 2, 1, 0)
|
#define INCBIN_VA_ARGC(...) INCBIN_VA_ARG_COUNTER(__VA_ARGS__, 3, 2, 1, 0)
|
||||||
|
|
||||||
/* Green Hills uses a different directive for including binary data */
|
/* Green Hills uses a different directive for including binary data */
|
||||||
#if defined(__ghs__)
|
#if defined(__ghs__)
|
||||||
# if (__ghs_asm == 2)
|
#if (__ghs_asm == 2)
|
||||||
# define INCBIN_MACRO ".file"
|
#define INCBIN_MACRO ".file"
|
||||||
/* Or consider the ".myrawdata" entry in the ld file */
|
/* Or consider the ".myrawdata" entry in the ld file */
|
||||||
# else
|
|
||||||
# define INCBIN_MACRO "\tINCBIN"
|
|
||||||
# endif
|
|
||||||
#else
|
#else
|
||||||
# define INCBIN_MACRO ".incbin"
|
#define INCBIN_MACRO "\tINCBIN"
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#define INCBIN_MACRO ".incbin"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
# define INCBIN_ALIGN \
|
#define INCBIN_ALIGN __attribute__((aligned(INCBIN_ALIGNMENT)))
|
||||||
__attribute__((aligned(INCBIN_ALIGNMENT)))
|
|
||||||
#else
|
#else
|
||||||
# define INCBIN_ALIGN __declspec(align(INCBIN_ALIGNMENT))
|
#define INCBIN_ALIGN __declspec(align(INCBIN_ALIGNMENT))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__arm__) || /* GNU C and RealView */ \
|
#if defined(__arm__) || /* GNU C and RealView */ \
|
||||||
defined(__arm) || /* Diab */ \
|
defined(__arm) || /* Diab */ \
|
||||||
defined(_ARM) /* ImageCraft */
|
defined(_ARM) /* ImageCraft */
|
||||||
# define INCBIN_ARM
|
#define INCBIN_ARM
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
/* Utilize .balign where supported */
|
/* Utilize .balign where supported */
|
||||||
# define INCBIN_ALIGN_HOST ".balign " INCBIN_STRINGIZE(INCBIN_ALIGNMENT) "\n"
|
#define INCBIN_ALIGN_HOST ".balign " INCBIN_STRINGIZE(INCBIN_ALIGNMENT) "\n"
|
||||||
# define INCBIN_ALIGN_BYTE ".balign 1\n"
|
#define INCBIN_ALIGN_BYTE ".balign 1\n"
|
||||||
#elif defined(INCBIN_ARM)
|
#elif defined(INCBIN_ARM)
|
||||||
/*
|
/*
|
||||||
* On arm assemblers, the alignment value is calculated as (1 << n) where `n' is
|
* On arm assemblers, the alignment value is calculated as (1 << n) where `n' is
|
||||||
* the shift count. This is the value passed to `.align'
|
* the shift count. This is the value passed to `.align'
|
||||||
*/
|
*/
|
||||||
# define INCBIN_ALIGN_HOST ".align " INCBIN_STRINGIZE(INCBIN_ALIGNMENT_INDEX) "\n"
|
#define INCBIN_ALIGN_HOST ".align " INCBIN_STRINGIZE(INCBIN_ALIGNMENT_INDEX) "\n"
|
||||||
# define INCBIN_ALIGN_BYTE ".align 0\n"
|
#define INCBIN_ALIGN_BYTE ".align 0\n"
|
||||||
#else
|
#else
|
||||||
/* We assume other inline assembler's treat `.align' as `.balign' */
|
/* We assume other inline assembler's treat `.align' as `.balign' */
|
||||||
# define INCBIN_ALIGN_HOST ".align " INCBIN_STRINGIZE(INCBIN_ALIGNMENT) "\n"
|
#define INCBIN_ALIGN_HOST ".align " INCBIN_STRINGIZE(INCBIN_ALIGNMENT) "\n"
|
||||||
# define INCBIN_ALIGN_BYTE ".align 1\n"
|
#define INCBIN_ALIGN_BYTE ".align 1\n"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* INCBIN_CONST is used by incbin.c generated files */
|
/* INCBIN_CONST is used by incbin.c generated files */
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
# define INCBIN_EXTERNAL extern "C"
|
#define INCBIN_EXTERNAL extern "C"
|
||||||
# define INCBIN_CONST extern const
|
#define INCBIN_CONST extern const
|
||||||
#else
|
#else
|
||||||
# define INCBIN_EXTERNAL extern
|
#define INCBIN_EXTERNAL extern
|
||||||
# define INCBIN_CONST const
|
#define INCBIN_CONST const
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -129,11 +106,11 @@
|
|||||||
* platform-specific linker output section naming on your own.
|
* platform-specific linker output section naming on your own.
|
||||||
*/
|
*/
|
||||||
#if !defined(INCBIN_OUTPUT_SECTION)
|
#if !defined(INCBIN_OUTPUT_SECTION)
|
||||||
# if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
# define INCBIN_OUTPUT_SECTION ".const_data"
|
#define INCBIN_OUTPUT_SECTION ".const_data"
|
||||||
# else
|
#else
|
||||||
# define INCBIN_OUTPUT_SECTION ".rodata"
|
#define INCBIN_OUTPUT_SECTION ".rodata"
|
||||||
# endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -143,7 +120,7 @@
|
|||||||
* platform-specific linker output section naming on your own.
|
* platform-specific linker output section naming on your own.
|
||||||
*/
|
*/
|
||||||
#if !defined(INCBIN_OUTPUT_DATA_SECTION)
|
#if !defined(INCBIN_OUTPUT_DATA_SECTION)
|
||||||
# define INCBIN_OUTPUT_DATA_SECTION INCBIN_OUTPUT_SECTION
|
#define INCBIN_OUTPUT_DATA_SECTION INCBIN_OUTPUT_SECTION
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -157,45 +134,46 @@
|
|||||||
* can chose to put the size variable in RAM rather than ROM.
|
* can chose to put the size variable in RAM rather than ROM.
|
||||||
*/
|
*/
|
||||||
#if !defined(INCBIN_OUTPUT_SIZE_SECTION)
|
#if !defined(INCBIN_OUTPUT_SIZE_SECTION)
|
||||||
# define INCBIN_OUTPUT_SIZE_SECTION INCBIN_OUTPUT_SECTION
|
#define INCBIN_OUTPUT_SIZE_SECTION INCBIN_OUTPUT_SECTION
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
# include <TargetConditionals.h>
|
#include <TargetConditionals.h>
|
||||||
# if defined(TARGET_OS_IPHONE) && !defined(INCBIN_SILENCE_BITCODE_WARNING)
|
#if defined(TARGET_OS_IPHONE) && !defined(INCBIN_SILENCE_BITCODE_WARNING)
|
||||||
# warning "incbin is incompatible with bitcode. Using the library will break upload to App Store if you have bitcode enabled. Add `#define INCBIN_SILENCE_BITCODE_WARNING` before including this header to silence this warning."
|
#warning \
|
||||||
# endif
|
"incbin is incompatible with bitcode. Using the library will break upload to App Store if you have bitcode enabled. Add `#define INCBIN_SILENCE_BITCODE_WARNING` before including this header to silence this warning."
|
||||||
|
#endif
|
||||||
/* The directives are different for Apple branded compilers */
|
/* The directives are different for Apple branded compilers */
|
||||||
# define INCBIN_SECTION INCBIN_OUTPUT_SECTION "\n"
|
#define INCBIN_SECTION INCBIN_OUTPUT_SECTION "\n"
|
||||||
# define INCBIN_GLOBAL(NAME) ".globl " INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME "\n"
|
#define INCBIN_GLOBAL(NAME) ".globl " INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME "\n"
|
||||||
# define INCBIN_INT ".long "
|
#define INCBIN_INT ".long "
|
||||||
# define INCBIN_MANGLE "_"
|
#define INCBIN_MANGLE "_"
|
||||||
# define INCBIN_BYTE ".byte "
|
#define INCBIN_BYTE ".byte "
|
||||||
# define INCBIN_TYPE(...)
|
#define INCBIN_TYPE(...)
|
||||||
#else
|
#else
|
||||||
# define INCBIN_SECTION ".section " INCBIN_OUTPUT_SECTION "\n"
|
#define INCBIN_SECTION ".section " INCBIN_OUTPUT_SECTION "\n"
|
||||||
# define INCBIN_GLOBAL(NAME) ".global " INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME "\n"
|
#define INCBIN_GLOBAL(NAME) ".global " INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME "\n"
|
||||||
# if defined(__ghs__)
|
#if defined(__ghs__)
|
||||||
# define INCBIN_INT ".word "
|
#define INCBIN_INT ".word "
|
||||||
# else
|
#else
|
||||||
# define INCBIN_INT ".int "
|
#define INCBIN_INT ".int "
|
||||||
# endif
|
#endif
|
||||||
# if defined(__USER_LABEL_PREFIX__)
|
#if defined(__USER_LABEL_PREFIX__)
|
||||||
# define INCBIN_MANGLE INCBIN_STRINGIZE(__USER_LABEL_PREFIX__)
|
#define INCBIN_MANGLE INCBIN_STRINGIZE(__USER_LABEL_PREFIX__)
|
||||||
# else
|
#else
|
||||||
# define INCBIN_MANGLE ""
|
#define INCBIN_MANGLE ""
|
||||||
# endif
|
#endif
|
||||||
# if defined(INCBIN_ARM)
|
#if defined(INCBIN_ARM)
|
||||||
/* On arm assemblers, `@' is used as a line comment token */
|
/* On arm assemblers, `@' is used as a line comment token */
|
||||||
# define INCBIN_TYPE(NAME) ".type " INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME ", %object\n"
|
#define INCBIN_TYPE(NAME) ".type " INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME ", %object\n"
|
||||||
# elif defined(__MINGW32__) || defined(__MINGW64__) || defined(__CYGWIN__)
|
#elif defined(__MINGW32__) || defined(__MINGW64__) || defined(__CYGWIN__)
|
||||||
/* Mingw and Cygwin don't support this directive either */
|
/* Mingw and Cygwin don't support this directive either */
|
||||||
# define INCBIN_TYPE(NAME)
|
#define INCBIN_TYPE(NAME)
|
||||||
# else
|
#else
|
||||||
/* It's safe to use `@' on other architectures */
|
/* It's safe to use `@' on other architectures */
|
||||||
# define INCBIN_TYPE(NAME) ".type " INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME ", @object\n"
|
#define INCBIN_TYPE(NAME) ".type " INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME ", @object\n"
|
||||||
# endif
|
#endif
|
||||||
# define INCBIN_BYTE ".byte "
|
#define INCBIN_BYTE ".byte "
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* List of style types used for symbol names */
|
/* List of style types used for symbol names */
|
||||||
@ -219,7 +197,7 @@
|
|||||||
* @endcode
|
* @endcode
|
||||||
*/
|
*/
|
||||||
#if !defined(INCBIN_PREFIX)
|
#if !defined(INCBIN_PREFIX)
|
||||||
# define INCBIN_PREFIX g
|
#define INCBIN_PREFIX g
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -243,7 +221,7 @@
|
|||||||
* @endcode
|
* @endcode
|
||||||
*/
|
*/
|
||||||
#if !defined(INCBIN_STYLE)
|
#if !defined(INCBIN_STYLE)
|
||||||
# define INCBIN_STYLE INCBIN_STYLE_CAMEL
|
#define INCBIN_STYLE INCBIN_STYLE_CAMEL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Style lookup tables */
|
/* Style lookup tables */
|
||||||
@ -255,35 +233,17 @@
|
|||||||
#define INCBIN_STYLE_1_SIZE _size
|
#define INCBIN_STYLE_1_SIZE _size
|
||||||
|
|
||||||
/* Style lookup: returning identifier */
|
/* Style lookup: returning identifier */
|
||||||
#define INCBIN_STYLE_IDENT(TYPE) \
|
#define INCBIN_STYLE_IDENT(TYPE) \
|
||||||
INCBIN_CONCATENATE( \
|
INCBIN_CONCATENATE(INCBIN_STYLE_, INCBIN_CONCATENATE(INCBIN_EVAL(INCBIN_STYLE), INCBIN_CONCATENATE(_, TYPE)))
|
||||||
INCBIN_STYLE_, \
|
|
||||||
INCBIN_CONCATENATE( \
|
|
||||||
INCBIN_EVAL(INCBIN_STYLE), \
|
|
||||||
INCBIN_CONCATENATE(_, TYPE)))
|
|
||||||
|
|
||||||
/* Style lookup: returning string literal */
|
/* Style lookup: returning string literal */
|
||||||
#define INCBIN_STYLE_STRING(TYPE) \
|
#define INCBIN_STYLE_STRING(TYPE) INCBIN_STRINGIZE(INCBIN_STYLE_IDENT(TYPE))
|
||||||
INCBIN_STRINGIZE( \
|
|
||||||
INCBIN_STYLE_IDENT(TYPE)) \
|
|
||||||
|
|
||||||
/* Generate the global labels by indirectly invoking the macro with our style
|
/* Generate the global labels by indirectly invoking the macro with our style
|
||||||
* type and concatenating the name against them. */
|
* type and concatenating the name against them. */
|
||||||
#define INCBIN_GLOBAL_LABELS(NAME, TYPE) \
|
#define INCBIN_GLOBAL_LABELS(NAME, TYPE) \
|
||||||
INCBIN_INVOKE( \
|
INCBIN_INVOKE(INCBIN_GLOBAL, INCBIN_CONCATENATE(NAME, INCBIN_INVOKE(INCBIN_STYLE_IDENT, TYPE))) \
|
||||||
INCBIN_GLOBAL, \
|
INCBIN_INVOKE(INCBIN_TYPE, INCBIN_CONCATENATE(NAME, INCBIN_INVOKE(INCBIN_STYLE_IDENT, TYPE)))
|
||||||
INCBIN_CONCATENATE( \
|
|
||||||
NAME, \
|
|
||||||
INCBIN_INVOKE( \
|
|
||||||
INCBIN_STYLE_IDENT, \
|
|
||||||
TYPE))) \
|
|
||||||
INCBIN_INVOKE( \
|
|
||||||
INCBIN_TYPE, \
|
|
||||||
INCBIN_CONCATENATE( \
|
|
||||||
NAME, \
|
|
||||||
INCBIN_INVOKE( \
|
|
||||||
INCBIN_STYLE_IDENT, \
|
|
||||||
TYPE)))
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Externally reference binary data included in another translation unit.
|
* @brief Externally reference binary data included in another translation unit.
|
||||||
@ -316,23 +276,19 @@
|
|||||||
* // extern const unsigned int <prefix>Foo<size>;
|
* // extern const unsigned int <prefix>Foo<size>;
|
||||||
* @endcode
|
* @endcode
|
||||||
*/
|
*/
|
||||||
#define INCBIN_EXTERN(...) \
|
#define INCBIN_EXTERN(...) INCBIN_CONCATENATE(INCBIN_EXTERN_, INCBIN_VA_ARGC(__VA_ARGS__))(__VA_ARGS__)
|
||||||
INCBIN_CONCATENATE(INCBIN_EXTERN_, INCBIN_VA_ARGC(__VA_ARGS__))(__VA_ARGS__)
|
#define INCBIN_EXTERN_1(NAME, ...) INCBIN_EXTERN_2(unsigned char, NAME)
|
||||||
#define INCBIN_EXTERN_1(NAME, ...) \
|
#define INCBIN_EXTERN_2(TYPE, NAME) \
|
||||||
INCBIN_EXTERN_2(unsigned char, NAME)
|
INCBIN_EXTERNAL const INCBIN_ALIGN TYPE \
|
||||||
#define INCBIN_EXTERN_2(TYPE, NAME) \
|
INCBIN_CONCATENATE(INCBIN_CONCATENATE(INCBIN_PREFIX, NAME), INCBIN_STYLE_IDENT(DATA))[]; \
|
||||||
INCBIN_EXTERNAL const INCBIN_ALIGN TYPE \
|
INCBIN_EXTERNAL const INCBIN_ALIGN TYPE* const INCBIN_CONCATENATE( \
|
||||||
INCBIN_CONCATENATE( \
|
INCBIN_CONCATENATE(INCBIN_PREFIX, NAME), \
|
||||||
INCBIN_CONCATENATE(INCBIN_PREFIX, NAME), \
|
INCBIN_STYLE_IDENT(END) \
|
||||||
INCBIN_STYLE_IDENT(DATA))[]; \
|
); \
|
||||||
INCBIN_EXTERNAL const INCBIN_ALIGN TYPE *const \
|
INCBIN_EXTERNAL const unsigned int INCBIN_CONCATENATE( \
|
||||||
INCBIN_CONCATENATE( \
|
INCBIN_CONCATENATE(INCBIN_PREFIX, NAME), \
|
||||||
INCBIN_CONCATENATE(INCBIN_PREFIX, NAME), \
|
INCBIN_STYLE_IDENT(SIZE) \
|
||||||
INCBIN_STYLE_IDENT(END)); \
|
)
|
||||||
INCBIN_EXTERNAL const unsigned int \
|
|
||||||
INCBIN_CONCATENATE( \
|
|
||||||
INCBIN_CONCATENATE(INCBIN_PREFIX, NAME), \
|
|
||||||
INCBIN_STYLE_IDENT(SIZE))
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Externally reference textual data included in another translation unit.
|
* @brief Externally reference textual data included in another translation unit.
|
||||||
@ -354,8 +310,7 @@
|
|||||||
* // extern const unsigned int <prefix>Foo<size>;
|
* // extern const unsigned int <prefix>Foo<size>;
|
||||||
* @endcode
|
* @endcode
|
||||||
*/
|
*/
|
||||||
#define INCTXT_EXTERN(NAME) \
|
#define INCTXT_EXTERN(NAME) INCBIN_EXTERN_2(char, NAME)
|
||||||
INCBIN_EXTERN_2(char, NAME)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Include a binary file into the current translation unit.
|
* @brief Include a binary file into the current translation unit.
|
||||||
@ -397,41 +352,29 @@
|
|||||||
* please @see INCBIN_EXTERN.
|
* please @see INCBIN_EXTERN.
|
||||||
*/
|
*/
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
# define INCBIN(NAME, FILENAME) \
|
#define INCBIN(NAME, FILENAME) INCBIN_EXTERN(NAME)
|
||||||
INCBIN_EXTERN(NAME)
|
|
||||||
#else
|
#else
|
||||||
# define INCBIN(...) \
|
#define INCBIN(...) INCBIN_CONCATENATE(INCBIN_, INCBIN_VA_ARGC(__VA_ARGS__))(__VA_ARGS__)
|
||||||
INCBIN_CONCATENATE(INCBIN_, INCBIN_VA_ARGC(__VA_ARGS__))(__VA_ARGS__)
|
#if defined(__GNUC__)
|
||||||
# if defined(__GNUC__)
|
#define INCBIN_1(...) _Pragma("GCC error \"Single argument INCBIN not allowed\"")
|
||||||
# define INCBIN_1(...) _Pragma("GCC error \"Single argument INCBIN not allowed\"")
|
#elif defined(__clang__)
|
||||||
# elif defined(__clang__)
|
#define INCBIN_1(...) _Pragma("clang error \"Single argument INCBIN not allowed\"")
|
||||||
# define INCBIN_1(...) _Pragma("clang error \"Single argument INCBIN not allowed\"")
|
#else
|
||||||
# else
|
#define INCBIN_1(...) /* Cannot do anything here */
|
||||||
# define INCBIN_1(...) /* Cannot do anything here */
|
#endif
|
||||||
# endif
|
#define INCBIN_2(NAME, FILENAME) INCBIN_3(unsigned char, NAME, FILENAME)
|
||||||
# define INCBIN_2(NAME, FILENAME) \
|
#define INCBIN_3(TYPE, NAME, FILENAME) INCBIN_COMMON(TYPE, NAME, FILENAME, /* No terminator for binary data */)
|
||||||
INCBIN_3(unsigned char, NAME, FILENAME)
|
#define INCBIN_COMMON(TYPE, NAME, FILENAME, TERMINATOR) \
|
||||||
# define INCBIN_3(TYPE, NAME, FILENAME) INCBIN_COMMON(TYPE, NAME, FILENAME, /* No terminator for binary data */)
|
__asm__(INCBIN_SECTION INCBIN_GLOBAL_LABELS(NAME, DATA) \
|
||||||
# define INCBIN_COMMON(TYPE, NAME, FILENAME, TERMINATOR) \
|
INCBIN_ALIGN_HOST INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(DATA \
|
||||||
__asm__(INCBIN_SECTION \
|
) ":\n" INCBIN_MACRO " \"" FILENAME "\"\n" TERMINATOR INCBIN_GLOBAL_LABELS(NAME, END) \
|
||||||
INCBIN_GLOBAL_LABELS(NAME, DATA) \
|
INCBIN_ALIGN_BYTE INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(END \
|
||||||
INCBIN_ALIGN_HOST \
|
) ":\n" INCBIN_BYTE "1\n" INCBIN_GLOBAL_LABELS(NAME, SIZE) \
|
||||||
INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(DATA) ":\n" \
|
INCBIN_ALIGN_HOST INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(SIZE \
|
||||||
INCBIN_MACRO " \"" FILENAME "\"\n" \
|
) ":\n" INCBIN_INT INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(END \
|
||||||
TERMINATOR \
|
) " - " INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(DATA \
|
||||||
INCBIN_GLOBAL_LABELS(NAME, END) \
|
) "\n" INCBIN_ALIGN_HOST ".text\n"); \
|
||||||
INCBIN_ALIGN_BYTE \
|
INCBIN_EXTERN(TYPE, NAME)
|
||||||
INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(END) ":\n" \
|
|
||||||
INCBIN_BYTE "1\n" \
|
|
||||||
INCBIN_GLOBAL_LABELS(NAME, SIZE) \
|
|
||||||
INCBIN_ALIGN_HOST \
|
|
||||||
INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(SIZE) ":\n" \
|
|
||||||
INCBIN_INT INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(END) " - " \
|
|
||||||
INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(DATA) "\n" \
|
|
||||||
INCBIN_ALIGN_HOST \
|
|
||||||
".text\n" \
|
|
||||||
); \
|
|
||||||
INCBIN_EXTERN(TYPE, NAME)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -466,11 +409,9 @@
|
|||||||
* please @see INCBIN_EXTERN.
|
* please @see INCBIN_EXTERN.
|
||||||
*/
|
*/
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
# define INCTXT(NAME, FILENAME) \
|
#define INCTXT(NAME, FILENAME) INCBIN_EXTERN(NAME)
|
||||||
INCBIN_EXTERN(NAME)
|
|
||||||
#else
|
#else
|
||||||
# define INCTXT(NAME, FILENAME) \
|
#define INCTXT(NAME, FILENAME) INCBIN_COMMON(char, NAME, FILENAME, INCBIN_BYTE "0\n")
|
||||||
INCBIN_COMMON(char, NAME, FILENAME, INCBIN_BYTE "0\n")
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -1,9 +1,17 @@
|
|||||||
#include "gxm_memory.h"
|
#include "gxm_memory.h"
|
||||||
|
#include "tlsf.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#include <SDL3/SDL_stdinc.h>
|
#include <SDL3/SDL_stdinc.h>
|
||||||
#include <psp2/gxm.h>
|
#include <psp2/gxm.h>
|
||||||
|
#include <psp2/kernel/clib.h>
|
||||||
|
#include <psp2/kernel/sysmem.h>
|
||||||
|
|
||||||
|
#define CDRAM_POOL_SIZE 64 * 1024 * 1024
|
||||||
|
|
||||||
|
static SceUID cdramAllocatorUID = -1;
|
||||||
|
static tlsf_t cdramAllocator = nullptr;
|
||||||
|
int inuse_mem = 0;
|
||||||
|
|
||||||
void* patcher_host_alloc(void* user_data, unsigned int size)
|
void* patcher_host_alloc(void* user_data, unsigned int size)
|
||||||
{
|
{
|
||||||
@ -114,3 +122,53 @@ void vita_mem_fragment_usse_free(SceUID uid)
|
|||||||
sceGxmUnmapFragmentUsseMemory(mem);
|
sceGxmUnmapFragmentUsseMemory(mem);
|
||||||
sceKernelFreeMemBlock(uid);
|
sceKernelFreeMemBlock(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool cdram_allocator_create()
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = sceKernelAllocMemBlock("gpu_cdram_pool", SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW, CDRAM_POOL_SIZE, NULL);
|
||||||
|
if (ret < 0) {
|
||||||
|
sceClibPrintf("sceKernelAllocMemBlock failed: %08x\n", ret);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
cdramAllocatorUID = ret;
|
||||||
|
|
||||||
|
void* mem;
|
||||||
|
ret = sceKernelGetMemBlockBase(cdramAllocatorUID, &mem);
|
||||||
|
if (ret < 0) {
|
||||||
|
sceClibPrintf("sceKernelGetMemBlockBase failed: %08x\n", ret);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = sceGxmMapMemory(
|
||||||
|
mem,
|
||||||
|
CDRAM_POOL_SIZE,
|
||||||
|
(SceGxmMemoryAttribFlags) (SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE)
|
||||||
|
);
|
||||||
|
if (ret < 0) {
|
||||||
|
sceClibPrintf("sceGxmMapMemory failed: %08x\n", ret);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
cdramAllocator = SDL_malloc(tlsf_size());
|
||||||
|
tlsf_create(cdramAllocator);
|
||||||
|
tlsf_add_pool(cdramAllocator, mem, CDRAM_POOL_SIZE);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* cdram_alloc(size_t size, size_t align)
|
||||||
|
{
|
||||||
|
DEBUG_ONLY_PRINTF("cdram_alloc(%d, %d) inuse=%d ", size, align, inuse_mem);
|
||||||
|
void* ptr = tlsf_memalign(cdramAllocator, align, size);
|
||||||
|
DEBUG_ONLY_PRINTF("ptr=%p\n", ptr);
|
||||||
|
inuse_mem += tlsf_block_size(ptr);
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cdram_free(void* ptr)
|
||||||
|
{
|
||||||
|
inuse_mem -= tlsf_block_size(ptr);
|
||||||
|
DEBUG_ONLY_PRINTF("cdram_free(%p)\n", ptr);
|
||||||
|
tlsf_free(cdramAllocator, ptr);
|
||||||
|
}
|
||||||
|
|||||||
@ -3,10 +3,11 @@
|
|||||||
#include <psp2/razor_capture.h>
|
#include <psp2/razor_capture.h>
|
||||||
#include <psp2/razor_hud.h>
|
#include <psp2/razor_hud.h>
|
||||||
|
|
||||||
extern "C" {
|
extern "C"
|
||||||
extern int sceRazorGpuCaptureSetTrigger(int frames, const char* path);
|
{
|
||||||
|
extern int sceRazorGpuCaptureSetTrigger(int frames, const char* path);
|
||||||
|
|
||||||
extern int sceRazorGpuTraceTrigger();
|
extern int sceRazorGpuTraceTrigger();
|
||||||
extern int sceRazorGpuTraceSetFilename(const char* filename, int counter);
|
extern int sceRazorGpuTraceSetFilename(const char* filename, int counter);
|
||||||
extern int sceRazorHudSetDisplayEnabled(bool enable);
|
extern int sceRazorHudSetDisplayEnabled(bool enable);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,15 +1,16 @@
|
|||||||
#include "d3drmrenderer_gxm.h"
|
#include "d3drmrenderer_gxm.h"
|
||||||
#include "gxm_memory.h"
|
#include "gxm_memory.h"
|
||||||
#include "meshutils.h"
|
#include "meshutils.h"
|
||||||
#include "utils.h"
|
|
||||||
#include "razor.h"
|
#include "razor.h"
|
||||||
#include "tlsf.h"
|
#include "tlsf.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <psp2/display.h>
|
#include <psp2/display.h>
|
||||||
#include <psp2/gxm.h>
|
#include <psp2/gxm.h>
|
||||||
#include <psp2/kernel/modulemgr.h>
|
#include <psp2/kernel/modulemgr.h>
|
||||||
|
#include <psp2/kernel/sysmem.h>
|
||||||
#include <psp2/types.h>
|
#include <psp2/types.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#define INCBIN_PREFIX _inc_
|
#define INCBIN_PREFIX _inc_
|
||||||
@ -27,9 +28,6 @@ bool gxm_initialized = false;
|
|||||||
#define VITA_GXM_COLOR_FORMAT SCE_GXM_COLOR_FORMAT_A8B8G8R8
|
#define VITA_GXM_COLOR_FORMAT SCE_GXM_COLOR_FORMAT_A8B8G8R8
|
||||||
#define VITA_GXM_PIXEL_FORMAT SCE_DISPLAY_PIXELFORMAT_A8B8G8R8
|
#define VITA_GXM_PIXEL_FORMAT SCE_DISPLAY_PIXELFORMAT_A8B8G8R8
|
||||||
|
|
||||||
#define CDRAM_POOL_SIZE 64*1024*1024
|
|
||||||
|
|
||||||
|
|
||||||
INCBIN(main_vert_gxp, "shaders/main.vert.gxp");
|
INCBIN(main_vert_gxp, "shaders/main.vert.gxp");
|
||||||
INCBIN(main_frag_gxp, "shaders/main.frag.gxp");
|
INCBIN(main_frag_gxp, "shaders/main.frag.gxp");
|
||||||
INCBIN(color_frag_gxp, "shaders/color.frag.gxp");
|
INCBIN(color_frag_gxp, "shaders/color.frag.gxp");
|
||||||
@ -60,7 +58,6 @@ static const SceGxmBlendInfo blendInfoTransparent = {
|
|||||||
.alphaDst = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
|
.alphaDst = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static GXMRendererContext gxm_renderer_context;
|
static GXMRendererContext gxm_renderer_context;
|
||||||
|
|
||||||
static void display_callback(const void* callback_data)
|
static void display_callback(const void* callback_data)
|
||||||
@ -84,13 +81,13 @@ static void display_callback(const void* callback_data)
|
|||||||
static int load_skprx(const char* name)
|
static int load_skprx(const char* name)
|
||||||
{
|
{
|
||||||
int modid = taiLoadKernelModule(name, 0, nullptr);
|
int modid = taiLoadKernelModule(name, 0, nullptr);
|
||||||
if(modid < 0) {
|
if (modid < 0) {
|
||||||
sceClibPrintf("%s load: 0x%08x\n", name, modid);
|
sceClibPrintf("%s load: 0x%08x\n", name, modid);
|
||||||
return modid;
|
return modid;
|
||||||
}
|
}
|
||||||
int status;
|
int status;
|
||||||
int ret = taiStartKernelModule(modid, 0, nullptr, 0, nullptr, &status);
|
int ret = taiStartKernelModule(modid, 0, nullptr, 0, nullptr, &status);
|
||||||
if(ret < 0) {
|
if (ret < 0) {
|
||||||
sceClibPrintf("%s start: 0x%08x\n", name, ret);
|
sceClibPrintf("%s start: 0x%08x\n", name, ret);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -99,13 +96,13 @@ static int load_skprx(const char* name)
|
|||||||
static int load_suprx(const char* name)
|
static int load_suprx(const char* name)
|
||||||
{
|
{
|
||||||
int modid = _sceKernelLoadModule(name, 0, nullptr);
|
int modid = _sceKernelLoadModule(name, 0, nullptr);
|
||||||
if(modid < 0) {
|
if (modid < 0) {
|
||||||
sceClibPrintf("%s load: 0x%08x\n", name, modid);
|
sceClibPrintf("%s load: 0x%08x\n", name, modid);
|
||||||
return modid;
|
return modid;
|
||||||
}
|
}
|
||||||
int status;
|
int status;
|
||||||
int ret = sceKernelStartModule(modid, 0, nullptr, 0, nullptr, &status);
|
int ret = sceKernelStartModule(modid, 0, nullptr, 0, nullptr, &status);
|
||||||
if(ret < 0) {
|
if (ret < 0) {
|
||||||
sceClibPrintf("%s start: 0x%08x\n", name, ret);
|
sceClibPrintf("%s start: 0x%08x\n", name, ret);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -115,18 +112,18 @@ static const bool extra_debug = false;
|
|||||||
|
|
||||||
static void load_razor()
|
static void load_razor()
|
||||||
{
|
{
|
||||||
if(load_suprx("app0:librazorcapture_es4.suprx") >= 0) {
|
if (load_suprx("app0:librazorcapture_es4.suprx") >= 0) {
|
||||||
with_razor = true;
|
with_razor = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(extra_debug) {
|
if (extra_debug) {
|
||||||
load_skprx("ux0:app/LEGO00001/syslibtrace.skprx");
|
load_skprx("ux0:app/LEGO00001/syslibtrace.skprx");
|
||||||
load_skprx("ux0:app/LEGO00001/pamgr.skprx");
|
load_skprx("ux0:app/LEGO00001/pamgr.skprx");
|
||||||
|
|
||||||
if(load_suprx("app0:libperf.suprx") >= 0) {
|
if (load_suprx("app0:libperf.suprx") >= 0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(load_suprx("app0:librazorhud_es4.suprx") >= 0) {
|
if (load_suprx("app0:librazorhud_es4.suprx") >= 0) {
|
||||||
with_razor_hud = true;
|
with_razor_hud = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -135,7 +132,7 @@ static void load_razor()
|
|||||||
sceRazorGpuCaptureEnableSalvage("ux0:data/gpu_crash.sgx");
|
sceRazorGpuCaptureEnableSalvage("ux0:data/gpu_crash.sgx");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(with_razor_hud) {
|
if (with_razor_hud) {
|
||||||
sceRazorGpuTraceSetFilename("ux0:data/gpu_trace", 3);
|
sceRazorGpuTraceSetFilename("ux0:data/gpu_trace", 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -165,62 +162,6 @@ bool gxm_init()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SceUID cdramAllocatorUID = -1;
|
|
||||||
static tlsf_t cdramAllocator = nullptr;
|
|
||||||
|
|
||||||
bool cdram_allocator_create() {
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = sceKernelAllocMemBlock(
|
|
||||||
"gpu_cdram_pool",
|
|
||||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW,
|
|
||||||
CDRAM_POOL_SIZE,
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
if (ret < 0) {
|
|
||||||
sceClibPrintf("sceKernelAllocMemBlock failed: %08x\n", ret);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
cdramAllocatorUID = ret;
|
|
||||||
|
|
||||||
void* mem;
|
|
||||||
ret = sceKernelGetMemBlockBase(cdramAllocatorUID, &mem);
|
|
||||||
if (ret < 0) {
|
|
||||||
sceClibPrintf("sceKernelGetMemBlockBase failed: %08x\n", ret);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = sceGxmMapMemory(
|
|
||||||
mem,
|
|
||||||
CDRAM_POOL_SIZE,
|
|
||||||
(SceGxmMemoryAttribFlags) (SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE)
|
|
||||||
);
|
|
||||||
if (ret < 0) {
|
|
||||||
sceClibPrintf("sceGxmMapMemory failed: %08x\n", ret);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
cdramAllocator = SDL_malloc(tlsf_size());
|
|
||||||
tlsf_create(cdramAllocator);
|
|
||||||
tlsf_add_pool(cdramAllocator, mem, CDRAM_POOL_SIZE);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int inuse_mem = 0;
|
|
||||||
inline void* cdram_alloc(size_t size, size_t align) {
|
|
||||||
sceClibPrintf("cdram_alloc(%d, %d) inuse=%d ", size, align, inuse_mem);
|
|
||||||
void* ptr = tlsf_memalign(cdramAllocator, align, size);
|
|
||||||
sceClibPrintf("ptr=%p\n", ptr);
|
|
||||||
inuse_mem += tlsf_block_size(ptr);
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void cdram_free(void* ptr) {
|
|
||||||
inuse_mem -= tlsf_block_size(ptr);
|
|
||||||
sceClibPrintf("cdram_free(%p)\n", ptr);
|
|
||||||
tlsf_free(cdramAllocator, ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool create_gxm_context()
|
static bool create_gxm_context()
|
||||||
{
|
{
|
||||||
GXMRendererContext* data = &gxm_renderer_context;
|
GXMRendererContext* data = &gxm_renderer_context;
|
||||||
@ -407,7 +348,7 @@ GXMRenderer::GXMRenderer(DWORD width, DWORD height)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!cdram_allocator_create()) {
|
if (!cdram_allocator_create()) {
|
||||||
sceClibPrintf("failed to create cdram allocator");
|
sceClibPrintf("failed to create cdram allocator");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -551,15 +492,15 @@ GXMRenderer::GXMRenderer(DWORD width, DWORD height)
|
|||||||
vertexStreams[0].indexSource = SCE_GXM_INDEX_SOURCE_INDEX_16BIT;
|
vertexStreams[0].indexSource = SCE_GXM_INDEX_SOURCE_INDEX_16BIT;
|
||||||
|
|
||||||
if (SCE_ERR(
|
if (SCE_ERR(
|
||||||
sceGxmShaderPatcherCreateVertexProgram,
|
sceGxmShaderPatcherCreateVertexProgram,
|
||||||
this->shaderPatcher,
|
this->shaderPatcher,
|
||||||
this->mainVertexProgramId,
|
this->mainVertexProgramId,
|
||||||
vertexAttributes,
|
vertexAttributes,
|
||||||
3,
|
3,
|
||||||
vertexStreams,
|
vertexStreams,
|
||||||
1,
|
1,
|
||||||
&this->mainVertexProgram
|
&this->mainVertexProgram
|
||||||
)) {
|
)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -635,7 +576,6 @@ GXMRenderer::GXMRenderer(DWORD width, DWORD height)
|
|||||||
// clear uniforms
|
// clear uniforms
|
||||||
this->colorShader_uColor = sceGxmProgramFindParameterByName(colorFragmentProgramGxp, "uColor"); // vec4
|
this->colorShader_uColor = sceGxmProgramFindParameterByName(colorFragmentProgramGxp, "uColor"); // vec4
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < GXM_FRAGMENT_BUFFER_COUNT; i++) {
|
for (int i = 0; i < GXM_FRAGMENT_BUFFER_COUNT; i++) {
|
||||||
this->lights[i] = static_cast<GXMSceneLightUniform*>(cdram_alloc(sizeof(GXMSceneLightUniform), 4));
|
this->lights[i] = static_cast<GXMSceneLightUniform*>(cdram_alloc(sizeof(GXMSceneLightUniform), 4));
|
||||||
}
|
}
|
||||||
@ -649,13 +589,13 @@ GXMRenderer::GXMRenderer(DWORD width, DWORD height)
|
|||||||
this->quadIndices[3] = 3;
|
this->quadIndices[3] = 3;
|
||||||
|
|
||||||
volatile uint32_t* notificationMem = sceGxmGetNotificationRegion();
|
volatile uint32_t* notificationMem = sceGxmGetNotificationRegion();
|
||||||
for(uint32_t i = 0; i < GXM_FRAGMENT_BUFFER_COUNT; i++) {
|
for (uint32_t i = 0; i < GXM_FRAGMENT_BUFFER_COUNT; i++) {
|
||||||
this->fragmentNotifications[i].address = notificationMem++;
|
this->fragmentNotifications[i].address = notificationMem++;
|
||||||
this->fragmentNotifications[i].value = 0;
|
this->fragmentNotifications[i].value = 0;
|
||||||
}
|
}
|
||||||
this->currentFragmentBufferIndex = 0;
|
this->currentFragmentBufferIndex = 0;
|
||||||
|
|
||||||
for(uint32_t i = 0; i < GXM_VERTEX_BUFFER_COUNT; i++) {
|
for (uint32_t i = 0; i < GXM_VERTEX_BUFFER_COUNT; i++) {
|
||||||
this->vertexNotifications[i].address = notificationMem++;
|
this->vertexNotifications[i].address = notificationMem++;
|
||||||
this->vertexNotifications[i].value = 0;
|
this->vertexNotifications[i].value = 0;
|
||||||
}
|
}
|
||||||
@ -663,10 +603,10 @@ GXMRenderer::GXMRenderer(DWORD width, DWORD height)
|
|||||||
|
|
||||||
int count;
|
int count;
|
||||||
auto ids = SDL_GetGamepads(&count);
|
auto ids = SDL_GetGamepads(&count);
|
||||||
for(int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
auto id = ids[i];
|
auto id = ids[i];
|
||||||
auto gamepad = SDL_OpenGamepad(id);
|
auto gamepad = SDL_OpenGamepad(id);
|
||||||
if(gamepad != nullptr) {
|
if (gamepad != nullptr) {
|
||||||
this->gamepad = gamepad;
|
this->gamepad = gamepad;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -734,90 +674,84 @@ static void convertTextureMetadata(
|
|||||||
SDL_Surface* surface,
|
SDL_Surface* surface,
|
||||||
bool* supportedFormat,
|
bool* supportedFormat,
|
||||||
SceGxmTextureFormat* gxmTextureFormat,
|
SceGxmTextureFormat* gxmTextureFormat,
|
||||||
size_t* textureSize, // size in bytes
|
size_t* textureSize, // size in bytes
|
||||||
size_t* textureAlignment, // alignment in bytes
|
size_t* textureAlignment, // alignment in bytes
|
||||||
size_t* textureStride, // stride in bytes
|
size_t* textureStride, // stride in bytes
|
||||||
size_t* paletteOffset // offset from textureData in bytes
|
size_t* paletteOffset // offset from textureData in bytes
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
int bytesPerPixel;
|
int bytesPerPixel;
|
||||||
size_t extraDataSize = 0;
|
size_t extraDataSize = 0;
|
||||||
switch (surface->format) {
|
switch (surface->format) {
|
||||||
case SDL_PIXELFORMAT_INDEX8: {
|
case SDL_PIXELFORMAT_INDEX8: {
|
||||||
*supportedFormat = true;
|
*supportedFormat = true;
|
||||||
*gxmTextureFormat = SCE_GXM_TEXTURE_FORMAT_P8_ABGR;
|
*gxmTextureFormat = SCE_GXM_TEXTURE_FORMAT_P8_ABGR;
|
||||||
int pixelsSize = surface->w * surface->h;
|
int pixelsSize = surface->w * surface->h;
|
||||||
int alignBytes = ALIGNMENT(pixelsSize, SCE_GXM_PALETTE_ALIGNMENT);
|
int alignBytes = ALIGNMENT(pixelsSize, SCE_GXM_PALETTE_ALIGNMENT);
|
||||||
extraDataSize = alignBytes + 256 * 4;
|
extraDataSize = alignBytes + 256 * 4;
|
||||||
*textureAlignment = SCE_GXM_PALETTE_ALIGNMENT;
|
*textureAlignment = SCE_GXM_PALETTE_ALIGNMENT;
|
||||||
*paletteOffset = pixelsSize + alignBytes;
|
*paletteOffset = pixelsSize + alignBytes;
|
||||||
bytesPerPixel = 1;
|
bytesPerPixel = 1;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case SDL_PIXELFORMAT_ABGR8888: {
|
|
||||||
*supportedFormat = true;
|
|
||||||
*gxmTextureFormat = SCE_GXM_TEXTURE_FORMAT_U8U8U8U8_ABGR;
|
|
||||||
*textureAlignment = SCE_GXM_TEXTURE_ALIGNMENT;
|
|
||||||
bytesPerPixel = 4;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
*supportedFormat = false;
|
|
||||||
*gxmTextureFormat = SCE_GXM_TEXTURE_FORMAT_U8U8U8U8_ABGR;
|
|
||||||
*textureAlignment = SCE_GXM_TEXTURE_ALIGNMENT;
|
|
||||||
bytesPerPixel = 4;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
*textureStride = ALIGN(surface->w, 8)*bytesPerPixel;
|
case SDL_PIXELFORMAT_ABGR8888: {
|
||||||
*textureSize = (*textureStride)*surface->h+extraDataSize;
|
*supportedFormat = true;
|
||||||
|
*gxmTextureFormat = SCE_GXM_TEXTURE_FORMAT_U8U8U8U8_ABGR;
|
||||||
|
*textureAlignment = SCE_GXM_TEXTURE_ALIGNMENT;
|
||||||
|
bytesPerPixel = 4;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
*supportedFormat = false;
|
||||||
|
*gxmTextureFormat = SCE_GXM_TEXTURE_FORMAT_U8U8U8U8_ABGR;
|
||||||
|
*textureAlignment = SCE_GXM_TEXTURE_ALIGNMENT;
|
||||||
|
bytesPerPixel = 4;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*textureStride = ALIGN(surface->w, 8) * bytesPerPixel;
|
||||||
|
*textureSize = (*textureStride) * surface->h + extraDataSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void copySurfaceToGxm(DirectDrawSurfaceImpl* surface, uint8_t* textureData, size_t dstStride, size_t dstSize)
|
void copySurfaceToGxm(DirectDrawSurfaceImpl* surface, uint8_t* textureData, size_t dstStride, size_t dstSize)
|
||||||
{
|
{
|
||||||
SDL_Surface* src = surface->m_surface;
|
SDL_Surface* src = surface->m_surface;
|
||||||
switch(src->format) {
|
switch (src->format) {
|
||||||
case SDL_PIXELFORMAT_ABGR8888: {
|
case SDL_PIXELFORMAT_ABGR8888: {
|
||||||
for(int y = 0; y < src->h; y++) {
|
for (int y = 0; y < src->h; y++) {
|
||||||
uint8_t* srcRow = (uint8_t*)src->pixels + (y*src->pitch);
|
uint8_t* srcRow = (uint8_t*) src->pixels + (y * src->pitch);
|
||||||
uint8_t* dstRow = textureData + (y*dstStride);
|
uint8_t* dstRow = textureData + (y * dstStride);
|
||||||
size_t rowSize = src->w*4;
|
size_t rowSize = src->w * 4;
|
||||||
if((dstRow - textureData)+rowSize > dstSize) {
|
memcpy(dstRow, srcRow, rowSize);
|
||||||
sceClibPrintf("buffer overrun!!! size=%d y=%d rowSize=%d\n", dstSize, y, rowSize);
|
|
||||||
}
|
|
||||||
memcpy(dstRow, srcRow, rowSize);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case SDL_PIXELFORMAT_INDEX8: {
|
break;
|
||||||
LPDIRECTDRAWPALETTE _palette;
|
}
|
||||||
surface->GetPalette(&_palette);
|
case SDL_PIXELFORMAT_INDEX8: {
|
||||||
auto palette = static_cast<DirectDrawPaletteImpl*>(_palette);
|
LPDIRECTDRAWPALETTE _palette;
|
||||||
|
surface->GetPalette(&_palette);
|
||||||
|
auto palette = static_cast<DirectDrawPaletteImpl*>(_palette);
|
||||||
|
|
||||||
// copy pixels
|
// copy pixels
|
||||||
for(int y = 0; y < src->h; y++) {
|
for (int y = 0; y < src->h; y++) {
|
||||||
void* srcRow = static_cast<uint8_t*>(src->pixels) + (y*src->pitch);
|
void* srcRow = static_cast<uint8_t*>(src->pixels) + (y * src->pitch);
|
||||||
void* dstRow = static_cast<uint8_t*>(textureData) + (y*dstStride);
|
void* dstRow = static_cast<uint8_t*>(textureData) + (y * dstStride);
|
||||||
memcpy(dstRow, srcRow, src->w);
|
memcpy(dstRow, srcRow, src->w);
|
||||||
}
|
}
|
||||||
|
|
||||||
int pixelsSize = src->w * src->h;
|
int pixelsSize = src->w * src->h;
|
||||||
int alignBytes = ALIGNMENT(pixelsSize, SCE_GXM_PALETTE_ALIGNMENT);
|
int alignBytes = ALIGNMENT(pixelsSize, SCE_GXM_PALETTE_ALIGNMENT);
|
||||||
uint8_t* paletteData = textureData + pixelsSize + alignBytes;
|
uint8_t* paletteData = textureData + pixelsSize + alignBytes;
|
||||||
memcpy(paletteData, palette->m_palette->colors, 256 * 4);
|
memcpy(paletteData, palette->m_palette->colors, 256 * 4);
|
||||||
if((paletteData-textureData) + 256*4 > dstSize) {
|
palette->Release();
|
||||||
sceClibPrintf("buffer overrun!!! textureData=%p paletteData=%p size=%d\n", textureData, paletteData, dstSize);
|
break;
|
||||||
}
|
}
|
||||||
palette->Release();
|
default: {
|
||||||
break;
|
DEBUG_ONLY_PRINTF("unsupported format %d\n", SDL_GetPixelFormatName(src->format));
|
||||||
}
|
SDL_Surface* dst = SDL_CreateSurfaceFrom(src->w, src->h, SDL_PIXELFORMAT_ABGR8888, textureData, src->w * 4);
|
||||||
default: {
|
SDL_BlitSurface(src, nullptr, dst, nullptr);
|
||||||
sceClibPrintf("unsupported format %d\n", SDL_GetPixelFormatName(src->format));
|
SDL_DestroySurface(dst);
|
||||||
SDL_Surface* dst = SDL_CreateSurfaceFrom(src->w, src->h, SDL_PIXELFORMAT_ABGR8888, textureData, src->w*4);
|
break;
|
||||||
SDL_BlitSurface(src, nullptr, dst, nullptr);
|
}
|
||||||
SDL_DestroySurface(dst);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -846,7 +780,7 @@ Uint32 GXMRenderer::GetTextureId(IDirect3DRMTexture* iTexture, bool isUi)
|
|||||||
&paletteOffset
|
&paletteOffset
|
||||||
);
|
);
|
||||||
|
|
||||||
if(!supportedFormat) {
|
if (!supportedFormat) {
|
||||||
return NO_TEXTURE_ID;
|
return NO_TEXTURE_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -855,14 +789,15 @@ Uint32 GXMRenderer::GetTextureId(IDirect3DRMTexture* iTexture, bool isUi)
|
|||||||
if (tex.texture == texture) {
|
if (tex.texture == texture) {
|
||||||
if (tex.version != texture->m_version) {
|
if (tex.version != texture->m_version) {
|
||||||
void* textureData = sceGxmTextureGetData(&tex.gxmTexture);
|
void* textureData = sceGxmTextureGetData(&tex.gxmTexture);
|
||||||
copySurfaceToGxm(surface, (uint8_t*)textureData, textureStride, textureSize);
|
copySurfaceToGxm(surface, (uint8_t*) textureData, textureStride, textureSize);
|
||||||
tex.version = texture->m_version;
|
tex.version = texture->m_version;
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sceClibPrintf("Create Texture %s w=%d h=%d s=%d size=%d align=%d\n",
|
DEBUG_ONLY_PRINTF(
|
||||||
|
"Create Texture %s w=%d h=%d s=%d size=%d align=%d\n",
|
||||||
SDL_GetPixelFormatName(surface->m_surface->format),
|
SDL_GetPixelFormatName(surface->m_surface->format),
|
||||||
textureWidth,
|
textureWidth,
|
||||||
textureHeight,
|
textureHeight,
|
||||||
@ -873,24 +808,16 @@ Uint32 GXMRenderer::GetTextureId(IDirect3DRMTexture* iTexture, bool isUi)
|
|||||||
|
|
||||||
// allocate gpu memory
|
// allocate gpu memory
|
||||||
void* textureData = cdram_alloc(textureSize, textureAlignment);
|
void* textureData = cdram_alloc(textureSize, textureAlignment);
|
||||||
copySurfaceToGxm(surface, (uint8_t*)textureData, textureStride, textureSize);
|
copySurfaceToGxm(surface, (uint8_t*) textureData, textureStride, textureSize);
|
||||||
|
|
||||||
SceGxmTexture gxmTexture;
|
SceGxmTexture gxmTexture;
|
||||||
SCE_ERR(
|
SCE_ERR(sceGxmTextureInitLinear, &gxmTexture, textureData, gxmTextureFormat, textureWidth, textureHeight, 0);
|
||||||
sceGxmTextureInitLinear,
|
|
||||||
&gxmTexture,
|
|
||||||
textureData,
|
|
||||||
gxmTextureFormat,
|
|
||||||
textureWidth,
|
|
||||||
textureHeight,
|
|
||||||
0
|
|
||||||
);
|
|
||||||
sceGxmTextureSetMinFilter(&gxmTexture, SCE_GXM_TEXTURE_FILTER_LINEAR);
|
sceGxmTextureSetMinFilter(&gxmTexture, SCE_GXM_TEXTURE_FILTER_LINEAR);
|
||||||
sceGxmTextureSetMagFilter(&gxmTexture, SCE_GXM_TEXTURE_FILTER_LINEAR);
|
sceGxmTextureSetMagFilter(&gxmTexture, SCE_GXM_TEXTURE_FILTER_LINEAR);
|
||||||
sceGxmTextureSetUAddrMode(&gxmTexture, SCE_GXM_TEXTURE_ADDR_REPEAT);
|
sceGxmTextureSetUAddrMode(&gxmTexture, SCE_GXM_TEXTURE_ADDR_REPEAT);
|
||||||
sceGxmTextureSetVAddrMode(&gxmTexture, SCE_GXM_TEXTURE_ADDR_REPEAT);
|
sceGxmTextureSetVAddrMode(&gxmTexture, SCE_GXM_TEXTURE_ADDR_REPEAT);
|
||||||
if (gxmTextureFormat == SCE_GXM_TEXTURE_FORMAT_P8_ABGR) {
|
if (gxmTextureFormat == SCE_GXM_TEXTURE_FORMAT_P8_ABGR) {
|
||||||
sceGxmTextureSetPalette(&gxmTexture, (uint8_t*)textureData + paletteOffset);
|
sceGxmTextureSetPalette(&gxmTexture, (uint8_t*) textureData + paletteOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Uint32 i = 0; i < m_textures.size(); ++i) {
|
for (Uint32 i = 0; i < m_textures.size(); ++i) {
|
||||||
@ -1044,30 +971,31 @@ void GXMRenderer::StartScene()
|
|||||||
bool dpad_right = SDL_GetGamepadButton(this->gamepad, SDL_GAMEPAD_BUTTON_DPAD_RIGHT);
|
bool dpad_right = SDL_GetGamepadButton(this->gamepad, SDL_GAMEPAD_BUTTON_DPAD_RIGHT);
|
||||||
|
|
||||||
// hud display
|
// hud display
|
||||||
if(with_razor_hud && dpad_up != this->button_dpad_up) {
|
if (with_razor_hud && dpad_up != this->button_dpad_up) {
|
||||||
this->button_dpad_up = dpad_up;
|
this->button_dpad_up = dpad_up;
|
||||||
if(dpad_up) {
|
if (dpad_up) {
|
||||||
sceRazorHudSetDisplayEnabled(razor_display_enabled);
|
sceRazorHudSetDisplayEnabled(razor_display_enabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// capture frame
|
// capture frame
|
||||||
if(with_razor && dpad_down != this->button_dpad_down) {
|
if (with_razor && dpad_down != this->button_dpad_down) {
|
||||||
this->button_dpad_down = dpad_down;
|
this->button_dpad_down = dpad_down;
|
||||||
if(dpad_down) {
|
if (dpad_down) {
|
||||||
sceRazorGpuCaptureSetTriggerNextFrame("ux0:/data/capture.sgx");
|
sceRazorGpuCaptureSetTriggerNextFrame("ux0:/data/capture.sgx");
|
||||||
SDL_Log("trigger razor");
|
SDL_Log("trigger razor");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// toggle live
|
// toggle live
|
||||||
if(with_razor_hud && dpad_left != this->button_dpad_left) {
|
if (with_razor_hud && dpad_left != this->button_dpad_left) {
|
||||||
this->button_dpad_left = dpad_left;
|
this->button_dpad_left = dpad_left;
|
||||||
if(dpad_left) {
|
if (dpad_left) {
|
||||||
if(razor_live_started) {
|
if (razor_live_started) {
|
||||||
sceRazorGpuLiveStop();
|
sceRazorGpuLiveStop();
|
||||||
razor_live_started = false;
|
razor_live_started = false;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
sceRazorGpuLiveStart();
|
sceRazorGpuLiveStart();
|
||||||
razor_live_started = true;
|
razor_live_started = true;
|
||||||
}
|
}
|
||||||
@ -1075,9 +1003,9 @@ void GXMRenderer::StartScene()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// trigger trace
|
// trigger trace
|
||||||
if(with_razor_hud && dpad_right != this->button_dpad_right) {
|
if (with_razor_hud && dpad_right != this->button_dpad_right) {
|
||||||
this->button_dpad_right = dpad_right;
|
this->button_dpad_right = dpad_right;
|
||||||
if(dpad_right) {
|
if (dpad_right) {
|
||||||
sceRazorGpuTraceTrigger();
|
sceRazorGpuTraceTrigger();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1099,7 +1027,6 @@ void GXMRenderer::StartScene()
|
|||||||
sceGxmNotificationWait(&this->fragmentNotifications[this->currentFragmentBufferIndex]);
|
sceGxmNotificationWait(&this->fragmentNotifications[this->currentFragmentBufferIndex]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HRESULT GXMRenderer::BeginFrame()
|
HRESULT GXMRenderer::BeginFrame()
|
||||||
{
|
{
|
||||||
this->transparencyEnabled = false;
|
this->transparencyEnabled = false;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user