d3d12: Fix crash + use ref instead of copying in some for loops

This commit is contained in:
vlj 2015-06-25 18:34:47 +02:00 committed by Vincent Lejeune
commit 2c802735bd
2 changed files with 16 additions and 16 deletions

View file

@ -485,7 +485,7 @@ void D3D12GSRender::FillVertexShaderConstantsBuffer()
void *constantsBufferMap; void *constantsBufferMap;
check(m_constantsData.m_heap->Map(0, &range, &constantsBufferMap)); check(m_constantsData.m_heap->Map(0, &range, &constantsBufferMap));
for (auto vertexConstants : m_vertexConstants) for (const auto &vertexConstants : m_vertexConstants)
{ {
float data[4] = { float data[4] = {
vertexConstants.second.x, vertexConstants.second.x,

View file

@ -79,13 +79,13 @@ void D3D12GSRender::ResourceStorage::Reset()
m_frameFinishedFence = nullptr; m_frameFinishedFence = nullptr;
m_frameFinishedHandle = 0; m_frameFinishedHandle = 0;
for (auto tmp : m_inUseConstantsBuffers) for (auto &tmp : m_inUseConstantsBuffers)
SAFE_RELEASE(std::get<2>(tmp)); SAFE_RELEASE(std::get<2>(tmp));
for (auto tmp : m_inUseVertexIndexBuffers) for (auto &tmp : m_inUseVertexIndexBuffers)
SAFE_RELEASE(std::get<2>(tmp)); SAFE_RELEASE(std::get<2>(tmp));
for (auto tmp : m_inUseTextureUploadBuffers) for (auto &tmp : m_inUseTextureUploadBuffers)
SAFE_RELEASE(std::get<2>(tmp)); SAFE_RELEASE(std::get<2>(tmp));
for (auto tmp : m_inUseTexture2D) for (auto &tmp : m_inUseTexture2D)
SAFE_RELEASE(std::get<2>(tmp)); SAFE_RELEASE(std::get<2>(tmp));
m_inUseConstantsBuffers.clear(); m_inUseConstantsBuffers.clear();
m_inUseVertexIndexBuffers.clear(); m_inUseVertexIndexBuffers.clear();
@ -138,22 +138,22 @@ void D3D12GSRender::ResourceStorage::Init(ID3D12Device *device)
void D3D12GSRender::ResourceStorage::Release() void D3D12GSRender::ResourceStorage::Release()
{ {
// NOTE: Should be released only if no command are in flight ! // NOTE: Should be released only if no command are in flight !
for (auto tmp : m_inUseConstantsBuffers) for (auto &tmp : m_inUseConstantsBuffers)
SAFE_RELEASE(std::get<2>(tmp)); SAFE_RELEASE(std::get<2>(tmp));
for (auto tmp : m_inUseVertexIndexBuffers) for (auto &tmp : m_inUseVertexIndexBuffers)
SAFE_RELEASE(std::get<2>(tmp)); SAFE_RELEASE(std::get<2>(tmp));
for (auto tmp : m_inUseTextureUploadBuffers) for (auto &tmp : m_inUseTextureUploadBuffers)
SAFE_RELEASE(std::get<2>(tmp)); SAFE_RELEASE(std::get<2>(tmp));
for (auto tmp : m_inUseTexture2D) for (auto &tmp : m_inUseTexture2D)
SAFE_RELEASE(std::get<2>(tmp)); SAFE_RELEASE(std::get<2>(tmp));
m_constantsBufferDescriptorsHeap->Release(); m_constantsBufferDescriptorsHeap->Release();
m_scaleOffsetDescriptorHeap->Release(); m_scaleOffsetDescriptorHeap->Release();
for (auto tmp : m_inflightResources) for (auto &tmp : m_inflightResources)
tmp->Release(); tmp->Release();
m_textureDescriptorsHeap->Release(); m_textureDescriptorsHeap->Release();
m_samplerDescriptorHeap->Release(); m_samplerDescriptorHeap->Release();
for (auto tmp : m_inflightCommandList) for (auto &tmp : m_inflightCommandList)
tmp->Release(); tmp->Release();
m_commandAllocator->Release(); m_commandAllocator->Release();
m_textureUploadCommandAllocator->Release(); m_textureUploadCommandAllocator->Release();
@ -546,7 +546,7 @@ D3D12GSRender::D3D12GSRender()
m_perFrameStorage[1].Reset(); m_perFrameStorage[1].Reset();
// Convert shader // Convert shader
auto p = compileF32toU8CS(); const auto &p = compileF32toU8CS();
check( check(
m_device->CreateRootSignature(0, p.second->GetBufferPointer(), p.second->GetBufferSize(), IID_PPV_ARGS(&m_convertRootSignature)) m_device->CreateRootSignature(0, p.second->GetBufferPointer(), p.second->GetBufferSize(), IID_PPV_ARGS(&m_convertRootSignature))
); );
@ -609,9 +609,9 @@ D3D12GSRender::~D3D12GSRender()
m_rtts.Release(); m_rtts.Release();
for (unsigned i = 0; i < 17; i++) for (unsigned i = 0; i < 17; i++)
m_rootSignatures[i]->Release(); m_rootSignatures[i]->Release();
for (auto tmp : m_texToClean) for (auto &tmp : m_texToClean)
tmp->Release(); tmp->Release();
for (auto tmp : m_texturesCache) for (auto &tmp : m_texturesCache)
tmp.second->Release(); tmp.second->Release();
m_swapChain->Release(); m_swapChain->Release();
m_outputScalingPass.Release(); m_outputScalingPass.Release();
@ -1072,8 +1072,8 @@ void D3D12GSRender::Flip()
CloseHandle(storage.m_frameFinishedHandle); CloseHandle(storage.m_frameFinishedHandle);
storage.m_frameFinishedFence->Release(); storage.m_frameFinishedFence->Release();
for (unsigned i = 0; i < 4; i++) for (auto &cleanFunc : cleaningFunction)
cleaningFunction[i](); cleanFunc();
storage.Reset(); storage.Reset();
for (auto tmp : textoclean) for (auto tmp : textoclean)