Skip to content

Commit

Permalink
[rend2] Fix typo and fix ubos in sp port
Browse files Browse the repository at this point in the history
  • Loading branch information
SomaZ committed May 2, 2024
1 parent 9ff929c commit 166e83b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
11 changes: 6 additions & 5 deletions code/rd-rend2/tr_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1724,18 +1724,19 @@ static void R_InitBackEndFrameData()
GLuint timerQueries[MAX_GPU_TIMERS*MAX_FRAMES];
qglGenQueries(MAX_GPU_TIMERS*MAX_FRAMES, timerQueries);

GLuint ubos[MAX_FRAMES];
qglGenBuffers(MAX_FRAMES, ubos);
GLuint ubos[MAX_FRAMES * MAX_SCENES];
qglGenBuffers(MAX_FRAMES * MAX_SCENES, ubos);


for ( int i = 0; i < MAX_FRAMES; i++ )
{
gpuFrame_t *frame = backEndData->frames + i;
const GLbitfield mapBits = GL_MAP_WRITE_BIT | GL_MAP_COHERENT_BIT | GL_MAP_PERSISTENT_BIT;

for (byte j = 0; j < MAX_SCENCES; j++)
for (byte j = 0; j < MAX_SCENES; j++)
{
size_t BUFFER_SIZE = j == 0 ? FRAME_UNIFORM_BUFFER_SIZE : FRAME_SCENE_UNIFORM_BUFFER_SIZE;
frame->ubo[j] = ubos[i * MAX_SCENCES + j];
frame->ubo[j] = ubos[i * MAX_SCENES + j];
frame->uboWriteOffset[j] = 0;
frame->uboSize[j] = BUFFER_SIZE;
qglBindBuffer(GL_UNIFORM_BUFFER, frame->ubo[j]);
Expand Down Expand Up @@ -1945,7 +1946,7 @@ static void R_ShutdownBackEndFrameData()
frame->sync = NULL;
}

qglDeleteBuffers(MAX_SCENCES, frame->ubo);
qglDeleteBuffers(MAX_SCENES, frame->ubo);

if ( glRefConfig.immutableBuffers )
{
Expand Down
10 changes: 5 additions & 5 deletions codemp/rd-rend2/tr_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1674,18 +1674,18 @@ static void R_InitBackEndFrameData()
GLuint timerQueries[MAX_GPU_TIMERS*MAX_FRAMES];
qglGenQueries(MAX_GPU_TIMERS*MAX_FRAMES, timerQueries);

GLuint ubos[MAX_FRAMES * MAX_SCENCES];
qglGenBuffers(MAX_FRAMES * MAX_SCENCES, ubos);
GLuint ubos[MAX_FRAMES * MAX_SCENES];
qglGenBuffers(MAX_FRAMES * MAX_SCENES, ubos);

for ( int i = 0; i < MAX_FRAMES; i++ )
{
gpuFrame_t *frame = backEndData->frames + i;
const GLbitfield mapBits = GL_MAP_WRITE_BIT | GL_MAP_COHERENT_BIT | GL_MAP_PERSISTENT_BIT;

for (byte j = 0; j < MAX_SCENCES; j++)
for (byte j = 0; j < MAX_SCENES; j++)
{
size_t BUFFER_SIZE = j == 0 ? FRAME_UNIFORM_BUFFER_SIZE : FRAME_SCENE_UNIFORM_BUFFER_SIZE;
frame->ubo[j] = ubos[i * MAX_SCENCES + j];
frame->ubo[j] = ubos[i * MAX_SCENES + j];
frame->uboWriteOffset[j] = 0;
frame->uboSize[j] = BUFFER_SIZE;
qglBindBuffer(GL_UNIFORM_BUFFER, frame->ubo[j]);
Expand Down Expand Up @@ -1891,7 +1891,7 @@ static void R_ShutdownBackEndFrameData()
frame->sync = NULL;
}

qglDeleteBuffers(MAX_SCENCES, frame->ubo);
qglDeleteBuffers(MAX_SCENES, frame->ubo);

if ( glRefConfig.immutableBuffers )
{
Expand Down
4 changes: 2 additions & 2 deletions shared/rd-rend2/tr_cmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) {
qglDeleteSync( sync );
thisFrame->sync = NULL;

for (byte i = 0; i < MAX_SCENCES; i++)
for (byte i = 0; i < MAX_SCENES; i++)
{
thisFrame->uboWriteOffset[i] = 0;
}
Expand All @@ -579,7 +579,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) {
R_SaveScreenshot(&thisFrame->screenshotReadback);

// Resets resources
for (byte i = 0; i < MAX_SCENCES; i++)
for (byte i = 0; i < MAX_SCENES; i++)
{
qglBindBuffer(GL_UNIFORM_BUFFER, thisFrame->ubo[i]);
glState.currentGlobalUBO = thisFrame->ubo[i];
Expand Down
12 changes: 6 additions & 6 deletions shared/rd-rend2/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -3677,16 +3677,16 @@ struct screenshotReadback_t
};

#define MAX_GPU_TIMERS (512)
#define MAX_SCENCES (3)
#define MAX_SCENES (3)
struct gpuFrame_t
{
GLsync sync;
byte currentScene;
GLuint ubo[MAX_SCENCES];
size_t uboWriteOffset[MAX_SCENCES];
size_t uboSize[MAX_SCENCES];
size_t uboMapBase[MAX_SCENCES];
void *uboMemory[MAX_SCENCES];
GLuint ubo[MAX_SCENES];
size_t uboWriteOffset[MAX_SCENES];
size_t uboSize[MAX_SCENES];
size_t uboMapBase[MAX_SCENES];
void *uboMemory[MAX_SCENES];

screenshotReadback_t screenshotReadback;

Expand Down
2 changes: 1 addition & 1 deletion shared/rd-rend2/tr_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ void RE_EndScene()
tr.refdef.doFullbright = false;
#endif
backEndData->currentFrame->currentScene++;
if (backEndData->currentFrame->currentScene > MAX_SCENCES)
if (backEndData->currentFrame->currentScene > MAX_SCENES)
{
ri.Error(ERR_DROP, "Tried to render to many subscenes per frame");
}
Expand Down

0 comments on commit 166e83b

Please sign in to comment.