mirror of
https://git.neolegacy.dev/neoStudiosLCE/4JLibs.git
synced 2026-12-02 22:18:12 +01:00
fixed a logic bug in rendering
the old code has a major problem where it tried to memcpy data after unmaping which in some cases results in unexpected crashes as mapped.pData may point to invalid memory after unmaping Signed-off-by: 3makJoud <5+3makjoud@noreply.neolegacy.dev>
This commit is contained in:
1 parent
78ce519776
commit
fa93d9ac8a
1 file changed
+12
-6
@@ -677,13 +677,19 @@ void Renderer::UpdateLightingState()
|
||||
|
||||
void Renderer::UpdateTexGenState()
|
||||
{
|
||||
PROFILER_SCOPE("Renderer::UpdateTexGenState", "UpdateTexGenState", MP_ORCHID1);
|
||||
Context &c = getContext();
|
||||
PROFILER_SCOPE("Renderer::UpdateTexGenState", "UpdateTexGenState", MP_ORCHID1);
|
||||
Context &c = getContext();
|
||||
|
||||
D3D11_MAPPED_SUBRESOURCE mapped = {};
|
||||
c.m_pDeviceContext->Map(c.m_texGenMatricesBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped);
|
||||
c.m_pDeviceContext->Unmap(c.m_texGenMatricesBuffer, 0);
|
||||
std::memcpy(mapped.pData, c.texGenMatrices, sizeof(c.texGenMatrices));
|
||||
D3D11_MAPPED_SUBRESOURCE mapped = {};
|
||||
HRESULT hr = c.m_pDeviceContext->Map(c.m_texGenMatricesBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped);
|
||||
// @CDevJoud
|
||||
// the old code has a major problem where it tried to memcpy data after unmaping which
|
||||
// in some cases results in unexpected crashes as mapped.pData may point to invalid memory
|
||||
// after unmaping
|
||||
if (SUCCEEDED(hr)) {
|
||||
std::memcpy(mapped.pData, c.texGenMatrices, sizeof(c.texGenMatrices));
|
||||
c.m_pDeviceContext->Unmap(c.m_texGenMatricesBuffer, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user