chore: rename critical section variable to a more accurate one

fix: call ``Renderer::CBuffTick`` at ``C4JRender::Tick`` in release mode
This commit is contained in:
Patoke
2026-03-03 01:59:30 -03:00
parent 8dd19edd1a
commit 7a4e31561d
4 changed files with 20 additions and 22 deletions
-2
View File
@@ -30,9 +30,7 @@ C4JRender RenderManager;
void C4JRender::Tick() void C4JRender::Tick()
{ {
#if _DEBUG
InternalRenderManager.CBuffTick(); InternalRenderManager.CBuffTick();
#endif
} }
void C4JRender::UpdateGamma(unsigned short usGamma) void C4JRender::UpdateGamma(unsigned short usGamma)
+1 -1
View File
@@ -443,7 +443,7 @@ public:
DWORD presentCount; DWORD presentCount;
BYTE rendererFlag0; BYTE rendererFlag0;
BYTE paddingAfterRendererFlag0[3]; BYTE paddingAfterRendererFlag0[3];
_RTL_CRITICAL_SECTION rtl_critical_section100; _RTL_CRITICAL_SECTION m_commandBufferCS;
DWORD activeVertexType; DWORD activeVertexType;
DWORD activePixelType; DWORD activePixelType;
C4JRender::eViewportType m_ViewportType; C4JRender::eViewportType m_ViewportType;
+18 -18
View File
@@ -491,7 +491,7 @@ void Renderer::CommandBuffer::Render(C4JRender::eVertexType vType, Renderer::Con
bool Renderer::CBuffCall(int index, bool full) bool Renderer::CBuffCall(int index, bool full)
{ {
EnterCriticalSection(&rtl_critical_section100); EnterCriticalSection(&m_commandBufferCS);
bool result = false; bool result = false;
const int commandIndex = m_commandHandleToIndex[index]; const int commandIndex = m_commandHandleToIndex[index];
@@ -582,13 +582,13 @@ bool Renderer::CBuffCall(int index, bool full)
result = true; result = true;
} }
LeaveCriticalSection(&rtl_critical_section100); LeaveCriticalSection(&m_commandBufferCS);
return result; return result;
} }
void Renderer::CBuffClear(int index) void Renderer::CBuffClear(int index)
{ {
EnterCriticalSection(&rtl_critical_section100); EnterCriticalSection(&m_commandBufferCS);
std::int16_t *externalToInternal = static_cast<std::int16_t *>(m_commandHandleToIndex); std::int16_t *externalToInternal = static_cast<std::int16_t *>(m_commandHandleToIndex);
const int internalIndex = externalToInternal[index]; const int internalIndex = externalToInternal[index];
@@ -598,12 +598,12 @@ void Renderer::CBuffClear(int index)
externalToInternal[index] = static_cast<std::int16_t>(-2); externalToInternal[index] = static_cast<std::int16_t>(-2);
} }
LeaveCriticalSection(&rtl_critical_section100); LeaveCriticalSection(&m_commandBufferCS);
} }
int Renderer::CBuffCreate(int count) int Renderer::CBuffCreate(int count)
{ {
EnterCriticalSection(&rtl_critical_section100); EnterCriticalSection(&m_commandBufferCS);
int first = reservedRendererDword1; int first = reservedRendererDword1;
if (first < NUM_COMMAND_HANDLES) if (first < NUM_COMMAND_HANDLES)
@@ -648,7 +648,7 @@ int Renderer::CBuffCreate(int count)
first = -1; first = -1;
} }
LeaveCriticalSection(&rtl_critical_section100); LeaveCriticalSection(&m_commandBufferCS);
return first; return first;
} }
@@ -658,7 +658,7 @@ void Renderer::CBuffDeferredModeEnd()
if (!c.deferredModeEnabled) if (!c.deferredModeEnabled)
return; return;
EnterCriticalSection(&rtl_critical_section100); EnterCriticalSection(&m_commandBufferCS);
c.deferredModeEnabled = false; c.deferredModeEnabled = false;
for (std::vector<Renderer::DeferredCBuff>::const_iterator it = c.deferredBuffers.begin(); it != c.deferredBuffers.end(); ++it) for (std::vector<Renderer::DeferredCBuff>::const_iterator it = c.deferredBuffers.begin(); it != c.deferredBuffers.end(); ++it)
@@ -683,7 +683,7 @@ void Renderer::CBuffDeferredModeEnd()
} }
c.deferredBuffers.clear(); c.deferredBuffers.clear();
LeaveCriticalSection(&rtl_critical_section100); LeaveCriticalSection(&m_commandBufferCS);
} }
void Renderer::CBuffDeferredModeStart() void Renderer::CBuffDeferredModeStart()
@@ -693,7 +693,7 @@ void Renderer::CBuffDeferredModeStart()
void Renderer::CBuffDelete(int first, int count) void Renderer::CBuffDelete(int first, int count)
{ {
EnterCriticalSection(&rtl_critical_section100); EnterCriticalSection(&m_commandBufferCS);
const int end = first + count; const int end = first + count;
for (int i = first; i < end; ++i) for (int i = first; i < end; ++i)
@@ -705,7 +705,7 @@ void Renderer::CBuffDelete(int first, int count)
m_commandHandleToIndex[i] = static_cast<std::int16_t>(-1); m_commandHandleToIndex[i] = static_cast<std::int16_t>(-1);
} }
LeaveCriticalSection(&rtl_critical_section100); LeaveCriticalSection(&m_commandBufferCS);
} }
void Renderer::CBuffEnd() void Renderer::CBuffEnd()
@@ -715,7 +715,7 @@ void Renderer::CBuffEnd()
assert(c.stackType == MATRIX_MODE_MODELVIEW_CBUFF); assert(c.stackType == MATRIX_MODE_MODELVIEW_CBUFF);
assert(c.stackPos[MATRIX_MODE_MODELVIEW_CBUFF] == 0); assert(c.stackPos[MATRIX_MODE_MODELVIEW_CBUFF] == 0);
EnterCriticalSection(&rtl_critical_section100); EnterCriticalSection(&m_commandBufferCS);
if (c.deferredModeEnabled) if (c.deferredModeEnabled)
{ {
@@ -751,7 +751,7 @@ void Renderer::CBuffEnd()
c.commandBuffer->EndRecording(m_pDevice); c.commandBuffer->EndRecording(m_pDevice);
c.commandBuffer = NULL; c.commandBuffer = NULL;
LeaveCriticalSection(&rtl_critical_section100); LeaveCriticalSection(&m_commandBufferCS);
} }
void Renderer::CBuffLockStaticCreations() void Renderer::CBuffLockStaticCreations()
@@ -765,11 +765,11 @@ int Renderer::CBuffSize(int index)
return totalAlloc < 0 ? 0 : totalAlloc; return totalAlloc < 0 ? 0 : totalAlloc;
unsigned int size = 0; unsigned int size = 0;
EnterCriticalSection(&rtl_critical_section100); EnterCriticalSection(&m_commandBufferCS);
const int commandIndex = m_commandHandleToIndex[index]; const int commandIndex = m_commandHandleToIndex[index];
if (commandIndex >= 0) if (commandIndex >= 0)
size = static_cast<unsigned int>(m_commandBuffers[commandIndex]->GetAllocated()); size = static_cast<unsigned int>(m_commandBuffers[commandIndex]->GetAllocated());
LeaveCriticalSection(&rtl_critical_section100); LeaveCriticalSection(&m_commandBufferCS);
return size; return size;
} }
@@ -789,7 +789,7 @@ void Renderer::CBuffStart(int index, bool full)
void Renderer::CBuffTick() void Renderer::CBuffTick()
{ {
EnterCriticalSection(&rtl_critical_section100); EnterCriticalSection(&m_commandBufferCS);
const int firstPending = MAX_COMMAND_BUFFERS - static_cast<int>(reservedRendererDword3); const int firstPending = MAX_COMMAND_BUFFERS - static_cast<int>(reservedRendererDword3);
for (int i = firstPending; i < MAX_COMMAND_BUFFERS; ++i) for (int i = firstPending; i < MAX_COMMAND_BUFFERS; ++i)
@@ -801,12 +801,12 @@ void Renderer::CBuffTick()
} }
reservedRendererDword3 = 0; reservedRendererDword3 = 0;
LeaveCriticalSection(&rtl_critical_section100); LeaveCriticalSection(&m_commandBufferCS);
} }
void Renderer::DeleteInternalBuffer(int index) void Renderer::DeleteInternalBuffer(int index)
{ {
EnterCriticalSection(&rtl_critical_section100); EnterCriticalSection(&m_commandBufferCS);
++reservedRendererDword3; ++reservedRendererDword3;
const int recycledSlot = MAX_COMMAND_BUFFERS - static_cast<int>(reservedRendererDword3); const int recycledSlot = MAX_COMMAND_BUFFERS - static_cast<int>(reservedRendererDword3);
@@ -828,5 +828,5 @@ void Renderer::DeleteInternalBuffer(int index)
m_commandIndexToHandle[index] = commandIndex; m_commandIndexToHandle[index] = commandIndex;
} }
LeaveCriticalSection(&rtl_critical_section100); LeaveCriticalSection(&m_commandBufferCS);
} }
+1 -1
View File
@@ -488,7 +488,7 @@ void Renderer::Initialise(ID3D11Device *pDevice, IDXGISwapChain *pSwapChain)
StateSetVertexTextureUV(0.0f, 0.0f); StateSetVertexTextureUV(0.0f, 0.0f);
TextureBindVertex(-1); TextureBindVertex(-1);
InitializeCriticalSection(&rtl_critical_section100); InitializeCriticalSection(&m_commandBufferCS);
reservedRendererDword1 = 0; reservedRendererDword1 = 0;
activeVertexType = -1; activeVertexType = -1;