|
|
|
@ -1,6 +1,6 @@
|
|
|
|
#include "d3drmrenderer_gxm.h"
|
|
|
|
#include "d3drmrenderer_gxm.h"
|
|
|
|
#include "gxm_memory.h"
|
|
|
|
|
|
|
|
#include "gxm_context.h"
|
|
|
|
#include "gxm_context.h"
|
|
|
|
|
|
|
|
#include "gxm_memory.h"
|
|
|
|
#include "meshutils.h"
|
|
|
|
#include "meshutils.h"
|
|
|
|
#include "razor.h"
|
|
|
|
#include "razor.h"
|
|
|
|
#include "tlsf.h"
|
|
|
|
#include "tlsf.h"
|
|
|
|
@ -8,12 +8,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
#include <SDL3/SDL.h>
|
|
|
|
#include <SDL3/SDL.h>
|
|
|
|
#include <algorithm>
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
#include <psp2/common_dialog.h>
|
|
|
|
#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/kernel/sysmem.h>
|
|
|
|
#include <psp2/types.h>
|
|
|
|
#include <psp2/types.h>
|
|
|
|
#include <psp2/common_dialog.h>
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <string>
|
|
|
|
#define INCBIN_PREFIX _inc_
|
|
|
|
#define INCBIN_PREFIX _inc_
|
|
|
|
#include "incbin.h"
|
|
|
|
#include "incbin.h"
|
|
|
|
@ -37,7 +37,9 @@ const SceGxmMultisampleMode msaaMode = SCE_GXM_MULTISAMPLE_NONE;
|
|
|
|
|
|
|
|
|
|
|
|
#define SCE_GXM_PRECOMPUTED_ALIGNMENT 16
|
|
|
|
#define SCE_GXM_PRECOMPUTED_ALIGNMENT 16
|
|
|
|
|
|
|
|
|
|
|
|
#define INCSHADER(filename, name) INCBIN(name, filename); const SceGxmProgram* name = (const SceGxmProgram*) _inc_##name##Data;
|
|
|
|
#define INCSHADER(filename, name) \
|
|
|
|
|
|
|
|
INCBIN(name, filename); \
|
|
|
|
|
|
|
|
const SceGxmProgram* name = (const SceGxmProgram*) _inc_##name##Data;
|
|
|
|
|
|
|
|
|
|
|
|
INCSHADER("shaders/main.vert.gxp", mainVertexProgramGxp);
|
|
|
|
INCSHADER("shaders/main.vert.gxp", mainVertexProgramGxp);
|
|
|
|
INCSHADER("shaders/main.color.frag.gxp", mainColorFragmentProgramGxp);
|
|
|
|
INCSHADER("shaders/main.color.frag.gxp", mainColorFragmentProgramGxp);
|
|
|
|
@ -47,7 +49,6 @@ INCSHADER("shaders/plane.vert.gxp", planeVertexProgramGxp);
|
|
|
|
INCSHADER("shaders/image.frag.gxp", imageFragmentProgramGxp);
|
|
|
|
INCSHADER("shaders/image.frag.gxp", imageFragmentProgramGxp);
|
|
|
|
INCSHADER("shaders/color.frag.gxp", colorFragmentProgramGxp);
|
|
|
|
INCSHADER("shaders/color.frag.gxp", colorFragmentProgramGxp);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const SceGxmBlendInfo blendInfoOpaque = {
|
|
|
|
static const SceGxmBlendInfo blendInfoOpaque = {
|
|
|
|
.colorMask = SCE_GXM_COLOR_MASK_ALL,
|
|
|
|
.colorMask = SCE_GXM_COLOR_MASK_ALL,
|
|
|
|
.colorFunc = SCE_GXM_BLEND_FUNC_NONE,
|
|
|
|
.colorFunc = SCE_GXM_BLEND_FUNC_NONE,
|
|
|
|
@ -147,7 +148,8 @@ static void display_callback(const void* callback_data)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
bool load_razor() {
|
|
|
|
bool load_razor()
|
|
|
|
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
@ -256,7 +258,8 @@ int GXMContext::init()
|
|
|
|
contextParams.fragmentUsseRingBufferMemSize = SCE_GXM_DEFAULT_FRAGMENT_USSE_RING_BUFFER_SIZE;
|
|
|
|
contextParams.fragmentUsseRingBufferMemSize = SCE_GXM_DEFAULT_FRAGMENT_USSE_RING_BUFFER_SIZE;
|
|
|
|
contextParams.fragmentUsseRingBufferOffset = this->fragmentUsseRingBufferOffset;
|
|
|
|
contextParams.fragmentUsseRingBufferOffset = this->fragmentUsseRingBufferOffset;
|
|
|
|
|
|
|
|
|
|
|
|
if (ret = SCE_ERR(sceGxmCreateContext, &contextParams, &this->context); ret < 0) {
|
|
|
|
ret = SCE_ERR(sceGxmCreateContext, &contextParams, &this->context);
|
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this->contextHostMem = contextParams.hostMem;
|
|
|
|
this->contextHostMem = contextParams.hostMem;
|
|
|
|
@ -300,7 +303,8 @@ int GXMContext::init()
|
|
|
|
patcherParams.fragmentUsseMemSize = patcherFragmentUsseSize;
|
|
|
|
patcherParams.fragmentUsseMemSize = patcherFragmentUsseSize;
|
|
|
|
patcherParams.fragmentUsseOffset = this->patcherFragmentUsseOffset;
|
|
|
|
patcherParams.fragmentUsseOffset = this->patcherFragmentUsseOffset;
|
|
|
|
|
|
|
|
|
|
|
|
if (ret = SCE_ERR(sceGxmShaderPatcherCreate, &patcherParams, &this->shaderPatcher); ret < 0) {
|
|
|
|
ret = SCE_ERR(sceGxmShaderPatcherCreate, &patcherParams, &this->shaderPatcher);
|
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -314,7 +318,8 @@ int GXMContext::init()
|
|
|
|
renderTargetParams.multisampleMode = msaaMode;
|
|
|
|
renderTargetParams.multisampleMode = msaaMode;
|
|
|
|
renderTargetParams.multisampleLocations = 0;
|
|
|
|
renderTargetParams.multisampleLocations = 0;
|
|
|
|
renderTargetParams.driverMemBlock = -1; // Invalid UID
|
|
|
|
renderTargetParams.driverMemBlock = -1; // Invalid UID
|
|
|
|
if (ret = SCE_ERR(sceGxmCreateRenderTarget, &renderTargetParams, &this->renderTarget); ret < 0) {
|
|
|
|
ret = SCE_ERR(sceGxmCreateRenderTarget, &renderTargetParams, &this->renderTarget);
|
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -328,22 +333,25 @@ int GXMContext::init()
|
|
|
|
"displayBuffers"
|
|
|
|
"displayBuffers"
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if (ret = SCE_ERR(
|
|
|
|
ret = SCE_ERR(
|
|
|
|
sceGxmColorSurfaceInit,
|
|
|
|
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,
|
|
|
|
(msaaMode == SCE_GXM_MULTISAMPLE_NONE) ? SCE_GXM_COLOR_SURFACE_SCALE_NONE : SCE_GXM_COLOR_SURFACE_SCALE_MSAA_DOWNSCALE,
|
|
|
|
(msaaMode == SCE_GXM_MULTISAMPLE_NONE) ? SCE_GXM_COLOR_SURFACE_SCALE_NONE
|
|
|
|
|
|
|
|
: SCE_GXM_COLOR_SURFACE_SCALE_MSAA_DOWNSCALE,
|
|
|
|
SCE_GXM_OUTPUT_REGISTER_SIZE_32BIT,
|
|
|
|
SCE_GXM_OUTPUT_REGISTER_SIZE_32BIT,
|
|
|
|
VITA_GXM_SCREEN_WIDTH,
|
|
|
|
VITA_GXM_SCREEN_WIDTH,
|
|
|
|
VITA_GXM_SCREEN_HEIGHT,
|
|
|
|
VITA_GXM_SCREEN_HEIGHT,
|
|
|
|
VITA_GXM_SCREEN_STRIDE,
|
|
|
|
VITA_GXM_SCREEN_STRIDE,
|
|
|
|
this->displayBuffers[i]
|
|
|
|
this->displayBuffers[i]
|
|
|
|
); ret < 0) {
|
|
|
|
);
|
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (ret = SCE_ERR(sceGxmSyncObjectCreate, &this->displayBuffersSync[i]); ret < 0) {
|
|
|
|
ret = SCE_ERR(sceGxmSyncObjectCreate, &this->displayBuffersSync[i]);
|
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -360,22 +368,23 @@ int GXMContext::init()
|
|
|
|
|
|
|
|
|
|
|
|
this->stencilBufferData = vita_mem_alloc(
|
|
|
|
this->stencilBufferData = vita_mem_alloc(
|
|
|
|
SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE,
|
|
|
|
SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE,
|
|
|
|
4 * sampleCount,
|
|
|
|
1 * sampleCount,
|
|
|
|
SCE_GXM_DEPTHSTENCIL_SURFACE_ALIGNMENT,
|
|
|
|
SCE_GXM_DEPTHSTENCIL_SURFACE_ALIGNMENT,
|
|
|
|
SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE,
|
|
|
|
SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE,
|
|
|
|
&this->stencilBufferUid,
|
|
|
|
&this->stencilBufferUid,
|
|
|
|
"stencilBufferData"
|
|
|
|
"stencilBufferData"
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if (ret = SCE_ERR(
|
|
|
|
ret = SCE_ERR(
|
|
|
|
sceGxmDepthStencilSurfaceInit,
|
|
|
|
sceGxmDepthStencilSurfaceInit,
|
|
|
|
&this->depthSurface,
|
|
|
|
&this->depthSurface,
|
|
|
|
SCE_GXM_DEPTH_STENCIL_FORMAT_S8D24,
|
|
|
|
SCE_GXM_DEPTH_STENCIL_FORMAT_DF32_S8,
|
|
|
|
SCE_GXM_DEPTH_STENCIL_SURFACE_TILED,
|
|
|
|
SCE_GXM_DEPTH_STENCIL_SURFACE_TILED,
|
|
|
|
depthStrideInSamples,
|
|
|
|
depthStrideInSamples,
|
|
|
|
this->depthBufferData,
|
|
|
|
this->depthBufferData,
|
|
|
|
this->stencilBufferData
|
|
|
|
this->stencilBufferData
|
|
|
|
); ret < 0) {
|
|
|
|
);
|
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -385,32 +394,41 @@ int GXMContext::init()
|
|
|
|
CDRAM_POOL_SIZE,
|
|
|
|
CDRAM_POOL_SIZE,
|
|
|
|
16,
|
|
|
|
16,
|
|
|
|
SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE,
|
|
|
|
SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE,
|
|
|
|
&this->cdramUID, "cdram_pool"
|
|
|
|
&this->cdramUID,
|
|
|
|
|
|
|
|
"cdram_pool"
|
|
|
|
);
|
|
|
|
);
|
|
|
|
this->cdramPool = SDL_malloc(tlsf_size());
|
|
|
|
this->cdramPool = SDL_malloc(tlsf_size());
|
|
|
|
tlsf_create(this->cdramPool);
|
|
|
|
tlsf_create(this->cdramPool);
|
|
|
|
tlsf_add_pool(this->cdramPool, this->cdramMem, CDRAM_POOL_SIZE);
|
|
|
|
tlsf_add_pool(this->cdramPool, this->cdramMem, CDRAM_POOL_SIZE);
|
|
|
|
|
|
|
|
|
|
|
|
// register plane, color, image shaders
|
|
|
|
// register plane, color, image shaders
|
|
|
|
if (ret = SCE_ERR( sceGxmShaderPatcherRegisterProgram,
|
|
|
|
ret = SCE_ERR(
|
|
|
|
|
|
|
|
sceGxmShaderPatcherRegisterProgram,
|
|
|
|
this->shaderPatcher,
|
|
|
|
this->shaderPatcher,
|
|
|
|
planeVertexProgramGxp,
|
|
|
|
planeVertexProgramGxp,
|
|
|
|
&this->planeVertexProgramId
|
|
|
|
&this->planeVertexProgramId
|
|
|
|
); ret < 0) {
|
|
|
|
);
|
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ret = SCE_ERR(sceGxmShaderPatcherRegisterProgram,
|
|
|
|
|
|
|
|
|
|
|
|
ret = SCE_ERR(
|
|
|
|
|
|
|
|
sceGxmShaderPatcherRegisterProgram,
|
|
|
|
this->shaderPatcher,
|
|
|
|
this->shaderPatcher,
|
|
|
|
colorFragmentProgramGxp,
|
|
|
|
colorFragmentProgramGxp,
|
|
|
|
&this->colorFragmentProgramId
|
|
|
|
&this->colorFragmentProgramId
|
|
|
|
); ret < 0) {
|
|
|
|
);
|
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ret = SCE_ERR(sceGxmShaderPatcherRegisterProgram,
|
|
|
|
|
|
|
|
|
|
|
|
ret = SCE_ERR(
|
|
|
|
|
|
|
|
sceGxmShaderPatcherRegisterProgram,
|
|
|
|
this->shaderPatcher,
|
|
|
|
this->shaderPatcher,
|
|
|
|
imageFragmentProgramGxp,
|
|
|
|
imageFragmentProgramGxp,
|
|
|
|
&this->imageFragmentProgramId
|
|
|
|
&this->imageFragmentProgramId
|
|
|
|
); ret < 0) {
|
|
|
|
);
|
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -438,7 +456,7 @@ int GXMContext::init()
|
|
|
|
vertexStreams[0].stride = sizeof(float) * 4;
|
|
|
|
vertexStreams[0].stride = sizeof(float) * 4;
|
|
|
|
vertexStreams[0].indexSource = SCE_GXM_INDEX_SOURCE_INDEX_16BIT;
|
|
|
|
vertexStreams[0].indexSource = SCE_GXM_INDEX_SOURCE_INDEX_16BIT;
|
|
|
|
|
|
|
|
|
|
|
|
if (ret = SCE_ERR(
|
|
|
|
ret = SCE_ERR(
|
|
|
|
sceGxmShaderPatcherCreateVertexProgram,
|
|
|
|
sceGxmShaderPatcherCreateVertexProgram,
|
|
|
|
this->shaderPatcher,
|
|
|
|
this->shaderPatcher,
|
|
|
|
this->planeVertexProgramId,
|
|
|
|
this->planeVertexProgramId,
|
|
|
|
@ -447,11 +465,12 @@ int GXMContext::init()
|
|
|
|
vertexStreams,
|
|
|
|
vertexStreams,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
&this->planeVertexProgram
|
|
|
|
&this->planeVertexProgram
|
|
|
|
); ret < 0) {
|
|
|
|
);
|
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (ret = SCE_ERR(
|
|
|
|
ret = SCE_ERR(
|
|
|
|
sceGxmShaderPatcherCreateFragmentProgram,
|
|
|
|
sceGxmShaderPatcherCreateFragmentProgram,
|
|
|
|
this->shaderPatcher,
|
|
|
|
this->shaderPatcher,
|
|
|
|
this->colorFragmentProgramId,
|
|
|
|
this->colorFragmentProgramId,
|
|
|
|
@ -460,11 +479,12 @@ int GXMContext::init()
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
planeVertexProgramGxp,
|
|
|
|
planeVertexProgramGxp,
|
|
|
|
&this->colorFragmentProgram
|
|
|
|
&this->colorFragmentProgram
|
|
|
|
); ret < 0) {
|
|
|
|
);
|
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (ret = SCE_ERR(
|
|
|
|
ret = SCE_ERR(
|
|
|
|
sceGxmShaderPatcherCreateFragmentProgram,
|
|
|
|
sceGxmShaderPatcherCreateFragmentProgram,
|
|
|
|
this->shaderPatcher,
|
|
|
|
this->shaderPatcher,
|
|
|
|
this->imageFragmentProgramId,
|
|
|
|
this->imageFragmentProgramId,
|
|
|
|
@ -473,7 +493,8 @@ int GXMContext::init()
|
|
|
|
&blendInfoTransparent,
|
|
|
|
&blendInfoTransparent,
|
|
|
|
planeVertexProgramGxp,
|
|
|
|
planeVertexProgramGxp,
|
|
|
|
&this->imageFragmentProgram
|
|
|
|
&this->imageFragmentProgram
|
|
|
|
); ret < 0) {
|
|
|
|
);
|
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -512,7 +533,8 @@ void GXMContext::free(void* ptr)
|
|
|
|
tlsf_free(this->cdramPool, ptr);
|
|
|
|
tlsf_free(this->cdramPool, ptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GXMContext::clear(float r, float g, float b, bool new_scene) {
|
|
|
|
void GXMContext::clear(float r, float g, float b, bool new_scene)
|
|
|
|
|
|
|
|
{
|
|
|
|
new_scene = new_scene && !this->sceneStarted;
|
|
|
|
new_scene = new_scene && !this->sceneStarted;
|
|
|
|
if (new_scene) {
|
|
|
|
if (new_scene) {
|
|
|
|
sceGxmBeginScene(
|
|
|
|
sceGxmBeginScene(
|
|
|
|
@ -549,9 +571,11 @@ void GXMContext::clear(float r, float g, float b, bool new_scene) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GXMContext::copy_frontbuffer() {
|
|
|
|
void GXMContext::copy_frontbuffer()
|
|
|
|
|
|
|
|
{
|
|
|
|
SceGxmTexture texture;
|
|
|
|
SceGxmTexture texture;
|
|
|
|
sceGxmTextureInitLinearStrided(&texture,
|
|
|
|
sceGxmTextureInitLinearStrided(
|
|
|
|
|
|
|
|
&texture,
|
|
|
|
this->displayBuffers[this->frontBufferIndex],
|
|
|
|
this->displayBuffers[this->frontBufferIndex],
|
|
|
|
SCE_GXM_TEXTURE_FORMAT_U8U8U8U8_ABGR,
|
|
|
|
SCE_GXM_TEXTURE_FORMAT_U8U8U8U8_ABGR,
|
|
|
|
VITA_GXM_SCREEN_WIDTH,
|
|
|
|
VITA_GXM_SCREEN_WIDTH,
|
|
|
|
@ -573,10 +597,15 @@ void GXMContext::copy_frontbuffer() {
|
|
|
|
sceGxmDraw(this->context, SCE_GXM_PRIMITIVE_TRIANGLE_STRIP, SCE_GXM_INDEX_FORMAT_U16, this->clearIndices, 4);
|
|
|
|
sceGxmDraw(this->context, SCE_GXM_PRIMITIVE_TRIANGLE_STRIP, SCE_GXM_INDEX_FORMAT_U16, this->clearIndices, 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GXMContext::destroy() {
|
|
|
|
void GXMContext::destroy()
|
|
|
|
|
|
|
|
{
|
|
|
|
sceGxmDisplayQueueFinish();
|
|
|
|
sceGxmDisplayQueueFinish();
|
|
|
|
if(gxm->context) sceGxmFinish(gxm->context);
|
|
|
|
if (gxm->context) {
|
|
|
|
if(this->renderTarget) sceGxmDestroyRenderTarget(this->renderTarget);
|
|
|
|
sceGxmFinish(gxm->context);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this->renderTarget) {
|
|
|
|
|
|
|
|
sceGxmDestroyRenderTarget(this->renderTarget);
|
|
|
|
|
|
|
|
}
|
|
|
|
for (int i = 0; i < GXM_DISPLAY_BUFFER_COUNT; i++) {
|
|
|
|
for (int i = 0; i < GXM_DISPLAY_BUFFER_COUNT; i++) {
|
|
|
|
if (this->displayBuffersUid[i]) {
|
|
|
|
if (this->displayBuffersUid[i]) {
|
|
|
|
vita_mem_free(this->displayBuffersUid[i]);
|
|
|
|
vita_mem_free(this->displayBuffersUid[i]);
|
|
|
|
@ -585,8 +614,12 @@ void GXMContext::destroy() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(this->depthBufferUid) vita_mem_free(this->depthBufferUid);
|
|
|
|
if (this->depthBufferUid) {
|
|
|
|
if(this->stencilBufferUid) vita_mem_free(this->stencilBufferUid);
|
|
|
|
vita_mem_free(this->depthBufferUid);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this->stencilBufferUid) {
|
|
|
|
|
|
|
|
vita_mem_free(this->stencilBufferUid);
|
|
|
|
|
|
|
|
}
|
|
|
|
this->stencilBufferData = nullptr;
|
|
|
|
this->stencilBufferData = nullptr;
|
|
|
|
this->depthBufferData = nullptr;
|
|
|
|
this->depthBufferData = nullptr;
|
|
|
|
|
|
|
|
|
|
|
|
@ -599,15 +632,13 @@ void GXMContext::destroy() {
|
|
|
|
SDL_free(this->contextHostMem);
|
|
|
|
SDL_free(this->contextHostMem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GXMContext::swap_display() {
|
|
|
|
void GXMContext::swap_display()
|
|
|
|
|
|
|
|
{
|
|
|
|
if (this->sceneStarted) {
|
|
|
|
if (this->sceneStarted) {
|
|
|
|
SCE_ERR(sceGxmEndScene,
|
|
|
|
sceGxmEndScene(gxm->context, nullptr, nullptr);
|
|
|
|
gxm->context,
|
|
|
|
|
|
|
|
nullptr,
|
|
|
|
|
|
|
|
nullptr
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
this->sceneStarted = false;
|
|
|
|
this->sceneStarted = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SceCommonDialogUpdateParam updateParam;
|
|
|
|
SceCommonDialogUpdateParam updateParam;
|
|
|
|
SDL_zero(updateParam);
|
|
|
|
SDL_zero(updateParam);
|
|
|
|
updateParam.renderTarget.colorFormat = VITA_GXM_COLOR_FORMAT;
|
|
|
|
updateParam.renderTarget.colorFormat = VITA_GXM_COLOR_FORMAT;
|
|
|
|
@ -637,35 +668,6 @@ void GXMContext::swap_display() {
|
|
|
|
this->backBufferIndex = (this->backBufferIndex + 1) % GXM_DISPLAY_BUFFER_COUNT;
|
|
|
|
this->backBufferIndex = (this->backBufferIndex + 1) % GXM_DISPLAY_BUFFER_COUNT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void CreateOrthoMatrix(float left, float right, float bottom, float top, D3DRMMATRIX4D& outMatrix)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
float near = -1.0f;
|
|
|
|
|
|
|
|
float far = 1.0f;
|
|
|
|
|
|
|
|
float rl = right - left;
|
|
|
|
|
|
|
|
float tb = top - bottom;
|
|
|
|
|
|
|
|
float fn = far - near;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
outMatrix[0][0] = 2.0f / rl;
|
|
|
|
|
|
|
|
outMatrix[0][1] = 0.0f;
|
|
|
|
|
|
|
|
outMatrix[0][2] = 0.0f;
|
|
|
|
|
|
|
|
outMatrix[0][3] = 0.0f;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
outMatrix[1][0] = 0.0f;
|
|
|
|
|
|
|
|
outMatrix[1][1] = 2.0f / tb;
|
|
|
|
|
|
|
|
outMatrix[1][2] = 0.0f;
|
|
|
|
|
|
|
|
outMatrix[1][3] = 0.0f;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
outMatrix[2][0] = 0.0f;
|
|
|
|
|
|
|
|
outMatrix[2][1] = 0.0f;
|
|
|
|
|
|
|
|
outMatrix[2][2] = -2.0f / fn;
|
|
|
|
|
|
|
|
outMatrix[2][3] = 0.0f;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
outMatrix[3][0] = -(right + left) / rl;
|
|
|
|
|
|
|
|
outMatrix[3][1] = -(top + bottom) / tb;
|
|
|
|
|
|
|
|
outMatrix[3][2] = -(far + near) / fn;
|
|
|
|
|
|
|
|
outMatrix[3][3] = 1.0f;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Direct3DRMRenderer* GXMRenderer::Create(DWORD width, DWORD height)
|
|
|
|
Direct3DRMRenderer* GXMRenderer::Create(DWORD width, DWORD height)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int ret = gxm_library_init();
|
|
|
|
int ret = gxm_library_init();
|
|
|
|
@ -686,33 +688,39 @@ GXMRenderer::GXMRenderer(DWORD width, DWORD height)
|
|
|
|
if (!gxm) {
|
|
|
|
if (!gxm) {
|
|
|
|
gxm = (GXMContext*) SDL_malloc(sizeof(GXMContext));
|
|
|
|
gxm = (GXMContext*) SDL_malloc(sizeof(GXMContext));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(ret = SCE_ERR(gxm->init); ret < 0) {
|
|
|
|
ret = SCE_ERR(gxm->init);
|
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// register shader programs
|
|
|
|
// register shader programs
|
|
|
|
if (ret = SCE_ERR(
|
|
|
|
ret = SCE_ERR(
|
|
|
|
sceGxmShaderPatcherRegisterProgram,
|
|
|
|
sceGxmShaderPatcherRegisterProgram,
|
|
|
|
gxm->shaderPatcher,
|
|
|
|
gxm->shaderPatcher,
|
|
|
|
mainVertexProgramGxp,
|
|
|
|
mainVertexProgramGxp,
|
|
|
|
&this->mainVertexProgramId
|
|
|
|
&this->mainVertexProgramId
|
|
|
|
); ret < 0) {
|
|
|
|
);
|
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ret = SCE_ERR(
|
|
|
|
|
|
|
|
|
|
|
|
ret = SCE_ERR(
|
|
|
|
sceGxmShaderPatcherRegisterProgram,
|
|
|
|
sceGxmShaderPatcherRegisterProgram,
|
|
|
|
gxm->shaderPatcher,
|
|
|
|
gxm->shaderPatcher,
|
|
|
|
mainColorFragmentProgramGxp,
|
|
|
|
mainColorFragmentProgramGxp,
|
|
|
|
&this->mainColorFragmentProgramId
|
|
|
|
&this->mainColorFragmentProgramId
|
|
|
|
); ret < 0) {
|
|
|
|
);
|
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ret = SCE_ERR(
|
|
|
|
|
|
|
|
|
|
|
|
ret = SCE_ERR(
|
|
|
|
sceGxmShaderPatcherRegisterProgram,
|
|
|
|
sceGxmShaderPatcherRegisterProgram,
|
|
|
|
gxm->shaderPatcher,
|
|
|
|
gxm->shaderPatcher,
|
|
|
|
mainTextureFragmentProgramGxp,
|
|
|
|
mainTextureFragmentProgramGxp,
|
|
|
|
&this->mainTextureFragmentProgramId
|
|
|
|
&this->mainTextureFragmentProgramId
|
|
|
|
); ret < 0) {
|
|
|
|
);
|
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -748,7 +756,7 @@ 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 (ret = SCE_ERR(
|
|
|
|
ret = SCE_ERR(
|
|
|
|
sceGxmShaderPatcherCreateVertexProgram,
|
|
|
|
sceGxmShaderPatcherCreateVertexProgram,
|
|
|
|
gxm->shaderPatcher,
|
|
|
|
gxm->shaderPatcher,
|
|
|
|
this->mainVertexProgramId,
|
|
|
|
this->mainVertexProgramId,
|
|
|
|
@ -757,13 +765,14 @@ GXMRenderer::GXMRenderer(DWORD width, DWORD height)
|
|
|
|
vertexStreams,
|
|
|
|
vertexStreams,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
&this->mainVertexProgram
|
|
|
|
&this->mainVertexProgram
|
|
|
|
); ret < 0) {
|
|
|
|
);
|
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// main color opaque
|
|
|
|
// main color opaque
|
|
|
|
if (ret = SCE_ERR(
|
|
|
|
ret = SCE_ERR(
|
|
|
|
sceGxmShaderPatcherCreateFragmentProgram,
|
|
|
|
sceGxmShaderPatcherCreateFragmentProgram,
|
|
|
|
gxm->shaderPatcher,
|
|
|
|
gxm->shaderPatcher,
|
|
|
|
this->mainColorFragmentProgramId,
|
|
|
|
this->mainColorFragmentProgramId,
|
|
|
|
@ -772,12 +781,13 @@ GXMRenderer::GXMRenderer(DWORD width, DWORD height)
|
|
|
|
&blendInfoOpaque,
|
|
|
|
&blendInfoOpaque,
|
|
|
|
mainVertexProgramGxp,
|
|
|
|
mainVertexProgramGxp,
|
|
|
|
&this->opaqueColorFragmentProgram
|
|
|
|
&this->opaqueColorFragmentProgram
|
|
|
|
); ret < 0) {
|
|
|
|
);
|
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// main color blended
|
|
|
|
// main color blended
|
|
|
|
if (ret = SCE_ERR(
|
|
|
|
ret = SCE_ERR(
|
|
|
|
sceGxmShaderPatcherCreateFragmentProgram,
|
|
|
|
sceGxmShaderPatcherCreateFragmentProgram,
|
|
|
|
gxm->shaderPatcher,
|
|
|
|
gxm->shaderPatcher,
|
|
|
|
this->mainColorFragmentProgramId,
|
|
|
|
this->mainColorFragmentProgramId,
|
|
|
|
@ -786,12 +796,13 @@ GXMRenderer::GXMRenderer(DWORD width, DWORD height)
|
|
|
|
&blendInfoTransparent,
|
|
|
|
&blendInfoTransparent,
|
|
|
|
mainVertexProgramGxp,
|
|
|
|
mainVertexProgramGxp,
|
|
|
|
&this->blendedColorFragmentProgram
|
|
|
|
&this->blendedColorFragmentProgram
|
|
|
|
); ret < 0) {
|
|
|
|
);
|
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// main texture opaque
|
|
|
|
// main texture opaque
|
|
|
|
if (ret = SCE_ERR(
|
|
|
|
ret = SCE_ERR(
|
|
|
|
sceGxmShaderPatcherCreateFragmentProgram,
|
|
|
|
sceGxmShaderPatcherCreateFragmentProgram,
|
|
|
|
gxm->shaderPatcher,
|
|
|
|
gxm->shaderPatcher,
|
|
|
|
this->mainTextureFragmentProgramId,
|
|
|
|
this->mainTextureFragmentProgramId,
|
|
|
|
@ -800,12 +811,13 @@ GXMRenderer::GXMRenderer(DWORD width, DWORD height)
|
|
|
|
&blendInfoOpaque,
|
|
|
|
&blendInfoOpaque,
|
|
|
|
mainVertexProgramGxp,
|
|
|
|
mainVertexProgramGxp,
|
|
|
|
&this->opaqueTextureFragmentProgram
|
|
|
|
&this->opaqueTextureFragmentProgram
|
|
|
|
); ret < 0) {
|
|
|
|
);
|
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// main texture transparent
|
|
|
|
// main texture transparent
|
|
|
|
if (ret = SCE_ERR(
|
|
|
|
ret = SCE_ERR(
|
|
|
|
sceGxmShaderPatcherCreateFragmentProgram,
|
|
|
|
sceGxmShaderPatcherCreateFragmentProgram,
|
|
|
|
gxm->shaderPatcher,
|
|
|
|
gxm->shaderPatcher,
|
|
|
|
this->mainTextureFragmentProgramId,
|
|
|
|
this->mainTextureFragmentProgramId,
|
|
|
|
@ -814,16 +826,12 @@ GXMRenderer::GXMRenderer(DWORD width, DWORD height)
|
|
|
|
&blendInfoTransparent,
|
|
|
|
&blendInfoTransparent,
|
|
|
|
mainVertexProgramGxp,
|
|
|
|
mainVertexProgramGxp,
|
|
|
|
&this->blendedTextureFragmentProgram
|
|
|
|
&this->blendedTextureFragmentProgram
|
|
|
|
); ret < 0) {
|
|
|
|
);
|
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// vertex uniforms
|
|
|
|
// vertex uniforms
|
|
|
|
//this->uNormalMatrix = sceGxmProgramFindParameterByName(mainVertexProgramGxp, "uNormalMatrix");
|
|
|
|
|
|
|
|
//this->uWorldViewProjection = sceGxmProgramFindParameterByName(mainVertexProgramGxp, "uWorldViewProjection");
|
|
|
|
|
|
|
|
//this->uWorld = sceGxmProgramFindParameterByName(mainVertexProgramGxp, "uWorld");
|
|
|
|
|
|
|
|
//this->uViewInverse = sceGxmProgramFindParameterByName(mainVertexProgramGxp, "uViewInverse");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this->uModelViewMatrix = sceGxmProgramFindParameterByName(mainVertexProgramGxp, "uModelViewMatrix");
|
|
|
|
this->uModelViewMatrix = sceGxmProgramFindParameterByName(mainVertexProgramGxp, "uModelViewMatrix");
|
|
|
|
this->uNormalMatrix = sceGxmProgramFindParameterByName(mainVertexProgramGxp, "uNormalMatrix");
|
|
|
|
this->uNormalMatrix = sceGxmProgramFindParameterByName(mainVertexProgramGxp, "uNormalMatrix");
|
|
|
|
this->uProjectionMatrix = sceGxmProgramFindParameterByName(mainVertexProgramGxp, "uProjectionMatrix");
|
|
|
|
this->uProjectionMatrix = sceGxmProgramFindParameterByName(mainVertexProgramGxp, "uProjectionMatrix");
|
|
|
|
@ -869,21 +877,31 @@ GXMRenderer::GXMRenderer(DWORD width, DWORD height)
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(ids) SDL_free(ids);
|
|
|
|
if (ids) {
|
|
|
|
|
|
|
|
SDL_free(ids);
|
|
|
|
|
|
|
|
}
|
|
|
|
m_initialized = true;
|
|
|
|
m_initialized = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GXMRenderer::~GXMRenderer()
|
|
|
|
GXMRenderer::~GXMRenderer()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (int i = 0; i < GXM_FRAGMENT_BUFFER_COUNT; i++) {
|
|
|
|
for (int i = 0; i < GXM_FRAGMENT_BUFFER_COUNT; i++) {
|
|
|
|
if(this->lights[i]) gxm->free(this->lights[i]);
|
|
|
|
if (this->lights[i]) {
|
|
|
|
|
|
|
|
gxm->free(this->lights[i]);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (int i = 0; i < GXM_VERTEX_BUFFER_COUNT; i++) {
|
|
|
|
for (int i = 0; i < GXM_VERTEX_BUFFER_COUNT; i++) {
|
|
|
|
if(this->quadVertices[i]) gxm->free(this->quadVertices[i]);
|
|
|
|
if (this->quadVertices[i]) {
|
|
|
|
|
|
|
|
gxm->free(this->quadVertices[i]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this->quadIndices) {
|
|
|
|
|
|
|
|
gxm->free(this->quadIndices);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(this->quadIndices) gxm->free(this->quadIndices);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(this->gamepad) SDL_CloseGamepad(this->gamepad);
|
|
|
|
if (this->gamepad) {
|
|
|
|
|
|
|
|
SDL_CloseGamepad(this->gamepad);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GXMRenderer::PushLights(const SceneLight* lightsArray, size_t count)
|
|
|
|
void GXMRenderer::PushLights(const SceneLight* lightsArray, size_t count)
|
|
|
|
@ -1094,7 +1112,8 @@ Uint32 GXMRenderer::GetTextureId(IDirect3DRMTexture* iTexture, bool isUi, float
|
|
|
|
sceGxmTextureSetMagFilter(&gxmTexture, SCE_GXM_TEXTURE_FILTER_POINT);
|
|
|
|
sceGxmTextureSetMagFilter(&gxmTexture, SCE_GXM_TEXTURE_FILTER_POINT);
|
|
|
|
sceGxmTextureSetUAddrMode(&gxmTexture, SCE_GXM_TEXTURE_ADDR_CLAMP);
|
|
|
|
sceGxmTextureSetUAddrMode(&gxmTexture, SCE_GXM_TEXTURE_ADDR_CLAMP);
|
|
|
|
sceGxmTextureSetVAddrMode(&gxmTexture, SCE_GXM_TEXTURE_ADDR_CLAMP);
|
|
|
|
sceGxmTextureSetVAddrMode(&gxmTexture, SCE_GXM_TEXTURE_ADDR_CLAMP);
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
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);
|
|
|
|
@ -1209,24 +1228,24 @@ GXMMeshCacheEntry GXMRenderer::GXMUploadMesh(const MeshGroup& meshGroup)
|
|
|
|
if (texture) {
|
|
|
|
if (texture) {
|
|
|
|
fragmentProgramGxp = mainTextureFragmentProgramGxp;
|
|
|
|
fragmentProgramGxp = mainTextureFragmentProgramGxp;
|
|
|
|
fragmentProgram = isOpaque ? this->opaqueTextureFragmentProgram : this->blendedTextureFragmentProgram;
|
|
|
|
fragmentProgram = isOpaque ? this->opaqueTextureFragmentProgram : this->blendedTextureFragmentProgram;
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
fragmentProgramGxp = mainColorFragmentProgramGxp;
|
|
|
|
fragmentProgramGxp = mainColorFragmentProgramGxp;
|
|
|
|
fragmentProgram = isOpaque ? this->opaqueColorFragmentProgram : this->blendedColorFragmentProgram;
|
|
|
|
fragmentProgram = isOpaque ? this->opaqueColorFragmentProgram : this->blendedColorFragmentProgram;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// get sizes
|
|
|
|
// get sizes
|
|
|
|
const size_t drawSize = ALIGN(sceGxmGetPrecomputedDrawSize(this->mainVertexProgram), SCE_GXM_PRECOMPUTED_ALIGNMENT);
|
|
|
|
const size_t drawSize = ALIGN(sceGxmGetPrecomputedDrawSize(this->mainVertexProgram), SCE_GXM_PRECOMPUTED_ALIGNMENT);
|
|
|
|
const size_t vertexStateSize = ALIGN(sceGxmGetPrecomputedVertexStateSize(this->mainVertexProgram), SCE_GXM_PRECOMPUTED_ALIGNMENT);
|
|
|
|
const size_t vertexStateSize =
|
|
|
|
const size_t fragmentStateSize = ALIGN(sceGxmGetPrecomputedFragmentStateSize(fragmentProgram), SCE_GXM_PRECOMPUTED_ALIGNMENT);
|
|
|
|
ALIGN(sceGxmGetPrecomputedVertexStateSize(this->mainVertexProgram), SCE_GXM_PRECOMPUTED_ALIGNMENT);
|
|
|
|
|
|
|
|
const size_t fragmentStateSize =
|
|
|
|
|
|
|
|
ALIGN(sceGxmGetPrecomputedFragmentStateSize(fragmentProgram), SCE_GXM_PRECOMPUTED_ALIGNMENT);
|
|
|
|
const size_t precomputeDataSize =
|
|
|
|
const size_t precomputeDataSize =
|
|
|
|
drawSize +
|
|
|
|
drawSize + vertexStateSize * GXM_VERTEX_BUFFER_COUNT + fragmentStateSize * GXM_FRAGMENT_BUFFER_COUNT;
|
|
|
|
vertexStateSize * GXM_VERTEX_BUFFER_COUNT +
|
|
|
|
|
|
|
|
fragmentStateSize * GXM_FRAGMENT_BUFFER_COUNT;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const size_t vertexDefaultBufferSize = sceGxmProgramGetDefaultUniformBufferSize(mainVertexProgramGxp);
|
|
|
|
const size_t vertexDefaultBufferSize = sceGxmProgramGetDefaultUniformBufferSize(mainVertexProgramGxp);
|
|
|
|
const size_t fragmentDefaultBufferSize = sceGxmProgramGetDefaultUniformBufferSize(fragmentProgramGxp);
|
|
|
|
const size_t fragmentDefaultBufferSize = sceGxmProgramGetDefaultUniformBufferSize(fragmentProgramGxp);
|
|
|
|
const size_t uniformBuffersSize =
|
|
|
|
const size_t uniformBuffersSize = vertexDefaultBufferSize * GXM_VERTEX_BUFFER_COUNT;
|
|
|
|
vertexDefaultBufferSize * GXM_VERTEX_BUFFER_COUNT;
|
|
|
|
|
|
|
|
fragmentStateSize* GXM_FRAGMENT_BUFFER_COUNT;
|
|
|
|
fragmentStateSize* GXM_FRAGMENT_BUFFER_COUNT;
|
|
|
|
|
|
|
|
|
|
|
|
sceClibPrintf("drawSize: %d\n", drawSize);
|
|
|
|
sceClibPrintf("drawSize: %d\n", drawSize);
|
|
|
|
@ -1245,11 +1264,7 @@ GXMMeshCacheEntry GXMRenderer::GXMUploadMesh(const MeshGroup& meshGroup)
|
|
|
|
cache.uniformBuffers = uniformBuffers;
|
|
|
|
cache.uniformBuffers = uniformBuffers;
|
|
|
|
|
|
|
|
|
|
|
|
// init precomputed draw
|
|
|
|
// init precomputed draw
|
|
|
|
SCE_ERR(sceGxmPrecomputedDrawInit,
|
|
|
|
SCE_ERR(sceGxmPrecomputedDrawInit, &cache.drawState, this->mainVertexProgram, precomputeData);
|
|
|
|
&cache.drawState,
|
|
|
|
|
|
|
|
this->mainVertexProgram,
|
|
|
|
|
|
|
|
precomputeData
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
void* vertexStreams[] = {vertexBuffer};
|
|
|
|
void* vertexStreams[] = {vertexBuffer};
|
|
|
|
sceGxmPrecomputedDrawSetAllVertexStreams(&cache.drawState, vertexStreams);
|
|
|
|
sceGxmPrecomputedDrawSetAllVertexStreams(&cache.drawState, vertexStreams);
|
|
|
|
sceGxmPrecomputedDrawSetParams(
|
|
|
|
sceGxmPrecomputedDrawSetParams(
|
|
|
|
@ -1263,36 +1278,24 @@ GXMMeshCacheEntry GXMRenderer::GXMUploadMesh(const MeshGroup& meshGroup)
|
|
|
|
|
|
|
|
|
|
|
|
// init precomputed vertex state
|
|
|
|
// init precomputed vertex state
|
|
|
|
for (int bufferIndex = 0; bufferIndex < GXM_VERTEX_BUFFER_COUNT; bufferIndex++) {
|
|
|
|
for (int bufferIndex = 0; bufferIndex < GXM_VERTEX_BUFFER_COUNT; bufferIndex++) {
|
|
|
|
SCE_ERR(sceGxmPrecomputedVertexStateInit,
|
|
|
|
SCE_ERR(
|
|
|
|
|
|
|
|
sceGxmPrecomputedVertexStateInit,
|
|
|
|
&cache.vertexState[bufferIndex],
|
|
|
|
&cache.vertexState[bufferIndex],
|
|
|
|
this->mainVertexProgram,
|
|
|
|
this->mainVertexProgram,
|
|
|
|
precomputeData
|
|
|
|
precomputeData
|
|
|
|
);
|
|
|
|
);
|
|
|
|
sceGxmPrecomputedVertexStateSetDefaultUniformBuffer(
|
|
|
|
sceGxmPrecomputedVertexStateSetDefaultUniformBuffer(&cache.vertexState[bufferIndex], uniformBuffers);
|
|
|
|
&cache.vertexState[bufferIndex],
|
|
|
|
|
|
|
|
uniformBuffers
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
precomputeData += vertexStateSize;
|
|
|
|
precomputeData += vertexStateSize;
|
|
|
|
uniformBuffers += vertexDefaultBufferSize;
|
|
|
|
uniformBuffers += vertexDefaultBufferSize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// init precomputed fragment state
|
|
|
|
// init precomputed fragment state
|
|
|
|
for (int bufferIndex = 0; bufferIndex < GXM_FRAGMENT_BUFFER_COUNT; bufferIndex++) {
|
|
|
|
for (int bufferIndex = 0; bufferIndex < GXM_FRAGMENT_BUFFER_COUNT; bufferIndex++) {
|
|
|
|
SCE_ERR(sceGxmPrecomputedFragmentStateInit,
|
|
|
|
SCE_ERR(sceGxmPrecomputedFragmentStateInit, &cache.fragmentState[bufferIndex], fragmentProgram, precomputeData);
|
|
|
|
&cache.fragmentState[bufferIndex],
|
|
|
|
|
|
|
|
fragmentProgram,
|
|
|
|
|
|
|
|
precomputeData
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
if (texture) {
|
|
|
|
if (texture) {
|
|
|
|
sceGxmPrecomputedFragmentStateSetTexture(
|
|
|
|
sceGxmPrecomputedFragmentStateSetTexture(&cache.fragmentState[bufferIndex], 0, texture);
|
|
|
|
&cache.fragmentState[bufferIndex],
|
|
|
|
|
|
|
|
0, texture
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sceGxmPrecomputedFragmentStateSetDefaultUniformBuffer(
|
|
|
|
sceGxmPrecomputedFragmentStateSetDefaultUniformBuffer(&cache.fragmentState[bufferIndex], uniformBuffers);
|
|
|
|
&cache.fragmentState[bufferIndex],
|
|
|
|
|
|
|
|
uniformBuffers
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
precomputeData += fragmentStateSize;
|
|
|
|
precomputeData += fragmentStateSize;
|
|
|
|
uniformBuffers += fragmentDefaultBufferSize;
|
|
|
|
uniformBuffers += fragmentDefaultBufferSize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1454,7 +1457,8 @@ HRESULT GXMRenderer::BeginFrame()
|
|
|
|
lightData->lights[i].vec[0] = light.direction.x;
|
|
|
|
lightData->lights[i].vec[0] = light.direction.x;
|
|
|
|
lightData->lights[i].vec[1] = light.direction.y;
|
|
|
|
lightData->lights[i].vec[1] = light.direction.y;
|
|
|
|
lightData->lights[i].vec[2] = light.direction.z;
|
|
|
|
lightData->lights[i].vec[2] = light.direction.z;
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
lightData->lights[i].vec[0] = light.position.x;
|
|
|
|
lightData->lights[i].vec[0] = light.position.x;
|
|
|
|
lightData->lights[i].vec[1] = light.position.y;
|
|
|
|
lightData->lights[i].vec[1] = light.position.y;
|
|
|
|
lightData->lights[i].vec[2] = light.position.z;
|
|
|
|
lightData->lights[i].vec[2] = light.position.z;
|
|
|
|
@ -1520,12 +1524,12 @@ void GXMRenderer::SubmitDraw(
|
|
|
|
sceGxmPushUserMarker(gxm->context, marker);
|
|
|
|
sceGxmPushUserMarker(gxm->context, marker);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool textured = appearance.textureId != NO_TEXTURE_ID;
|
|
|
|
bool textured = appearance.textureId != NO_TEXTURE_ID;
|
|
|
|
const SceGxmFragmentProgram* fragmentProgram;
|
|
|
|
const SceGxmFragmentProgram* fragmentProgram;
|
|
|
|
if (this->transparencyEnabled) {
|
|
|
|
if (this->transparencyEnabled) {
|
|
|
|
fragmentProgram = textured ? this->blendedTextureFragmentProgram : this->blendedColorFragmentProgram;
|
|
|
|
fragmentProgram = textured ? this->blendedTextureFragmentProgram : this->blendedColorFragmentProgram;
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
fragmentProgram = textured ? this->opaqueTextureFragmentProgram : this->opaqueColorFragmentProgram;
|
|
|
|
fragmentProgram = textured ? this->opaqueTextureFragmentProgram : this->opaqueColorFragmentProgram;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sceGxmSetVertexProgram(gxm->context, this->mainVertexProgram);
|
|
|
|
sceGxmSetVertexProgram(gxm->context, this->mainVertexProgram);
|
|
|
|
@ -1615,7 +1619,8 @@ void GXMRenderer::Draw2DImage(Uint32 textureId, const SDL_Rect& srcRect, const S
|
|
|
|
sceGxmSetVertexProgram(gxm->context, gxm->planeVertexProgram);
|
|
|
|
sceGxmSetVertexProgram(gxm->context, gxm->planeVertexProgram);
|
|
|
|
if (textureId != NO_TEXTURE_ID) {
|
|
|
|
if (textureId != NO_TEXTURE_ID) {
|
|
|
|
sceGxmSetFragmentProgram(gxm->context, gxm->imageFragmentProgram);
|
|
|
|
sceGxmSetFragmentProgram(gxm->context, gxm->imageFragmentProgram);
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
sceGxmSetFragmentProgram(gxm->context, gxm->colorFragmentProgram);
|
|
|
|
sceGxmSetFragmentProgram(gxm->context, gxm->colorFragmentProgram);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -1657,7 +1662,8 @@ void GXMRenderer::Draw2DImage(Uint32 textureId, const SDL_Rect& srcRect, const S
|
|
|
|
v1 = static_cast<float>(srcRect.y) / texH;
|
|
|
|
v1 = static_cast<float>(srcRect.y) / texH;
|
|
|
|
u2 = static_cast<float>(srcRect.x + srcRect.w) / texW;
|
|
|
|
u2 = static_cast<float>(srcRect.x + srcRect.w) / texW;
|
|
|
|
v2 = static_cast<float>(srcRect.y + srcRect.h) / texH;
|
|
|
|
v2 = static_cast<float>(srcRect.y + srcRect.h) / texH;
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
SET_UNIFORM(fragUniforms, gxm->color_uColor, color);
|
|
|
|
SET_UNIFORM(fragUniforms, gxm->color_uColor, color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|