double buffered uniforms seem to work now

This commit is contained in:
olebeck 2025-06-30 21:07:42 +02:00
parent 5005772243
commit 9cab1ac14d
2 changed files with 12 additions and 17 deletions

View File

@ -511,15 +511,15 @@ GXMRenderer::GXMRenderer(DWORD width, DWORD height)
vertexStreams[0].indexSource = SCE_GXM_INDEX_SOURCE_INDEX_16BIT; vertexStreams[0].indexSource = SCE_GXM_INDEX_SOURCE_INDEX_16BIT;
if (SCE_ERR( if (SCE_ERR(
sceGxmShaderPatcherCreateVertexProgram, sceGxmShaderPatcherCreateVertexProgram,
this->shaderPatcher, this->shaderPatcher,
this->mainVertexProgramId, this->mainVertexProgramId,
vertexAttributes, vertexAttributes,
3, 3,
vertexStreams, vertexStreams,
1, 1,
&this->mainVertexProgram &this->mainVertexProgram
)) { )) {
return; return;
} }
} }
@ -1070,7 +1070,6 @@ void GXMRenderer::StartScene()
this->sceneStarted = true; this->sceneStarted = true;
this->quadsUsed = 0; this->quadsUsed = 0;
// wait for this uniform buffer to become available
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]);
} }
@ -1253,13 +1252,10 @@ void GXMRenderer::Flip()
// end scene // end scene
++this->fragmentNotifications[this->activeUniformBuffer].value; ++this->fragmentNotifications[this->activeUniformBuffer].value;
++this->vertexNotifications[this->activeUniformBuffer].value;
sceGxmEndScene( sceGxmEndScene(
this->context, this->context,
nullptr, //&this->vertexNotifications[this->activeUniformBuffer], nullptr,
// nullptr &this->fragmentNotifications[this->activeUniformBuffer]
&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],

View File

@ -17,7 +17,7 @@
DEFINE_GUID(GXM_GUID, 0x682656F3, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x58, 0x4D); DEFINE_GUID(GXM_GUID, 0x682656F3, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x58, 0x4D);
#define VITA_GXM_DISPLAY_BUFFER_COUNT 3 #define VITA_GXM_DISPLAY_BUFFER_COUNT 3
#define VITA_GXM_UNIFORM_BUFFER_COUNT 6 // hacky solution to corruption while drawing next frame, sync not working #define VITA_GXM_UNIFORM_BUFFER_COUNT 2
struct GXMTextureCacheEntry { struct GXMTextureCacheEntry {
IDirect3DRMTexture* texture; IDirect3DRMTexture* texture;
@ -207,7 +207,6 @@ class GXMRenderer : public Direct3DRMRenderer {
uint16_t* quadIndices; uint16_t* quadIndices;
int quadsUsed = 0; int quadsUsed = 0;
int activeUniformBuffer = 0; int activeUniformBuffer = 0;
SceGxmNotification vertexNotifications[VITA_GXM_UNIFORM_BUFFER_COUNT];
SceGxmNotification fragmentNotifications[VITA_GXM_UNIFORM_BUFFER_COUNT]; SceGxmNotification fragmentNotifications[VITA_GXM_UNIFORM_BUFFER_COUNT];
SDL_Gamepad* gamepad; SDL_Gamepad* gamepad;