mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-11 18:41:14 +00:00
fix open isle.ini with fopen
This commit is contained in:
parent
3958762721
commit
b451528d1d
@ -852,7 +852,8 @@ if(VITA)
|
||||
|
||||
set(VPK_FILE_ARGS "")
|
||||
file(GLOB_RECURSE SCE_SYS_FILES packaging/vita/sce_sys/*)
|
||||
foreach(FILE ${SCE_SYS_FILES})
|
||||
file(GLOB_RECURSE SCE_MODULE_FILES packaging/vita/sce_module/*)
|
||||
foreach(FILE ${SCE_SYS_FILES} ${SCE_MODULE_FILES})
|
||||
file(RELATIVE_PATH REL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/packaging/vita/ ${FILE})
|
||||
list(APPEND VPK_FILE_ARGS "FILE")
|
||||
list(APPEND VPK_FILE_ARGS ${FILE})
|
||||
|
||||
@ -23,6 +23,7 @@ target_link_libraries(iniparser_paf
|
||||
ScePafStdc_stub
|
||||
SceLibKernel_stub
|
||||
SceLibc_stub
|
||||
SceFios2_stub
|
||||
)
|
||||
|
||||
target_include_directories(iniparser_paf PUBLIC
|
||||
@ -62,8 +63,8 @@ target_link_libraries(isle-config PRIVATE
|
||||
ScePafStdc_stub
|
||||
SceAppSettings_stub
|
||||
SceFios2_stub
|
||||
SceLibc_stub
|
||||
|
||||
#Isle::iniparser
|
||||
iniparser_paf
|
||||
)
|
||||
|
||||
|
||||
@ -34,6 +34,11 @@
|
||||
<string id="msg_max_lod" src="Maximum LOD" />
|
||||
<string id="msg_max_actors" src="Maximum Actors" />
|
||||
|
||||
<string id="msg_msaa" src="MSAA" />
|
||||
<string id="msg_1x" src="1x" />
|
||||
<string id="msg_2x" src="2x" />
|
||||
<string id="msg_4x" src="4x" />
|
||||
|
||||
<!-- Controls -->
|
||||
<string id="msg_touch_control_scheme" src="Touch Control Scheme" />
|
||||
<string id="msg_virtual_gamepad" src="Virtual Gamepad" />
|
||||
|
||||
@ -9,10 +9,10 @@
|
||||
<text_field id="save_path" title="msg_save_path" max_length="255" min_length="0" keyboard_type="alphabet" key="save_path" default_value=""/>
|
||||
<list id="transition_type" title="msg_transition_type" key="transition_type" default_value="0">
|
||||
<list_item id="transition_none" title="msg_transition_none" value="0" />
|
||||
<list_item id="transition_dissolve" title="msg_transition_dissolve" value="1" />
|
||||
<list_item id="transition_mosaic" title="msg_transition_mosaic" value="2" />
|
||||
<list_item id="transition_wipe_down" title="msg_transition_wipe_down" value="3" />
|
||||
<list_item id="transition_windows" title="msg_transition_windows" value="4" />
|
||||
<list_item id="transition_dissolve" title="msg_transition_dissolve" value="2" />
|
||||
<list_item id="transition_mosaic" title="msg_transition_mosaic" value="3" />
|
||||
<list_item id="transition_wipe_down" title="msg_transition_wipe_down" value="4" />
|
||||
<list_item id="transition_windows" title="msg_transition_windows" value="5" />
|
||||
</list>
|
||||
<toggle_switch id="music" title="msg_music" key="music" default_value="1"/>
|
||||
<toggle_switch id="3d_sound" title="msg_3d_sound" key="3d_sound" default_value="1"/>
|
||||
@ -28,6 +28,11 @@
|
||||
<list_item id="quality_medium" title="msg_quality_medium" value="1" />
|
||||
<list_item id="quality_high" title="msg_quality_high" value="2" />
|
||||
</list>
|
||||
<list id="msaa" title="msg_msaa" key="msaa" default_value="4">
|
||||
<list_item id="msaa_1" title="msg_1x" value="1" />
|
||||
<list_item id="msaa_2" title="msg_2x" value="2" />
|
||||
<list_item id="msaa_4" title="msg_4x" value="4" />
|
||||
</list>
|
||||
</setting_list>
|
||||
|
||||
<setting_list id="page_controls" title="msg_page_controls" style="edit" icon="tex_spanner">
|
||||
|
||||
@ -1,134 +0,0 @@
|
||||
#include <psp2/kernel/threadmgr.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
typedef struct SceFiosBuffer {
|
||||
void* pPtr;
|
||||
size_t length;
|
||||
} SceFiosBuffer;
|
||||
|
||||
#define SCE_FIOS_THREAD_TYPES 3
|
||||
|
||||
typedef struct SceFiosParams {
|
||||
uint32_t initialized : 1;
|
||||
uint32_t paramsSize : 15;
|
||||
uint32_t pathMax : 16;
|
||||
uint32_t profiling;
|
||||
uint32_t ioThreadCount;
|
||||
uint32_t threadsPerScheduler;
|
||||
uint32_t extraFlag1 : 1;
|
||||
uint32_t extraFlags : 31;
|
||||
uint32_t maxChunk;
|
||||
uint8_t maxDecompressorThreadCount;
|
||||
uint8_t reserved1;
|
||||
uint8_t reserved2;
|
||||
uint8_t reserved3;
|
||||
intptr_t reserved4;
|
||||
intptr_t reserved5;
|
||||
SceFiosBuffer opStorage;
|
||||
SceFiosBuffer fhStorage;
|
||||
SceFiosBuffer dhStorage;
|
||||
SceFiosBuffer chunkStorage;
|
||||
void* pVprintf;
|
||||
void* pMemcpy;
|
||||
void* pProfileCallback;
|
||||
int threadPriority[SCE_FIOS_THREAD_TYPES];
|
||||
int threadAffinity[SCE_FIOS_THREAD_TYPES];
|
||||
int threadStackSize[SCE_FIOS_THREAD_TYPES];
|
||||
} SceFiosParams;
|
||||
|
||||
#define SCE_KERNEL_HIGHEST_PRIORITY_USER (64)
|
||||
#define SCE_KERNEL_LOWEST_PRIORITY_USER (191)
|
||||
|
||||
#define SCE_FIOS_IO_THREAD_DEFAULT_PRIORITY (SCE_KERNEL_HIGHEST_PRIORITY_USER + 2)
|
||||
#define SCE_FIOS_DECOMPRESSOR_THREAD_DEFAULT_PRIORITY (SCE_KERNEL_LOWEST_PRIORITY_USER - 2)
|
||||
#define SCE_FIOS_CALLBACK_THREAD_DEFAULT_PRIORITY (SCE_KERNEL_HIGHEST_PRIORITY_USER + 2)
|
||||
|
||||
#define SCE_FIOS_THREAD_DEFAULT_AFFINITY SCE_KERNEL_CPU_MASK_USER_2
|
||||
#define SCE_FIOS_IO_THREAD_DEFAULT_AFFINITY SCE_FIOS_THREAD_DEFAULT_AFFINITY
|
||||
#define SCE_FIOS_DECOMPRESSOR_THREAD_DEFAULT_AFFINITY SCE_KERNEL_THREAD_CPU_AFFINITY_MASK_DEFAULT
|
||||
#define SCE_FIOS_CALLBACK_THREAD_DEFAULT_AFFINITY SCE_FIOS_THREAD_DEFAULT_AFFINITY
|
||||
|
||||
#define SCE_FIOS_IO_THREAD_DEFAULT_STACKSIZE (8 * 1024)
|
||||
#define SCE_FIOS_DECOMPRESSOR_THREAD_DEFAULT_STACKSIZE (16 * 1024)
|
||||
#define SCE_FIOS_CALLBACK_THREAD_DEFAULT_STACKSIZE (8 * 1024)
|
||||
|
||||
#define SCE_FIOS_PARAMS_INITIALIZER \
|
||||
{ \
|
||||
0, sizeof(SceFiosParams), 0, 0, 2, 2, 0, 0, (256 * 1024), 2, 0, 0, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, {0, 0}, \
|
||||
NULL, NULL, NULL, \
|
||||
{SCE_FIOS_IO_THREAD_DEFAULT_PRIORITY, \
|
||||
SCE_FIOS_DECOMPRESSOR_THREAD_DEFAULT_PRIORITY, \
|
||||
SCE_FIOS_CALLBACK_THREAD_DEFAULT_PRIORITY}, \
|
||||
{SCE_FIOS_IO_THREAD_DEFAULT_AFFINITY, \
|
||||
SCE_FIOS_DECOMPRESSOR_THREAD_DEFAULT_AFFINITY, \
|
||||
SCE_FIOS_CALLBACK_THREAD_DEFAULT_AFFINITY}, \
|
||||
{ \
|
||||
SCE_FIOS_IO_THREAD_DEFAULT_STACKSIZE, SCE_FIOS_DECOMPRESSOR_THREAD_DEFAULT_STACKSIZE, \
|
||||
SCE_FIOS_CALLBACK_THREAD_DEFAULT_STACKSIZE \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SCE_FIOS_IO_THREAD 0
|
||||
#define SCE_FIOS_DECOMPRESSOR_THREAD 1
|
||||
#define SCE_FIOS_CALLBACK_THREAD 2
|
||||
|
||||
#define SCE_FIOS_FH_SIZE 80
|
||||
#define SCE_FIOS_DH_SIZE 80
|
||||
#define SCE_FIOS_OP_SIZE 168
|
||||
#define SCE_FIOS_CHUNK_SIZE 64
|
||||
|
||||
#define SCE_FIOS_ALIGN_UP(val, align) (((val) + ((align) -1)) & ~((align) -1))
|
||||
|
||||
#define SCE_FIOS_STORAGE_SIZE(num, size) (((num) * (size)) + SCE_FIOS_ALIGN_UP(SCE_FIOS_ALIGN_UP((num), 8) / 8, 8))
|
||||
|
||||
#define SCE_FIOS_DH_STORAGE_SIZE(numDHs, pathMax) SCE_FIOS_STORAGE_SIZE(numDHs, SCE_FIOS_DH_SIZE + pathMax)
|
||||
|
||||
#define SCE_FIOS_FH_STORAGE_SIZE(numFHs, pathMax) SCE_FIOS_STORAGE_SIZE(numFHs, SCE_FIOS_FH_SIZE + pathMax)
|
||||
|
||||
#define SCE_FIOS_OP_STORAGE_SIZE(numOps, pathMax) SCE_FIOS_STORAGE_SIZE(numOps, SCE_FIOS_OP_SIZE + pathMax)
|
||||
|
||||
#define SCE_FIOS_CHUNK_STORAGE_SIZE(numChunks) SCE_FIOS_STORAGE_SIZE(numChunks, SCE_FIOS_CHUNK_SIZE)
|
||||
|
||||
int sceFiosInitialize(SceFiosParams* params);
|
||||
|
||||
typedef int64_t SceFiosTime;
|
||||
|
||||
typedef int32_t SceFiosHandle;
|
||||
|
||||
typedef SceFiosHandle SceFiosFH;
|
||||
|
||||
typedef struct SceFiosOpenParams {
|
||||
uint32_t openFlags : 16;
|
||||
uint32_t opFlags : 16;
|
||||
uint32_t reserved;
|
||||
SceFiosBuffer buffer;
|
||||
} SceFiosOpenParams;
|
||||
|
||||
typedef struct SceFiosOpAttr {
|
||||
SceFiosTime deadline;
|
||||
void* pCallback;
|
||||
void* pCallbackContext;
|
||||
int32_t priority : 8;
|
||||
uint32_t opflags : 24;
|
||||
uint32_t userTag;
|
||||
void* userPtr;
|
||||
void* pReserved;
|
||||
} SceFiosOpAttr;
|
||||
|
||||
int sceFiosFHOpenWithModeSync(
|
||||
const SceFiosOpAttr* pAttr,
|
||||
SceFiosFH* pOutFH,
|
||||
const char* pPath,
|
||||
const SceFiosOpenParams* pOpenParams,
|
||||
int32_t nativeMode
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@ -1,4 +1,3 @@
|
||||
#include "fios2.h"
|
||||
#include "pafinc.h"
|
||||
|
||||
#include <app_settings.h>
|
||||
@ -9,6 +8,8 @@
|
||||
#include <psp2/kernel/modulemgr.h>
|
||||
#include <psp2/sysmodule.h>
|
||||
|
||||
int sceLibcHeapSize = 10 * 1024 * 1024;
|
||||
|
||||
const char* g_iniPath = "ux0:data/isledecomp/isle/isle.ini";
|
||||
|
||||
paf::Framework* g_fw;
|
||||
@ -23,6 +24,7 @@ struct Config {
|
||||
int m_transition_type;
|
||||
int m_texture_quality;
|
||||
int m_model_quality;
|
||||
int m_msaa;
|
||||
int m_touch_scheme;
|
||||
bool m_wide_view_angle;
|
||||
bool m_music;
|
||||
@ -48,6 +50,7 @@ struct Config {
|
||||
m_texture_path = "/textures/";
|
||||
m_model_quality = 2;
|
||||
m_texture_quality = 1;
|
||||
m_msaa = 4;
|
||||
m_max_lod = 3.5f;
|
||||
m_max_actors = 20;
|
||||
}
|
||||
@ -61,9 +64,10 @@ struct Config {
|
||||
|
||||
#define GET_INT(x, name) x = iniparser_getint(dict, name, x)
|
||||
#define GET_FLOAT(x, name) x = iniparser_getdouble(dict, name, x)
|
||||
#define GET_STRING(x, name) \
|
||||
x = iniparser_getstring(dict, name, x.c_str()); \
|
||||
sceClibPrintf("%s: %s\n", name, x.c_str())
|
||||
#define GET_STRING(x, name) do { \
|
||||
const char* val = iniparser_getstring(dict, name, nullptr); \
|
||||
if(val != nullptr) x = val; \
|
||||
} while(0)
|
||||
#define GET_BOOLEAN(x, name) x = iniparser_getboolean(dict, name, x)
|
||||
|
||||
GET_STRING(m_base_path, "isle:diskpath");
|
||||
@ -82,6 +86,7 @@ struct Config {
|
||||
GET_BOOLEAN(m_draw_cursor, "isle:Draw Cursor");
|
||||
GET_INT(m_model_quality, "isle:Island Quality");
|
||||
GET_INT(m_texture_quality, "isle:Island Texture");
|
||||
GET_INT(m_msaa, "isle:MSAA");
|
||||
// GET_BOOLEAN(m_use_joystick, "isle:UseJoystick");
|
||||
GET_BOOLEAN(m_haptic, "isle:Haptic");
|
||||
GET_BOOLEAN(m_music, "isle:Music");
|
||||
@ -143,6 +148,7 @@ struct Config {
|
||||
|
||||
SetIniInt("isle:Island Quality", m_model_quality);
|
||||
SetIniInt("isle:Island Texture", m_texture_quality);
|
||||
SetIniInt("isle:MSAA", m_msaa);
|
||||
|
||||
SetIniFloat("isle:Max LOD", m_max_lod);
|
||||
SetIniInt("isle:Max Allowed Extras", m_max_actors);
|
||||
@ -160,6 +166,8 @@ struct Config {
|
||||
FILE* fd = fopen(g_iniPath, "w");
|
||||
if (fd) {
|
||||
iniparser_dump_ini(dict, fd);
|
||||
} else {
|
||||
sceClibPrintf("failed to write isle.ini\n");
|
||||
}
|
||||
iniparser_freedict(dict);
|
||||
|
||||
@ -170,9 +178,39 @@ struct Config {
|
||||
{
|
||||
appSettings->SetString("data_path", this->m_base_path.c_str());
|
||||
appSettings->SetString("save_path", this->m_save_path.c_str());
|
||||
appSettings->SetInt("transition_type", this->m_transition_type);
|
||||
appSettings->SetBool("music", this->m_music);
|
||||
appSettings->SetBool("3d_sound", this->m_3d_sound);
|
||||
appSettings->SetInt("island_texture_quality", this->m_texture_quality);
|
||||
appSettings->SetInt("island_model_quality", this->m_model_quality);
|
||||
appSettings->SetInt("msaa", this->m_msaa);
|
||||
appSettings->SetInt("touch_control_scheme", this->m_touch_scheme);
|
||||
appSettings->SetBool("rumble", this->m_haptic);
|
||||
appSettings->SetBool("texture_loader_extension", this->m_texture_load);
|
||||
appSettings->SetString("texture_loader_path", this->m_texture_path.c_str());
|
||||
}
|
||||
|
||||
void FromSettings(sce::AppSettings* appSettings) {}
|
||||
void FromSettings(sce::AppSettings* appSettings) {
|
||||
char text_buf[255];
|
||||
|
||||
#define GET_STRING(x, name) appSettings->GetString(name, text_buf, sizeof(text_buf), x.c_str()); x = text_buf;
|
||||
|
||||
GET_STRING(this->m_base_path, "data_path");
|
||||
GET_STRING(this->m_save_path, "save_path");
|
||||
appSettings->GetInt("transition_type", &this->m_transition_type, this->m_transition_type);
|
||||
printf("this->m_transition_type: %d\n", this->m_transition_type);
|
||||
appSettings->GetBool("music", &this->m_music, this->m_music);
|
||||
appSettings->GetBool("3d_sound", &this->m_3d_sound, this->m_3d_sound);
|
||||
appSettings->GetInt("island_texture_quality", &this->m_texture_quality, this->m_texture_quality);
|
||||
appSettings->GetInt("island_model_quality", &this->m_model_quality, this->m_model_quality);
|
||||
appSettings->GetInt("msaa", &this->m_msaa, this->m_msaa);
|
||||
appSettings->GetInt("touch_control_scheme", &this->m_touch_scheme, this->m_touch_scheme);
|
||||
appSettings->GetBool("rumble", &this->m_haptic, this->m_haptic);
|
||||
appSettings->GetBool("texture_loader_extension", &this->m_texture_load, this->m_texture_load);
|
||||
GET_STRING(this->m_texture_path, "texture_loader_path");
|
||||
|
||||
#undef GET_STRING
|
||||
}
|
||||
};
|
||||
|
||||
Config g_config;
|
||||
@ -212,13 +250,14 @@ int load_app_settings_plugin()
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool do_launch = false;
|
||||
int exit_type = 0;
|
||||
|
||||
void save_and_exit()
|
||||
{
|
||||
g_config.FromSettings(g_appSettings);
|
||||
g_config.SaveIni();
|
||||
g_fw->RequestShutdown();
|
||||
exit_type = 1;
|
||||
}
|
||||
|
||||
void save_and_launch()
|
||||
@ -226,7 +265,7 @@ void save_and_launch()
|
||||
g_config.FromSettings(g_appSettings);
|
||||
g_config.SaveIni();
|
||||
g_fw->RequestShutdown();
|
||||
do_launch = true;
|
||||
exit_type = 2;
|
||||
}
|
||||
|
||||
void CBOnStartPageTransition(const char* elementId, int32_t type)
|
||||
@ -280,7 +319,9 @@ int32_t CBOnPress2(const char* elementId, const char* newValue)
|
||||
|
||||
void CBOnTerm(int32_t result)
|
||||
{
|
||||
sceKernelExitProcess(0);
|
||||
if(exit_type == 0) {
|
||||
sceKernelExitProcess(0);
|
||||
}
|
||||
}
|
||||
|
||||
const wchar_t* CBOnGetString(const char* elementId)
|
||||
@ -328,44 +369,8 @@ void open_settings()
|
||||
g_appSetIf->ShowFooter();
|
||||
}
|
||||
|
||||
#define MAX_PATH_LENGTH 256
|
||||
|
||||
static int64_t g_OpStorage[SCE_FIOS_OP_STORAGE_SIZE(64, MAX_PATH_LENGTH) / sizeof(int64_t) + 1];
|
||||
static int64_t g_ChunkStorage[SCE_FIOS_CHUNK_STORAGE_SIZE(1024) / sizeof(int64_t) + 1];
|
||||
static int64_t g_FHStorage[SCE_FIOS_FH_STORAGE_SIZE(1024, MAX_PATH_LENGTH) / sizeof(int64_t) + 1];
|
||||
static int64_t g_DHStorage[SCE_FIOS_DH_STORAGE_SIZE(32, MAX_PATH_LENGTH) / sizeof(int64_t) + 1];
|
||||
|
||||
void init_fios2()
|
||||
{
|
||||
sceSysmoduleLoadModule(SCE_SYSMODULE_FIOS2);
|
||||
SceFiosParams params = SCE_FIOS_PARAMS_INITIALIZER;
|
||||
params.opStorage.pPtr = g_OpStorage;
|
||||
params.opStorage.length = sizeof(g_OpStorage);
|
||||
params.chunkStorage.pPtr = g_ChunkStorage;
|
||||
params.chunkStorage.length = sizeof(g_ChunkStorage);
|
||||
params.fhStorage.pPtr = g_FHStorage;
|
||||
params.fhStorage.length = sizeof(g_FHStorage);
|
||||
params.dhStorage.pPtr = g_DHStorage;
|
||||
params.dhStorage.length = sizeof(g_DHStorage);
|
||||
params.pathMax = MAX_PATH_LENGTH;
|
||||
|
||||
params.threadAffinity[SCE_FIOS_IO_THREAD] = 0x10000;
|
||||
params.threadAffinity[SCE_FIOS_CALLBACK_THREAD] = 0;
|
||||
params.threadAffinity[SCE_FIOS_DECOMPRESSOR_THREAD] = 0;
|
||||
|
||||
params.threadPriority[SCE_FIOS_IO_THREAD] = 64;
|
||||
params.threadPriority[SCE_FIOS_CALLBACK_THREAD] = 191;
|
||||
params.threadPriority[SCE_FIOS_DECOMPRESSOR_THREAD] = 191;
|
||||
int ret = sceFiosInitialize(¶ms);
|
||||
if (ret < 0) {
|
||||
sceClibPrintf("sceFiosInitialize: %08x\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
int paf_main(void)
|
||||
{
|
||||
init_fios2();
|
||||
|
||||
paf::Framework::InitParam fwParam;
|
||||
fwParam.mode = paf::Framework::Mode_Normal;
|
||||
|
||||
@ -396,8 +401,9 @@ int paf_main(void)
|
||||
open_settings();
|
||||
paf_fw->Run();
|
||||
|
||||
if (do_launch) {
|
||||
sceAppMgrLoadExec("app0:/eboot.bin", NULL, NULL);
|
||||
if (exit_type == 2) {
|
||||
int ret = sceAppMgrLoadExec("app0:/eboot.bin", NULL, NULL);
|
||||
printf("sceAppMgrLoadExec: %08x\n", ret);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -9,4 +9,5 @@ void VITA_SetupDefaultConfigOverrides(dictionary* p_dictionary)
|
||||
|
||||
iniparser_set(p_dictionary, "isle:diskpath", "ux0:data/isledecomp/DATA/disk");
|
||||
iniparser_set(p_dictionary, "isle:cdpath", "ux0:data/isledecomp/");
|
||||
iniparser_set(p_dictionary, "isle:MSAA", "4");
|
||||
}
|
||||
|
||||
@ -53,12 +53,14 @@ typedef struct GXMContext {
|
||||
|
||||
// display
|
||||
SceGxmRenderTarget* renderTarget;
|
||||
bool renderTargetInit = false;
|
||||
void* displayBuffers[GXM_DISPLAY_BUFFER_COUNT];
|
||||
SceUID displayBuffersUid[GXM_DISPLAY_BUFFER_COUNT];
|
||||
SceGxmColorSurface displayBuffersSurface[GXM_DISPLAY_BUFFER_COUNT];
|
||||
SceGxmSyncObject* displayBuffersSync[GXM_DISPLAY_BUFFER_COUNT];
|
||||
int backBufferIndex = 0;
|
||||
int frontBufferIndex = 1;
|
||||
SceGxmMultisampleMode displayMsaa;
|
||||
|
||||
// depth buffer
|
||||
SceUID depthBufferUid;
|
||||
@ -77,6 +79,15 @@ typedef struct GXMContext {
|
||||
void swap_display();
|
||||
void copy_frontbuffer();
|
||||
int init(SceGxmMultisampleMode msaaMode);
|
||||
void init_cdram_allocator();
|
||||
int init_context();
|
||||
int create_display_buffers(SceGxmMultisampleMode msaaMode);
|
||||
void init_clear_mesh();
|
||||
void destroy_display_buffers();
|
||||
int register_base_shaders();
|
||||
int patch_base_shaders(SceGxmMultisampleMode msaaMode);
|
||||
void destroy_base_shaders();
|
||||
|
||||
void destroy();
|
||||
void clear(float r, float g, float b, bool new_scene);
|
||||
void* alloc(size_t size, size_t align);
|
||||
|
||||
@ -180,34 +180,30 @@ int gxm_library_init()
|
||||
|
||||
GXMContext* gxm;
|
||||
|
||||
int GXMContext::init(SceGxmMultisampleMode msaaMode)
|
||||
void GXMContext::init_cdram_allocator()
|
||||
{
|
||||
if (this->context) {
|
||||
return 0;
|
||||
}
|
||||
// allocator
|
||||
this->cdramMem = vita_mem_alloc(
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW,
|
||||
CDRAM_POOL_SIZE,
|
||||
16,
|
||||
SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE,
|
||||
&this->cdramUID,
|
||||
"cdram_pool"
|
||||
);
|
||||
this->cdramPool = SDL_malloc(tlsf_size());
|
||||
tlsf_create(this->cdramPool);
|
||||
tlsf_add_pool(this->cdramPool, this->cdramMem, CDRAM_POOL_SIZE);
|
||||
}
|
||||
|
||||
int ret = gxm_library_init();
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
int GXMContext::init_context()
|
||||
{
|
||||
int ret;
|
||||
|
||||
const unsigned int patcherBufferSize = 64 * 1024;
|
||||
const unsigned int patcherVertexUsseSize = 64 * 1024;
|
||||
const unsigned int patcherFragmentUsseSize = 64 * 1024;
|
||||
|
||||
const uint32_t alignedWidth = ALIGN(VITA_GXM_SCREEN_WIDTH, SCE_GXM_TILE_SIZEX);
|
||||
const uint32_t alignedHeight = ALIGN(VITA_GXM_SCREEN_HEIGHT, SCE_GXM_TILE_SIZEY);
|
||||
uint32_t sampleCount = alignedWidth * alignedHeight;
|
||||
uint32_t depthStrideInSamples = alignedWidth;
|
||||
|
||||
if (msaaMode == SCE_GXM_MULTISAMPLE_4X) {
|
||||
sampleCount *= 4;
|
||||
depthStrideInSamples *= 2;
|
||||
}
|
||||
else if (msaaMode == SCE_GXM_MULTISAMPLE_2X) {
|
||||
sampleCount *= 2;
|
||||
}
|
||||
|
||||
// allocate buffers
|
||||
this->vdmRingBuffer = vita_mem_alloc(
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE,
|
||||
@ -306,6 +302,25 @@ int GXMContext::init(SceGxmMultisampleMode msaaMode)
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int GXMContext::create_display_buffers(SceGxmMultisampleMode msaaMode)
|
||||
{
|
||||
int ret;
|
||||
|
||||
const uint32_t alignedWidth = ALIGN(VITA_GXM_SCREEN_WIDTH, SCE_GXM_TILE_SIZEX);
|
||||
const uint32_t alignedHeight = ALIGN(VITA_GXM_SCREEN_HEIGHT, SCE_GXM_TILE_SIZEY);
|
||||
uint32_t sampleCount = alignedWidth * alignedHeight;
|
||||
uint32_t depthStrideInSamples = alignedWidth;
|
||||
|
||||
if (msaaMode == SCE_GXM_MULTISAMPLE_4X) {
|
||||
sampleCount *= 4;
|
||||
depthStrideInSamples *= 2;
|
||||
}
|
||||
else if (msaaMode == SCE_GXM_MULTISAMPLE_2X) {
|
||||
sampleCount *= 2;
|
||||
}
|
||||
|
||||
// render target
|
||||
SceGxmRenderTargetParams renderTargetParams;
|
||||
@ -321,6 +336,7 @@ int GXMContext::init(SceGxmMultisampleMode msaaMode)
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
this->renderTargetInit = true;
|
||||
|
||||
for (int i = 0; i < GXM_DISPLAY_BUFFER_COUNT; i++) {
|
||||
this->displayBuffers[i] = vita_mem_alloc(
|
||||
@ -387,19 +403,56 @@ int GXMContext::init(SceGxmMultisampleMode msaaMode)
|
||||
return ret;
|
||||
}
|
||||
|
||||
// allocator
|
||||
this->cdramMem = vita_mem_alloc(
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW,
|
||||
CDRAM_POOL_SIZE,
|
||||
16,
|
||||
SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE,
|
||||
&this->cdramUID,
|
||||
"cdram_pool"
|
||||
);
|
||||
this->cdramPool = SDL_malloc(tlsf_size());
|
||||
tlsf_create(this->cdramPool);
|
||||
tlsf_add_pool(this->cdramPool, this->cdramMem, CDRAM_POOL_SIZE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GXMContext::destroy_display_buffers()
|
||||
{
|
||||
if (this->renderTargetInit) {
|
||||
sceGxmFinish(this->context);
|
||||
sceGxmDestroyRenderTarget(this->renderTarget);
|
||||
this->renderTargetInit = false;
|
||||
}
|
||||
for (int i = 0; i < GXM_DISPLAY_BUFFER_COUNT; i++) {
|
||||
if (this->displayBuffers[i]) {
|
||||
vita_mem_free(this->displayBuffersUid[i]);
|
||||
this->displayBuffers[i] = nullptr;
|
||||
this->displayBuffersUid[i] = -1;
|
||||
sceGxmSyncObjectDestroy(this->displayBuffersSync[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (this->depthBufferData) {
|
||||
vita_mem_free(this->depthBufferUid);
|
||||
this->depthBufferData = nullptr;
|
||||
this->depthBufferUid = -1;
|
||||
}
|
||||
|
||||
if (this->stencilBufferData) {
|
||||
vita_mem_free(this->stencilBufferUid);
|
||||
this->stencilBufferData = nullptr;
|
||||
this->stencilBufferUid = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void GXMContext::init_clear_mesh()
|
||||
{
|
||||
this->clearVertices = static_cast<GXMVertex2D*>(this->alloc(sizeof(GXMVertex2D) * 4, 4));
|
||||
this->clearVertices[0] = {.position = {-1.0, 1.0}, .texCoord = {0, 0}};
|
||||
this->clearVertices[1] = {.position = {1.0, 1.0}, .texCoord = {0, 0}};
|
||||
this->clearVertices[2] = {.position = {-1.0, -1.0}, .texCoord = {0, 0}};
|
||||
this->clearVertices[3] = {.position = {1.0, -1.0}, .texCoord = {0, 0}};
|
||||
|
||||
this->clearIndices = static_cast<uint16_t*>(this->alloc(sizeof(uint16_t) * 4, 4));
|
||||
this->clearIndices[0] = 0;
|
||||
this->clearIndices[1] = 1;
|
||||
this->clearIndices[2] = 2;
|
||||
this->clearIndices[3] = 3;
|
||||
}
|
||||
|
||||
int GXMContext::register_base_shaders()
|
||||
{
|
||||
int ret;
|
||||
// register plane, color, image shaders
|
||||
ret = SCE_ERR(
|
||||
sceGxmShaderPatcherRegisterProgram,
|
||||
@ -430,7 +483,13 @@ int GXMContext::init(SceGxmMultisampleMode msaaMode)
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
this->color_uColor = sceGxmProgramFindParameterByName(colorFragmentProgramGxp, "uColor"); // vec4
|
||||
return 0;
|
||||
}
|
||||
|
||||
int GXMContext::patch_base_shaders(SceGxmMultisampleMode msaaMode)
|
||||
{
|
||||
int ret;
|
||||
{
|
||||
GET_SHADER_PARAM(positionAttribute, planeVertexProgramGxp, "aPosition", -1);
|
||||
GET_SHADER_PARAM(texCoordAttribute, planeVertexProgramGxp, "aTexCoord", -1);
|
||||
@ -498,26 +557,70 @@ int GXMContext::init(SceGxmMultisampleMode msaaMode)
|
||||
}
|
||||
}
|
||||
|
||||
this->color_uColor = sceGxmProgramFindParameterByName(colorFragmentProgramGxp, "uColor"); // vec4
|
||||
return 0;
|
||||
}
|
||||
|
||||
this->clearVertices = static_cast<GXMVertex2D*>(this->alloc(sizeof(GXMVertex2D) * 4, 4));
|
||||
this->clearVertices[0] = {.position = {-1.0, 1.0}, .texCoord = {0, 0}};
|
||||
this->clearVertices[1] = {.position = {1.0, 1.0}, .texCoord = {0, 0}};
|
||||
this->clearVertices[2] = {.position = {-1.0, -1.0}, .texCoord = {0, 0}};
|
||||
this->clearVertices[3] = {.position = {1.0, -1.0}, .texCoord = {0, 0}};
|
||||
void GXMContext::destroy_base_shaders()
|
||||
{
|
||||
sceGxmShaderPatcherReleaseVertexProgram(this->shaderPatcher, this->planeVertexProgram);
|
||||
sceGxmShaderPatcherReleaseFragmentProgram(this->shaderPatcher, this->colorFragmentProgram);
|
||||
sceGxmShaderPatcherReleaseFragmentProgram(this->shaderPatcher, this->imageFragmentProgram);
|
||||
}
|
||||
|
||||
this->clearIndices = static_cast<uint16_t*>(this->alloc(sizeof(uint16_t) * 4, 4));
|
||||
this->clearIndices[0] = 0;
|
||||
this->clearIndices[1] = 1;
|
||||
this->clearIndices[2] = 2;
|
||||
this->clearIndices[3] = 3;
|
||||
int GXMContext::init(SceGxmMultisampleMode msaaMode)
|
||||
{
|
||||
int ret = 0;
|
||||
ret = gxm_library_init();
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
if (this->cdramPool == nullptr) {
|
||||
this->init_cdram_allocator();
|
||||
}
|
||||
|
||||
if (this->context == nullptr) {
|
||||
ret = this->init_context();
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
if (this->planeVertexProgramId == 0) {
|
||||
ret = this->register_base_shaders();
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
if (this->clearVertices == nullptr) {
|
||||
this->init_clear_mesh();
|
||||
}
|
||||
|
||||
// recreate when msaa is different
|
||||
if (msaaMode != this->displayMsaa && this->renderTargetInit) {
|
||||
this->destroy_display_buffers();
|
||||
this->destroy_base_shaders();
|
||||
}
|
||||
|
||||
if (!this->renderTargetInit) {
|
||||
ret = this->create_display_buffers(msaaMode);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
ret = this->patch_base_shaders(msaaMode);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int inuse_mem = 0;
|
||||
void* GXMContext::alloc(size_t size, size_t align)
|
||||
{
|
||||
if (this->cdramPool == nullptr) {
|
||||
this->init_cdram_allocator();
|
||||
}
|
||||
DEBUG_ONLY_PRINTF("cdram_alloc(%d, %d) inuse=%d ", size, align, inuse_mem);
|
||||
void* ptr = tlsf_memalign(this->cdramPool, align, size);
|
||||
DEBUG_ONLY_PRINTF("ptr=%p\n", ptr);
|
||||
@ -602,25 +705,9 @@ void GXMContext::destroy()
|
||||
if (gxm->context) {
|
||||
sceGxmFinish(gxm->context);
|
||||
}
|
||||
if (this->renderTarget) {
|
||||
sceGxmDestroyRenderTarget(this->renderTarget);
|
||||
}
|
||||
for (int i = 0; i < GXM_DISPLAY_BUFFER_COUNT; i++) {
|
||||
if (this->displayBuffersUid[i]) {
|
||||
vita_mem_free(this->displayBuffersUid[i]);
|
||||
this->displayBuffers[i] = nullptr;
|
||||
sceGxmSyncObjectDestroy(this->displayBuffersSync[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (this->depthBufferUid) {
|
||||
vita_mem_free(this->depthBufferUid);
|
||||
}
|
||||
if (this->stencilBufferUid) {
|
||||
vita_mem_free(this->stencilBufferUid);
|
||||
}
|
||||
this->stencilBufferData = nullptr;
|
||||
this->depthBufferData = nullptr;
|
||||
this->destroy_display_buffers();
|
||||
this->destroy_base_shaders();
|
||||
|
||||
sceGxmShaderPatcherDestroy(this->shaderPatcher);
|
||||
sceGxmDestroyContext(this->context);
|
||||
@ -695,6 +782,7 @@ GXMRenderer::GXMRenderer(DWORD width, DWORD height, DWORD msaaSamples)
|
||||
int ret;
|
||||
if (!gxm) {
|
||||
gxm = (GXMContext*) SDL_malloc(sizeof(GXMContext));
|
||||
memset(gxm, 0, sizeof(GXMContext));
|
||||
}
|
||||
ret = SCE_ERR(gxm->init, msaaMode);
|
||||
if (ret < 0) {
|
||||
@ -1020,7 +1108,7 @@ static void convertTextureMetadata(
|
||||
}
|
||||
*textureStride = ALIGN(surface->w, 8) * bytesPerPixel;
|
||||
|
||||
*mipLevels = 1; // look weird right now
|
||||
*mipLevels = 1; // look weird
|
||||
|
||||
size_t totalSize = 0;
|
||||
int currentW = surface->w;
|
||||
@ -1242,7 +1330,7 @@ Uint32 GXMRenderer::GetTextureId(IDirect3DRMTexture* iTexture, bool isUi, float
|
||||
|
||||
// allocate gpu memory
|
||||
uint8_t* textureData = (uint8_t*) gxm->alloc(textureSize, textureAlignment);
|
||||
copySurfaceToGxm(surface, (uint8_t*) textureData, textureStride, paletteOffset, mipLevels);
|
||||
copySurfaceToGxm(surface, textureData, textureStride, paletteOffset, mipLevels);
|
||||
|
||||
SceGxmTexture gxmTexture;
|
||||
SCE_ERR(
|
||||
|
||||
BIN
packaging/vita/sce_module/libc.suprx
Normal file
BIN
packaging/vita/sce_module/libc.suprx
Normal file
Binary file not shown.
BIN
packaging/vita/sce_module/libfios2.suprx
Normal file
BIN
packaging/vita/sce_module/libfios2.suprx
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user