mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-20 22:21: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)
|
- name: Configure (CMake)
|
||||||
run: |
|
run: |
|
||||||
if [ "${{ matrix.vita }}" = "true" ]; then
|
if [ "${{ matrix.vita }}" = "true" ]; then
|
||||||
PRESET=--preset vita-debug
|
PRESET="--preset vita-debug"
|
||||||
fi
|
fi
|
||||||
${{ matrix.cmake-wrapper || '' }} cmake $PRESET -S . -B build -GNinja \
|
${{ matrix.cmake-wrapper || '' }} cmake $PRESET -S . -B build -GNinja \
|
||||||
-DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \
|
-DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \
|
||||||
|
|||||||
@ -1,15 +1,13 @@
|
|||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#include <psp2/gxm.h>
|
|
||||||
|
|
||||||
#include <SDL3/SDL_stdinc.h>
|
#include <SDL3/SDL_stdinc.h>
|
||||||
|
#include <psp2/gxm.h>
|
||||||
|
|
||||||
static SceUID cdramPoolUID = -1;
|
static SceUID cdramPoolUID = -1;
|
||||||
static SceClibMspace cdramPool = NULL;
|
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* mem = SDL_malloc(size);
|
||||||
@ -23,20 +21,17 @@ void patcher_host_free(void *user_data, void *mem)
|
|||||||
SDL_free(mem);
|
SDL_free(mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* vita_mem_alloc(
|
void* vita_mem_alloc(unsigned int type, size_t size, size_t alignment, int attribs, SceUID* uid)
|
||||||
unsigned int type,
|
{
|
||||||
size_t size,
|
|
||||||
size_t alignment,
|
|
||||||
int attribs,
|
|
||||||
SceUID *uid
|
|
||||||
) {
|
|
||||||
void* mem;
|
void* mem;
|
||||||
|
|
||||||
if (type == SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW) {
|
if (type == SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW) {
|
||||||
size = ALIGN(size, 256 * 1024);
|
size = ALIGN(size, 256 * 1024);
|
||||||
} else if (type == SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_NC_RW) {
|
}
|
||||||
|
else if (type == SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_NC_RW) {
|
||||||
size = ALIGN(size, 1024 * 1024);
|
size = ALIGN(size, 1024 * 1024);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
size = ALIGN(size, 4 * 1024);
|
size = ALIGN(size, 4 * 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,7 +118,8 @@ void vita_mem_fragment_usse_free(SceUID uid)
|
|||||||
sceKernelFreeMemBlock(uid);
|
sceKernelFreeMemBlock(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cdramPool_init() {
|
bool cdramPool_init()
|
||||||
|
{
|
||||||
if (cdramPool) {
|
if (cdramPool) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -153,13 +149,18 @@ bool cdramPool_init() {
|
|||||||
if (!cdramPool) {
|
if (!cdramPool) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ret = sceGxmMapMemory(mem, poolsize, (SceGxmMemoryAttribFlags)(SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE));
|
ret = sceGxmMapMemory(
|
||||||
|
mem,
|
||||||
|
poolsize,
|
||||||
|
(SceGxmMemoryAttribFlags) (SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE)
|
||||||
|
);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SceClibMspace cdramPool_get() {
|
SceClibMspace cdramPool_get()
|
||||||
|
{
|
||||||
return cdramPool;
|
return cdramPool;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,20 +1,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <psp2/types.h>
|
|
||||||
#include <psp2/kernel/sysmem.h>
|
|
||||||
#include <psp2/kernel/clib.h>
|
|
||||||
#include <SDL3/SDL_stdinc.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_alloc(void* user_data, unsigned int size);
|
||||||
void patcher_host_free(void* user_data, void* mem);
|
void patcher_host_free(void* user_data, void* mem);
|
||||||
|
|
||||||
void* vita_mem_alloc(
|
void* vita_mem_alloc(unsigned int type, size_t size, size_t alignment, int attribs, SceUID* uid);
|
||||||
unsigned int type,
|
|
||||||
size_t size,
|
|
||||||
size_t alignment,
|
|
||||||
int attribs,
|
|
||||||
SceUID* uid
|
|
||||||
);
|
|
||||||
void vita_mem_free(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);
|
||||||
|
|||||||
@ -1,17 +1,15 @@
|
|||||||
#include "d3drmrenderer_gxm.h"
|
#include "d3drmrenderer_gxm.h"
|
||||||
|
#include "memory.h"
|
||||||
#include "meshutils.h"
|
#include "meshutils.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include <psp2/gxm.h>
|
|
||||||
#include <psp2/display.h>
|
#include <psp2/display.h>
|
||||||
#include <psp2/types.h>
|
#include <psp2/gxm.h>
|
||||||
#include <psp2/kernel/modulemgr.h>
|
#include <psp2/kernel/modulemgr.h>
|
||||||
|
#include <psp2/types.h>
|
||||||
#include "utils.h"
|
#include <string>
|
||||||
#include "memory.h"
|
|
||||||
#define INCBIN_PREFIX _inc_
|
#define INCBIN_PREFIX _inc_
|
||||||
#include "incbin.h"
|
#include "incbin.h"
|
||||||
|
|
||||||
@ -25,8 +23,6 @@ bool with_razor = 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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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");
|
||||||
@ -63,7 +59,8 @@ extern "C" int sceRazorGpuCaptureSetTriggerNextFrame(const char* path);
|
|||||||
|
|
||||||
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)
|
||||||
|
{
|
||||||
const GXMDisplayData* display_data = (const GXMDisplayData*) callback_data;
|
const GXMDisplayData* display_data = (const GXMDisplayData*) callback_data;
|
||||||
|
|
||||||
SceDisplayFrameBuf framebuf;
|
SceDisplayFrameBuf framebuf;
|
||||||
@ -78,7 +75,8 @@ static void display_callback(const void *callback_data) {
|
|||||||
sceDisplayWaitSetFrameBuf();
|
sceDisplayWaitSetFrameBuf();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void load_razor() {
|
static void load_razor()
|
||||||
|
{
|
||||||
int mod_id = _sceKernelLoadModule("app0:librazorcapture_es4.suprx", 0, nullptr);
|
int mod_id = _sceKernelLoadModule("app0:librazorcapture_es4.suprx", 0, nullptr);
|
||||||
int status;
|
int status;
|
||||||
if (!SCE_ERR(sceKernelStartModule, mod_id, 0, nullptr, 0, nullptr, &status)) {
|
if (!SCE_ERR(sceKernelStartModule, mod_id, 0, nullptr, 0, nullptr, &status)) {
|
||||||
@ -91,7 +89,8 @@ static void load_razor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool gxm_initialized = false;
|
bool gxm_initialized = false;
|
||||||
bool gxm_init() {
|
bool gxm_init()
|
||||||
|
{
|
||||||
if (gxm_initialized) {
|
if (gxm_initialized) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -116,7 +115,8 @@ bool gxm_init() {
|
|||||||
return cdramPool_init();
|
return cdramPool_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool create_gxm_context() {
|
static bool create_gxm_context()
|
||||||
|
{
|
||||||
GXMRendererContext* data = &gxm_renderer_context;
|
GXMRendererContext* data = &gxm_renderer_context;
|
||||||
if (data->context) {
|
if (data->context) {
|
||||||
return true;
|
return true;
|
||||||
@ -164,7 +164,8 @@ static bool create_gxm_context() {
|
|||||||
data->fragmentUsseRingBuffer = vita_mem_fragment_usse_alloc(
|
data->fragmentUsseRingBuffer = vita_mem_fragment_usse_alloc(
|
||||||
SCE_GXM_DEFAULT_FRAGMENT_USSE_RING_BUFFER_SIZE,
|
SCE_GXM_DEFAULT_FRAGMENT_USSE_RING_BUFFER_SIZE,
|
||||||
&data->fragmentUsseRingBufferUid,
|
&data->fragmentUsseRingBufferUid,
|
||||||
&data->fragmentUsseRingBufferOffset);
|
&data->fragmentUsseRingBufferOffset
|
||||||
|
);
|
||||||
|
|
||||||
// create context
|
// create context
|
||||||
SceGxmContextParams contextParams;
|
SceGxmContextParams contextParams;
|
||||||
@ -195,15 +196,14 @@ static bool create_gxm_context() {
|
|||||||
&data->patcherBufferUid
|
&data->patcherBufferUid
|
||||||
);
|
);
|
||||||
|
|
||||||
data->patcherVertexUsse = vita_mem_vertex_usse_alloc(
|
data->patcherVertexUsse =
|
||||||
patcherVertexUsseSize,
|
vita_mem_vertex_usse_alloc(patcherVertexUsseSize, &data->patcherVertexUsseUid, &data->patcherVertexUsseOffset);
|
||||||
&data->patcherVertexUsseUid,
|
|
||||||
&data->patcherVertexUsseOffset);
|
|
||||||
|
|
||||||
data->patcherFragmentUsse = vita_mem_fragment_usse_alloc(
|
data->patcherFragmentUsse = vita_mem_fragment_usse_alloc(
|
||||||
patcherFragmentUsseSize,
|
patcherFragmentUsseSize,
|
||||||
&data->patcherFragmentUsseUid,
|
&data->patcherFragmentUsseUid,
|
||||||
&data->patcherFragmentUsseOffset);
|
&data->patcherFragmentUsseOffset
|
||||||
|
);
|
||||||
|
|
||||||
SceGxmShaderPatcherParams patcherParams;
|
SceGxmShaderPatcherParams patcherParams;
|
||||||
memset(&patcherParams, 0, sizeof(SceGxmShaderPatcherParams));
|
memset(&patcherParams, 0, sizeof(SceGxmShaderPatcherParams));
|
||||||
@ -231,7 +231,8 @@ static bool create_gxm_context() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroy_gxm_context() {
|
static void destroy_gxm_context()
|
||||||
|
{
|
||||||
sceGxmShaderPatcherDestroy(gxm_renderer_context.shaderPatcher);
|
sceGxmShaderPatcherDestroy(gxm_renderer_context.shaderPatcher);
|
||||||
sceGxmDestroyContext(gxm_renderer_context.context);
|
sceGxmDestroyContext(gxm_renderer_context.context);
|
||||||
vita_mem_fragment_usse_free(gxm_renderer_context.fragmentUsseRingBufferUid);
|
vita_mem_fragment_usse_free(gxm_renderer_context.fragmentUsseRingBufferUid);
|
||||||
@ -241,7 +242,8 @@ static void destroy_gxm_context() {
|
|||||||
SDL_free(gxm_renderer_context.contextHostMem);
|
SDL_free(gxm_renderer_context.contextHostMem);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get_gxm_context(SceGxmContext** context, SceGxmShaderPatcher** shaderPatcher, SceClibMspace* cdramPool) {
|
bool get_gxm_context(SceGxmContext** context, SceGxmShaderPatcher** shaderPatcher, SceClibMspace* cdramPool)
|
||||||
|
{
|
||||||
if (!create_gxm_context()) {
|
if (!create_gxm_context()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -292,7 +294,8 @@ Direct3DRMRenderer* GXMRenderer::Create(DWORD width, DWORD height)
|
|||||||
return new GXMRenderer(width, height);
|
return new GXMRenderer(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
GXMRenderer::GXMRenderer(DWORD width, DWORD height) {
|
GXMRenderer::GXMRenderer(DWORD width, DWORD height)
|
||||||
|
{
|
||||||
m_width = VITA_GXM_SCREEN_WIDTH;
|
m_width = VITA_GXM_SCREEN_WIDTH;
|
||||||
m_height = VITA_GXM_SCREEN_HEIGHT;
|
m_height = VITA_GXM_SCREEN_HEIGHT;
|
||||||
m_virtualWidth = width;
|
m_virtualWidth = width;
|
||||||
@ -303,7 +306,9 @@ GXMRenderer::GXMRenderer(DWORD width, DWORD height) {
|
|||||||
const unsigned int sampleCount = alignedWidth * alignedHeight;
|
const unsigned int sampleCount = alignedWidth * alignedHeight;
|
||||||
const unsigned int depthStrideInSamples = alignedWidth;
|
const unsigned int depthStrideInSamples = alignedWidth;
|
||||||
|
|
||||||
if(!get_gxm_context(&this->context, &this->shaderPatcher, &this->cdramPool)) return;
|
if (!get_gxm_context(&this->context, &this->shaderPatcher, &this->cdramPool)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// render target
|
// render target
|
||||||
SceGxmRenderTargetParams renderTargetParams;
|
SceGxmRenderTargetParams renderTargetParams;
|
||||||
@ -315,7 +320,9 @@ GXMRenderer::GXMRenderer(DWORD width, DWORD height) {
|
|||||||
renderTargetParams.multisampleMode = 0;
|
renderTargetParams.multisampleMode = 0;
|
||||||
renderTargetParams.multisampleLocations = 0;
|
renderTargetParams.multisampleLocations = 0;
|
||||||
renderTargetParams.driverMemBlock = -1; // Invalid UID
|
renderTargetParams.driverMemBlock = -1; // Invalid UID
|
||||||
if(SCE_ERR(sceGxmCreateRenderTarget, &renderTargetParams, &this->renderTarget)) return;
|
if (SCE_ERR(sceGxmCreateRenderTarget, &renderTargetParams, &this->renderTarget)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < VITA_GXM_DISPLAY_BUFFER_COUNT; i++) {
|
for (int i = 0; i < VITA_GXM_DISPLAY_BUFFER_COUNT; i++) {
|
||||||
this->displayBuffers[i] = vita_mem_alloc(
|
this->displayBuffers[i] = vita_mem_alloc(
|
||||||
@ -326,20 +333,25 @@ GXMRenderer::GXMRenderer(DWORD width, DWORD height) {
|
|||||||
&this->displayBuffersUid[i]
|
&this->displayBuffersUid[i]
|
||||||
);
|
);
|
||||||
|
|
||||||
if(SCE_ERR(sceGxmColorSurfaceInit,
|
if (SCE_ERR(
|
||||||
|
sceGxmColorSurfaceInit,
|
||||||
&this->displayBuffersSurface[i],
|
&this->displayBuffersSurface[i],
|
||||||
SCE_GXM_COLOR_FORMAT_A8B8G8R8,
|
SCE_GXM_COLOR_FORMAT_A8B8G8R8,
|
||||||
SCE_GXM_COLOR_SURFACE_LINEAR,
|
SCE_GXM_COLOR_SURFACE_LINEAR,
|
||||||
SCE_GXM_COLOR_SURFACE_SCALE_NONE,
|
SCE_GXM_COLOR_SURFACE_SCALE_NONE,
|
||||||
SCE_GXM_OUTPUT_REGISTER_SIZE_32BIT,
|
SCE_GXM_OUTPUT_REGISTER_SIZE_32BIT,
|
||||||
m_width, m_height,
|
m_width,
|
||||||
|
m_height,
|
||||||
m_width,
|
m_width,
|
||||||
this->displayBuffers[i]
|
this->displayBuffers[i]
|
||||||
)) return;
|
)) {
|
||||||
|
return;
|
||||||
if(SCE_ERR(sceGxmSyncObjectCreate, &this->displayBuffersSync[i])) return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SCE_ERR(sceGxmSyncObjectCreate, &this->displayBuffersSync[i])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// depth & stencil
|
// depth & stencil
|
||||||
this->depthBufferData = vita_mem_alloc(
|
this->depthBufferData = vita_mem_alloc(
|
||||||
@ -358,21 +370,51 @@ GXMRenderer::GXMRenderer(DWORD width, DWORD height) {
|
|||||||
&this->stencilBufferUid
|
&this->stencilBufferUid
|
||||||
);
|
);
|
||||||
|
|
||||||
if(SCE_ERR(sceGxmDepthStencilSurfaceInit,
|
if (SCE_ERR(
|
||||||
|
sceGxmDepthStencilSurfaceInit,
|
||||||
&this->depthSurface,
|
&this->depthSurface,
|
||||||
SCE_GXM_DEPTH_STENCIL_FORMAT_S8D24,
|
SCE_GXM_DEPTH_STENCIL_FORMAT_S8D24,
|
||||||
SCE_GXM_DEPTH_STENCIL_SURFACE_TILED,
|
SCE_GXM_DEPTH_STENCIL_SURFACE_TILED,
|
||||||
depthStrideInSamples,
|
depthStrideInSamples,
|
||||||
this->depthBufferData,
|
this->depthBufferData,
|
||||||
this->stencilBufferData
|
this->stencilBufferData
|
||||||
)) return;
|
)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// register shader programs
|
// register shader programs
|
||||||
if(SCE_ERR(sceGxmShaderPatcherRegisterProgram, this->shaderPatcher, colorFragmentProgramGxp, &this->colorFragmentProgramId)) return;
|
if (SCE_ERR(
|
||||||
if(SCE_ERR(sceGxmShaderPatcherRegisterProgram, this->shaderPatcher, mainVertexProgramGxp, &this->mainVertexProgramId)) return;
|
sceGxmShaderPatcherRegisterProgram,
|
||||||
if(SCE_ERR(sceGxmShaderPatcherRegisterProgram, this->shaderPatcher, mainFragmentProgramGxp, &this->mainFragmentProgramId)) return;
|
this->shaderPatcher,
|
||||||
if(SCE_ERR(sceGxmShaderPatcherRegisterProgram, this->shaderPatcher, imageFragmentProgramGxp, &this->imageFragmentProgramId)) return;
|
colorFragmentProgramGxp,
|
||||||
|
&this->colorFragmentProgramId
|
||||||
|
)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (SCE_ERR(
|
||||||
|
sceGxmShaderPatcherRegisterProgram,
|
||||||
|
this->shaderPatcher,
|
||||||
|
mainVertexProgramGxp,
|
||||||
|
&this->mainVertexProgramId
|
||||||
|
)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (SCE_ERR(
|
||||||
|
sceGxmShaderPatcherRegisterProgram,
|
||||||
|
this->shaderPatcher,
|
||||||
|
mainFragmentProgramGxp,
|
||||||
|
&this->mainFragmentProgramId
|
||||||
|
)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (SCE_ERR(
|
||||||
|
sceGxmShaderPatcherRegisterProgram,
|
||||||
|
this->shaderPatcher,
|
||||||
|
imageFragmentProgramGxp,
|
||||||
|
&this->imageFragmentProgramId
|
||||||
|
)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// main shader
|
// main shader
|
||||||
{
|
{
|
||||||
@ -406,17 +448,23 @@ GXMRenderer::GXMRenderer(DWORD width, DWORD height) {
|
|||||||
vertexStreams[0].stride = sizeof(Vertex);
|
vertexStreams[0].stride = sizeof(Vertex);
|
||||||
vertexStreams[0].indexSource = SCE_GXM_INDEX_SOURCE_INDEX_16BIT;
|
vertexStreams[0].indexSource = SCE_GXM_INDEX_SOURCE_INDEX_16BIT;
|
||||||
|
|
||||||
if(SCE_ERR(sceGxmShaderPatcherCreateVertexProgram,
|
if (SCE_ERR(
|
||||||
|
sceGxmShaderPatcherCreateVertexProgram,
|
||||||
this->shaderPatcher,
|
this->shaderPatcher,
|
||||||
this->mainVertexProgramId,
|
this->mainVertexProgramId,
|
||||||
vertexAttributes, 3,
|
vertexAttributes,
|
||||||
vertexStreams, 1,
|
3,
|
||||||
|
vertexStreams,
|
||||||
|
1,
|
||||||
&this->mainVertexProgram
|
&this->mainVertexProgram
|
||||||
)) return;
|
)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// main opaque
|
// main opaque
|
||||||
if(SCE_ERR(sceGxmShaderPatcherCreateFragmentProgram,
|
if (SCE_ERR(
|
||||||
|
sceGxmShaderPatcherCreateFragmentProgram,
|
||||||
this->shaderPatcher,
|
this->shaderPatcher,
|
||||||
this->mainFragmentProgramId,
|
this->mainFragmentProgramId,
|
||||||
SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4,
|
SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4,
|
||||||
@ -424,10 +472,13 @@ GXMRenderer::GXMRenderer(DWORD width, DWORD height) {
|
|||||||
&blendInfoOpaque,
|
&blendInfoOpaque,
|
||||||
mainVertexProgramGxp,
|
mainVertexProgramGxp,
|
||||||
&this->opaqueFragmentProgram
|
&this->opaqueFragmentProgram
|
||||||
)) return;
|
)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// main transparent
|
// main transparent
|
||||||
if(SCE_ERR(sceGxmShaderPatcherCreateFragmentProgram,
|
if (SCE_ERR(
|
||||||
|
sceGxmShaderPatcherCreateFragmentProgram,
|
||||||
this->shaderPatcher,
|
this->shaderPatcher,
|
||||||
this->mainFragmentProgramId,
|
this->mainFragmentProgramId,
|
||||||
SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4,
|
SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4,
|
||||||
@ -435,10 +486,13 @@ GXMRenderer::GXMRenderer(DWORD width, DWORD height) {
|
|||||||
&blendInfoTransparent,
|
&blendInfoTransparent,
|
||||||
mainVertexProgramGxp,
|
mainVertexProgramGxp,
|
||||||
&this->transparentFragmentProgram
|
&this->transparentFragmentProgram
|
||||||
)) return;
|
)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// image
|
// image
|
||||||
if(SCE_ERR(sceGxmShaderPatcherCreateFragmentProgram,
|
if (SCE_ERR(
|
||||||
|
sceGxmShaderPatcherCreateFragmentProgram,
|
||||||
this->shaderPatcher,
|
this->shaderPatcher,
|
||||||
this->imageFragmentProgramId,
|
this->imageFragmentProgramId,
|
||||||
SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4,
|
SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4,
|
||||||
@ -446,10 +500,13 @@ GXMRenderer::GXMRenderer(DWORD width, DWORD height) {
|
|||||||
&blendInfoTransparent,
|
&blendInfoTransparent,
|
||||||
mainVertexProgramGxp,
|
mainVertexProgramGxp,
|
||||||
&this->imageFragmentProgram
|
&this->imageFragmentProgram
|
||||||
)) return;
|
)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// color
|
// color
|
||||||
if(SCE_ERR(sceGxmShaderPatcherCreateFragmentProgram,
|
if (SCE_ERR(
|
||||||
|
sceGxmShaderPatcherCreateFragmentProgram,
|
||||||
this->shaderPatcher,
|
this->shaderPatcher,
|
||||||
this->colorFragmentProgramId,
|
this->colorFragmentProgramId,
|
||||||
SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4,
|
SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4,
|
||||||
@ -457,7 +514,9 @@ GXMRenderer::GXMRenderer(DWORD width, DWORD height) {
|
|||||||
NULL,
|
NULL,
|
||||||
mainVertexProgramGxp,
|
mainVertexProgramGxp,
|
||||||
&this->colorFragmentProgram
|
&this->colorFragmentProgram
|
||||||
)) return;
|
)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// vertex uniforms
|
// vertex uniforms
|
||||||
this->uModelViewMatrix = sceGxmProgramFindParameterByName(mainVertexProgramGxp, "uModelViewMatrix");
|
this->uModelViewMatrix = sceGxmProgramFindParameterByName(mainVertexProgramGxp, "uModelViewMatrix");
|
||||||
@ -495,7 +554,8 @@ GXMRenderer::GXMRenderer(DWORD width, DWORD height) {
|
|||||||
m_initialized = true;
|
m_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
GXMRenderer::~GXMRenderer() {
|
GXMRenderer::~GXMRenderer()
|
||||||
|
{
|
||||||
if (!m_initialized) {
|
if (!m_initialized) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -547,7 +607,15 @@ void GXMRenderer::AddTextureDestroyCallback(Uint32 id, IDirect3DRMTexture* textu
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void convertTextureMetadata(SDL_Surface* surface, bool* supportedFormat, SceGxmTextureFormat* textureFormat, size_t* textureSize, size_t* textureAlignment, size_t* textureStride) {
|
static void convertTextureMetadata(
|
||||||
|
SDL_Surface* surface,
|
||||||
|
bool* supportedFormat,
|
||||||
|
SceGxmTextureFormat* textureFormat,
|
||||||
|
size_t* textureSize,
|
||||||
|
size_t* textureAlignment,
|
||||||
|
size_t* textureStride
|
||||||
|
)
|
||||||
|
{
|
||||||
*supportedFormat = true;
|
*supportedFormat = true;
|
||||||
*textureAlignment = SCE_GXM_TEXTURE_ALIGNMENT;
|
*textureAlignment = SCE_GXM_TEXTURE_ALIGNMENT;
|
||||||
switch (surface->format) {
|
switch (surface->format) {
|
||||||
@ -574,7 +642,8 @@ static void convertTextureMetadata(SDL_Surface* surface, bool* supportedFormat,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void copySurfaceTo(SDL_Surface* src, void* dstData, size_t textureStride) {
|
void copySurfaceTo(SDL_Surface* src, void* dstData, size_t textureStride)
|
||||||
|
{
|
||||||
SDL_Surface* dst = SDL_CreateSurfaceFrom(src->w, src->h, SDL_PIXELFORMAT_ABGR8888, dstData, textureStride);
|
SDL_Surface* dst = SDL_CreateSurfaceFrom(src->w, src->h, SDL_PIXELFORMAT_ABGR8888, dstData, textureStride);
|
||||||
SDL_BlitSurface(src, nullptr, dst, nullptr);
|
SDL_BlitSurface(src, nullptr, dst, nullptr);
|
||||||
SDL_DestroySurface(dst);
|
SDL_DestroySurface(dst);
|
||||||
@ -585,7 +654,6 @@ Uint32 GXMRenderer::GetTextureId(IDirect3DRMTexture* iTexture)
|
|||||||
auto texture = static_cast<Direct3DRMTextureImpl*>(iTexture);
|
auto texture = static_cast<Direct3DRMTextureImpl*>(iTexture);
|
||||||
auto surface = static_cast<DirectDrawSurfaceImpl*>(texture->m_surface);
|
auto surface = static_cast<DirectDrawSurfaceImpl*>(texture->m_surface);
|
||||||
|
|
||||||
|
|
||||||
bool supportedFormat;
|
bool supportedFormat;
|
||||||
size_t textureSize;
|
size_t textureSize;
|
||||||
size_t textureAlignment;
|
size_t textureAlignment;
|
||||||
@ -594,7 +662,14 @@ Uint32 GXMRenderer::GetTextureId(IDirect3DRMTexture* iTexture)
|
|||||||
int textureWidth = surface->m_surface->w;
|
int textureWidth = surface->m_surface->w;
|
||||||
int textureHeight = surface->m_surface->h;
|
int textureHeight = surface->m_surface->h;
|
||||||
|
|
||||||
convertTextureMetadata(surface->m_surface, &supportedFormat, &textureFormat, &textureSize, &textureAlignment, &textureStride);
|
convertTextureMetadata(
|
||||||
|
surface->m_surface,
|
||||||
|
&supportedFormat,
|
||||||
|
&textureFormat,
|
||||||
|
&textureSize,
|
||||||
|
&textureAlignment,
|
||||||
|
&textureStride
|
||||||
|
);
|
||||||
|
|
||||||
if (!supportedFormat) {
|
if (!supportedFormat) {
|
||||||
textureAlignment = SCE_GXM_TEXTURE_ALIGNMENT;
|
textureAlignment = SCE_GXM_TEXTURE_ALIGNMENT;
|
||||||
@ -610,7 +685,8 @@ Uint32 GXMRenderer::GetTextureId(IDirect3DRMTexture* iTexture)
|
|||||||
void* textureData = sceGxmTextureGetData(&tex.gxmTexture);
|
void* textureData = sceGxmTextureGetData(&tex.gxmTexture);
|
||||||
if (!supportedFormat) {
|
if (!supportedFormat) {
|
||||||
copySurfaceTo(surface->m_surface, textureData, textureStride);
|
copySurfaceTo(surface->m_surface, textureData, textureStride);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
memcpy(textureData, surface->m_surface->pixels, textureSize);
|
memcpy(textureData, surface->m_surface->pixels, textureSize);
|
||||||
}
|
}
|
||||||
tex.version = texture->m_version;
|
tex.version = texture->m_version;
|
||||||
@ -619,19 +695,26 @@ Uint32 GXMRenderer::GetTextureId(IDirect3DRMTexture* iTexture)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Log("Create Texture %s w=%d h=%d s=%d",
|
SDL_Log(
|
||||||
SDL_GetPixelFormatName(surface->m_surface->format), textureWidth, textureHeight, textureStride);
|
"Create Texture %s w=%d h=%d s=%d",
|
||||||
|
SDL_GetPixelFormatName(surface->m_surface->format),
|
||||||
|
textureWidth,
|
||||||
|
textureHeight,
|
||||||
|
textureStride
|
||||||
|
);
|
||||||
|
|
||||||
// allocate gpu memory
|
// allocate gpu memory
|
||||||
void* textureData = sceClibMspaceMemalign(this->cdramPool, textureAlignment, textureSize);
|
void* textureData = sceClibMspaceMemalign(this->cdramPool, textureAlignment, textureSize);
|
||||||
uint8_t* paletteData = nullptr;
|
uint8_t* paletteData = nullptr;
|
||||||
|
|
||||||
if (!supportedFormat) {
|
if (!supportedFormat) {
|
||||||
SDL_Log("unsupported SDL texture format %s, falling back on SDL_PIXELFORMAT_ABGR8888", SDL_GetPixelFormatName(surface->m_surface->format));
|
SDL_Log(
|
||||||
|
"unsupported SDL texture format %s, falling back on SDL_PIXELFORMAT_ABGR8888",
|
||||||
|
SDL_GetPixelFormatName(surface->m_surface->format)
|
||||||
|
);
|
||||||
copySurfaceTo(surface->m_surface, textureData, textureStride);
|
copySurfaceTo(surface->m_surface, textureData, textureStride);
|
||||||
}
|
}
|
||||||
else if(surface->m_surface->format == SDL_PIXELFORMAT_INDEX8)
|
else if (surface->m_surface->format == SDL_PIXELFORMAT_INDEX8) {
|
||||||
{
|
|
||||||
LPDIRECTDRAWPALETTE _palette;
|
LPDIRECTDRAWPALETTE _palette;
|
||||||
surface->GetPalette(&_palette);
|
surface->GetPalette(&_palette);
|
||||||
auto palette = static_cast<DirectDrawPaletteImpl*>(_palette);
|
auto palette = static_cast<DirectDrawPaletteImpl*>(_palette);
|
||||||
@ -644,14 +727,21 @@ Uint32 GXMRenderer::GetTextureId(IDirect3DRMTexture* iTexture)
|
|||||||
paletteData = (uint8_t*) textureData + pixelsSize + alignBytes;
|
paletteData = (uint8_t*) textureData + pixelsSize + alignBytes;
|
||||||
memcpy(paletteData, palette->m_palette->colors, palette->m_palette->ncolors * sizeof(SDL_Color));
|
memcpy(paletteData, palette->m_palette->colors, palette->m_palette->ncolors * sizeof(SDL_Color));
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
SDL_Log("copying texture data from=%p to=%p", surface->m_surface->pixels, textureData);
|
SDL_Log("copying texture data from=%p to=%p", surface->m_surface->pixels, textureData);
|
||||||
memcpy(textureData, surface->m_surface->pixels, textureSize);
|
memcpy(textureData, surface->m_surface->pixels, textureSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceGxmTexture gxmTexture;
|
SceGxmTexture gxmTexture;
|
||||||
SCE_ERR(sceGxmTextureInitLinearStrided, &gxmTexture, textureData, textureFormat, textureWidth, textureHeight, textureStride);
|
SCE_ERR(
|
||||||
|
sceGxmTextureInitLinearStrided,
|
||||||
|
&gxmTexture,
|
||||||
|
textureData,
|
||||||
|
textureFormat,
|
||||||
|
textureWidth,
|
||||||
|
textureHeight,
|
||||||
|
textureStride
|
||||||
|
);
|
||||||
// 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);
|
||||||
if (paletteData) {
|
if (paletteData) {
|
||||||
@ -713,17 +803,20 @@ GXMMeshCacheEntry GXMRenderer::GXMUploadMesh(const MeshGroup& meshGroup)
|
|||||||
for (int i = 0; i < vertices.size(); i++) {
|
for (int i = 0; i < vertices.size(); i++) {
|
||||||
D3DRMVERTEX vertex = vertices.data()[i];
|
D3DRMVERTEX vertex = vertices.data()[i];
|
||||||
vertexBuffer[i] = Vertex{
|
vertexBuffer[i] = Vertex{
|
||||||
.position = {
|
.position =
|
||||||
|
{
|
||||||
vertex.position.x,
|
vertex.position.x,
|
||||||
vertex.position.y,
|
vertex.position.y,
|
||||||
vertex.position.z,
|
vertex.position.z,
|
||||||
},
|
},
|
||||||
.normal = {
|
.normal =
|
||||||
|
{
|
||||||
vertex.normal.x,
|
vertex.normal.x,
|
||||||
vertex.normal.y,
|
vertex.normal.y,
|
||||||
vertex.normal.z,
|
vertex.normal.z,
|
||||||
},
|
},
|
||||||
.texCoord = {
|
.texCoord =
|
||||||
|
{
|
||||||
vertex.tu,
|
vertex.tu,
|
||||||
vertex.tv,
|
vertex.tv,
|
||||||
}
|
}
|
||||||
@ -801,15 +894,18 @@ void GXMRenderer::GetDesc(D3DDEVICEDESC* halDesc, D3DDEVICEDESC* helDesc)
|
|||||||
memset(helDesc, 0, sizeof(D3DDEVICEDESC));
|
memset(helDesc, 0, sizeof(D3DDEVICEDESC));
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* GXMRenderer::GetName() {
|
const char* GXMRenderer::GetName()
|
||||||
|
{
|
||||||
return "GXM";
|
return "GXM";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool razor_triggered = false;
|
bool razor_triggered = false;
|
||||||
|
|
||||||
void GXMRenderer::StartScene() {
|
void GXMRenderer::StartScene()
|
||||||
if(sceneStarted) return;
|
{
|
||||||
|
if (sceneStarted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
sceGxmBeginScene(
|
sceGxmBeginScene(
|
||||||
this->context,
|
this->context,
|
||||||
0,
|
0,
|
||||||
@ -827,7 +923,8 @@ void GXMRenderer::StartScene() {
|
|||||||
this->activeUniformBuffer = (this->activeUniformBuffer + 1) % VITA_GXM_UNIFORM_BUFFER_COUNT;
|
this->activeUniformBuffer = (this->activeUniformBuffer + 1) % VITA_GXM_UNIFORM_BUFFER_COUNT;
|
||||||
sceGxmNotificationWait(&this->fragmentNotifications[this->activeUniformBuffer]);
|
sceGxmNotificationWait(&this->fragmentNotifications[this->activeUniformBuffer]);
|
||||||
|
|
||||||
//sceClibPrintf("this->activeUniformBuffer: %d notification: %d\n", this->activeUniformBuffer, this->fragmentNotifications[this->activeUniformBuffer].value);
|
// sceClibPrintf("this->activeUniformBuffer: %d notification: %d\n", this->activeUniformBuffer,
|
||||||
|
// this->fragmentNotifications[this->activeUniformBuffer].value);
|
||||||
}
|
}
|
||||||
|
|
||||||
int frames = 0;
|
int frames = 0;
|
||||||
@ -869,15 +966,19 @@ HRESULT GXMRenderer::BeginFrame()
|
|||||||
return DD_OK;
|
return DD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GXMRenderer::EnableTransparency() {
|
void GXMRenderer::EnableTransparency()
|
||||||
|
{
|
||||||
this->transparencyEnabled = true;
|
this->transparencyEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void transpose4x4(const float src[4][4], float dst[4][4]) {
|
static void transpose4x4(const float src[4][4], float dst[4][4])
|
||||||
for (int i = 0; i < 4; ++i)
|
{
|
||||||
for (int j = 0; j < 4; ++j)
|
for (int i = 0; i < 4; ++i) {
|
||||||
|
for (int j = 0; j < 4; ++j) {
|
||||||
dst[j][i] = src[i][j];
|
dst[j][i] = src[i][j];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static const D3DRMMATRIX4D identity4x4 = {
|
static const D3DRMMATRIX4D identity4x4 = {
|
||||||
{1.0, 0.0, 0.0, 0.0},
|
{1.0, 0.0, 0.0, 0.0},
|
||||||
@ -892,7 +993,6 @@ static const Matrix3x3 identity3x3 = {
|
|||||||
{0.0, 0.0, 1.0},
|
{0.0, 0.0, 1.0},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void GXMRenderer::SubmitDraw(
|
void GXMRenderer::SubmitDraw(
|
||||||
DWORD meshId,
|
DWORD meshId,
|
||||||
const D3DRMMATRIX4D& modelViewMatrix,
|
const D3DRMMATRIX4D& modelViewMatrix,
|
||||||
@ -900,7 +1000,8 @@ void GXMRenderer::SubmitDraw(
|
|||||||
const D3DRMMATRIX4D& viewMatrix,
|
const D3DRMMATRIX4D& viewMatrix,
|
||||||
const Matrix3x3& normalMatrix,
|
const Matrix3x3& normalMatrix,
|
||||||
const Appearance& appearance
|
const Appearance& appearance
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
auto& mesh = m_meshes[meshId];
|
auto& mesh = m_meshes[meshId];
|
||||||
|
|
||||||
char marker[256];
|
char marker[256];
|
||||||
@ -910,7 +1011,8 @@ void GXMRenderer::SubmitDraw(
|
|||||||
sceGxmSetVertexProgram(this->context, this->mainVertexProgram);
|
sceGxmSetVertexProgram(this->context, this->mainVertexProgram);
|
||||||
if (this->transparencyEnabled) {
|
if (this->transparencyEnabled) {
|
||||||
sceGxmSetFragmentProgram(this->context, this->transparentFragmentProgram);
|
sceGxmSetFragmentProgram(this->context, this->transparentFragmentProgram);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
sceGxmSetFragmentProgram(this->context, this->opaqueFragmentProgram);
|
sceGxmSetFragmentProgram(this->context, this->opaqueFragmentProgram);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -940,29 +1042,26 @@ void GXMRenderer::SubmitDraw(
|
|||||||
}
|
}
|
||||||
|
|
||||||
sceGxmSetVertexStream(this->context, 0, mesh.vertexBuffer);
|
sceGxmSetVertexStream(this->context, 0, mesh.vertexBuffer);
|
||||||
sceGxmDraw(
|
sceGxmDraw(this->context, SCE_GXM_PRIMITIVE_TRIANGLES, SCE_GXM_INDEX_FORMAT_U16, mesh.indexBuffer, mesh.indexCount);
|
||||||
this->context,
|
|
||||||
SCE_GXM_PRIMITIVE_TRIANGLES,
|
|
||||||
SCE_GXM_INDEX_FORMAT_U16,
|
|
||||||
mesh.indexBuffer,
|
|
||||||
mesh.indexCount
|
|
||||||
);
|
|
||||||
|
|
||||||
sceGxmPopUserMarker(this->context);
|
sceGxmPopUserMarker(this->context);
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT GXMRenderer::FinalizeFrame() {
|
HRESULT GXMRenderer::FinalizeFrame()
|
||||||
|
{
|
||||||
return DD_OK;
|
return DD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GXMRenderer::Resize(int width, int height, const ViewportTransform& viewportTransform) {
|
void GXMRenderer::Resize(int width, int height, const ViewportTransform& viewportTransform)
|
||||||
|
{
|
||||||
m_width = width;
|
m_width = width;
|
||||||
m_height = height;
|
m_height = height;
|
||||||
m_viewportTransform = viewportTransform;
|
m_viewportTransform = viewportTransform;
|
||||||
SDL_Log("GXMRenderer::Resize TODO");
|
SDL_Log("GXMRenderer::Resize TODO");
|
||||||
}
|
}
|
||||||
|
|
||||||
void GXMRenderer::Clear(float r, float g, float b) {
|
void GXMRenderer::Clear(float r, float g, float b)
|
||||||
|
{
|
||||||
this->StartScene();
|
this->StartScene();
|
||||||
|
|
||||||
char marker[256];
|
char marker[256];
|
||||||
@ -1001,17 +1100,13 @@ void GXMRenderer::Clear(float r, float g, float b) {
|
|||||||
quadVertices[3] = Vertex{.position = {x2, y2, -1.0}, .normal = {0, 0, 0}, .texCoord = {0, 0}};
|
quadVertices[3] = Vertex{.position = {x2, y2, -1.0}, .normal = {0, 0, 0}, .texCoord = {0, 0}};
|
||||||
|
|
||||||
sceGxmSetVertexStream(this->context, 0, quadVertices);
|
sceGxmSetVertexStream(this->context, 0, quadVertices);
|
||||||
sceGxmDraw(
|
sceGxmDraw(this->context, SCE_GXM_PRIMITIVE_TRIANGLE_STRIP, SCE_GXM_INDEX_FORMAT_U16, this->quadIndices, 4);
|
||||||
this->context,
|
|
||||||
SCE_GXM_PRIMITIVE_TRIANGLE_STRIP,
|
|
||||||
SCE_GXM_INDEX_FORMAT_U16,
|
|
||||||
this->quadIndices, 4
|
|
||||||
);
|
|
||||||
|
|
||||||
sceGxmPopUserMarker(this->context);
|
sceGxmPopUserMarker(this->context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GXMRenderer::Flip() {
|
void GXMRenderer::Flip()
|
||||||
|
{
|
||||||
if (!this->sceneStarted) {
|
if (!this->sceneStarted) {
|
||||||
this->Clear(0, 0, 0);
|
this->Clear(0, 0, 0);
|
||||||
}
|
}
|
||||||
@ -1023,7 +1118,8 @@ void GXMRenderer::Flip() {
|
|||||||
this->context,
|
this->context,
|
||||||
nullptr, //&this->vertexNotifications[this->activeUniformBuffer],
|
nullptr, //&this->vertexNotifications[this->activeUniformBuffer],
|
||||||
// nullptr
|
// nullptr
|
||||||
&this->fragmentNotifications[this->activeUniformBuffer] // wait for fragment processing to finish for this buffer, otherwise lighting corrupts
|
&this->fragmentNotifications[this->activeUniformBuffer] // wait for fragment processing to finish for this
|
||||||
|
// buffer, otherwise lighting corrupts
|
||||||
);
|
);
|
||||||
sceGxmPadHeartbeat(
|
sceGxmPadHeartbeat(
|
||||||
&this->displayBuffersSurface[this->backBufferIndex],
|
&this->displayBuffersSurface[this->backBufferIndex],
|
||||||
@ -1045,7 +1141,8 @@ void GXMRenderer::Flip() {
|
|||||||
this->backBufferIndex = (this->backBufferIndex + 1) % VITA_GXM_DISPLAY_BUFFER_COUNT;
|
this->backBufferIndex = (this->backBufferIndex + 1) % VITA_GXM_DISPLAY_BUFFER_COUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GXMRenderer::Draw2DImage(Uint32 textureId, const SDL_Rect& srcRect, const SDL_Rect& dstRect) {
|
void GXMRenderer::Draw2DImage(Uint32 textureId, const SDL_Rect& srcRect, const SDL_Rect& dstRect)
|
||||||
|
{
|
||||||
this->StartScene();
|
this->StartScene();
|
||||||
|
|
||||||
char marker[256];
|
char marker[256];
|
||||||
@ -1113,17 +1210,13 @@ void GXMRenderer::Draw2DImage(Uint32 textureId, const SDL_Rect& srcRect, const S
|
|||||||
sceGxmSetVertexStream(this->context, 0, quadVertices);
|
sceGxmSetVertexStream(this->context, 0, quadVertices);
|
||||||
|
|
||||||
sceGxmSetFrontDepthWriteEnable(this->context, SCE_GXM_DEPTH_WRITE_DISABLED);
|
sceGxmSetFrontDepthWriteEnable(this->context, SCE_GXM_DEPTH_WRITE_DISABLED);
|
||||||
sceGxmDraw(
|
sceGxmDraw(this->context, SCE_GXM_PRIMITIVE_TRIANGLE_STRIP, SCE_GXM_INDEX_FORMAT_U16, this->quadIndices, 4);
|
||||||
this->context,
|
|
||||||
SCE_GXM_PRIMITIVE_TRIANGLE_STRIP,
|
|
||||||
SCE_GXM_INDEX_FORMAT_U16,
|
|
||||||
this->quadIndices, 4
|
|
||||||
);
|
|
||||||
sceGxmSetFrontDepthWriteEnable(this->context, SCE_GXM_DEPTH_WRITE_ENABLED);
|
sceGxmSetFrontDepthWriteEnable(this->context, SCE_GXM_DEPTH_WRITE_ENABLED);
|
||||||
sceGxmPopUserMarker(this->context);
|
sceGxmPopUserMarker(this->context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GXMRenderer::Download(SDL_Surface* target) {
|
void GXMRenderer::Download(SDL_Surface* target)
|
||||||
|
{
|
||||||
SDL_Rect srcRect = {
|
SDL_Rect srcRect = {
|
||||||
static_cast<int>(m_viewportTransform.offsetX),
|
static_cast<int>(m_viewportTransform.offsetX),
|
||||||
static_cast<int>(m_viewportTransform.offsetY),
|
static_cast<int>(m_viewportTransform.offsetY),
|
||||||
@ -1131,9 +1224,11 @@ void GXMRenderer::Download(SDL_Surface* target) {
|
|||||||
static_cast<int>(target->h * m_viewportTransform.scale),
|
static_cast<int>(target->h * m_viewportTransform.scale),
|
||||||
};
|
};
|
||||||
SDL_Surface* src = SDL_CreateSurfaceFrom(
|
SDL_Surface* src = SDL_CreateSurfaceFrom(
|
||||||
this->m_width, this->m_height,
|
this->m_width,
|
||||||
|
this->m_height,
|
||||||
SDL_PIXELFORMAT_RGBA32,
|
SDL_PIXELFORMAT_RGBA32,
|
||||||
this->displayBuffers[this->frontBufferIndex], VITA_GXM_SCREEN_STRIDE
|
this->displayBuffers[this->frontBufferIndex],
|
||||||
|
VITA_GXM_SCREEN_STRIDE
|
||||||
);
|
);
|
||||||
SDL_BlitSurfaceScaled(src, &srcRect, target, nullptr, SDL_SCALEMODE_NEAREST);
|
SDL_BlitSurfaceScaled(src, &srcRect, target, nullptr, SDL_SCALEMODE_NEAREST);
|
||||||
SDL_DestroySurface(src);
|
SDL_DestroySurface(src);
|
||||||
|
|||||||
@ -4,7 +4,8 @@
|
|||||||
#include <psp2/gxm.h>
|
#include <psp2/gxm.h>
|
||||||
#include <psp2/kernel/clib.h>
|
#include <psp2/kernel/clib.h>
|
||||||
|
|
||||||
#define SCE_ERR(func, ...) ({ \
|
#define SCE_ERR(func, ...) \
|
||||||
|
({ \
|
||||||
sceClibPrintf(#func "\n"); \
|
sceClibPrintf(#func "\n"); \
|
||||||
int __sce_err_ret_val = func(__VA_ARGS__); \
|
int __sce_err_ret_val = func(__VA_ARGS__); \
|
||||||
if (__sce_err_ret_val < 0) { \
|
if (__sce_err_ret_val < 0) { \
|
||||||
@ -17,7 +18,6 @@
|
|||||||
|
|
||||||
#define ALIGNMENT(n, a) (((a) - ((n) % (a))) % (a))
|
#define ALIGNMENT(n, a) (((a) - ((n) % (a))) % (a))
|
||||||
|
|
||||||
|
|
||||||
#define SET_UNIFORM(buffer, param, value) \
|
#define SET_UNIFORM(buffer, param, value) \
|
||||||
do { \
|
do { \
|
||||||
size_t __offset = sceGxmProgramParameterGetResourceIndex(param); \
|
size_t __offset = sceGxmProgramParameterGetResourceIndex(param); \
|
||||||
@ -32,7 +32,8 @@
|
|||||||
return ret; \
|
return ret; \
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printMatrix4x4(const float mat[4][4]) {
|
static void printMatrix4x4(const float mat[4][4])
|
||||||
|
{
|
||||||
sceClibPrintf("mat4{\n");
|
sceClibPrintf("mat4{\n");
|
||||||
for (int i = 0; i < 4; i++) {
|
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("%f %f %f %f\n", mat[i][0], mat[i][1], mat[i][2], mat[i][3]);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user