d3d12: Submit command list every draw call in debug mode

This commit is contained in:
Vincent Lejeune 2015-09-15 14:38:37 +02:00
parent 7d15cc0dfd
commit bf04758285
2 changed files with 108 additions and 104 deletions

View file

@ -102,8 +102,7 @@ void D3D12GSRender::ResourceStorage::Reset()
m_currentSamplerIndex = 0; m_currentSamplerIndex = 0;
m_samplerDescriptorHeapIndex = 0; m_samplerDescriptorHeapIndex = 0;
m_commandAllocator->Reset(); ThrowIfFailed(m_commandAllocator->Reset());
m_nextAvailableCommandListIndex = 0;
setNewCommandList(); setNewCommandList();
m_singleFrameLifetimeResources.clear(); m_singleFrameLifetimeResources.clear();
@ -111,19 +110,7 @@ void D3D12GSRender::ResourceStorage::Reset()
void D3D12GSRender::ResourceStorage::setNewCommandList() void D3D12GSRender::ResourceStorage::setNewCommandList()
{ {
if (m_availableCommandLists.size() > m_nextAvailableCommandListIndex) ThrowIfFailed(m_commandList->Reset(m_commandAllocator.Get(), nullptr));
{
m_currentCommandList = m_availableCommandLists[m_nextAvailableCommandListIndex].Get();
m_currentCommandList->Reset(m_commandAllocator.Get(), nullptr);
}
else
{
ComPtr<ID3D12GraphicsCommandList> commandList;
ThrowIfFailed(m_device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, m_commandAllocator.Get(), nullptr, IID_PPV_ARGS(commandList.GetAddressOf())));
m_availableCommandLists.push_back(commandList);
m_currentCommandList = m_availableCommandLists.back().Get();
}
m_nextAvailableCommandListIndex++;
} }
void D3D12GSRender::ResourceStorage::Init(ID3D12Device *device) void D3D12GSRender::ResourceStorage::Init(ID3D12Device *device)
@ -133,6 +120,9 @@ void D3D12GSRender::ResourceStorage::Init(ID3D12Device *device)
// Create a global command allocator // Create a global command allocator
ThrowIfFailed(device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(m_commandAllocator.GetAddressOf()))); ThrowIfFailed(device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(m_commandAllocator.GetAddressOf())));
ThrowIfFailed(m_device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, m_commandAllocator.Get(), nullptr, IID_PPV_ARGS(m_commandList.GetAddressOf())));
ThrowIfFailed(m_commandList->Close());
D3D12_DESCRIPTOR_HEAP_DESC descriptorHeapDesc = {}; D3D12_DESCRIPTOR_HEAP_DESC descriptorHeapDesc = {};
descriptorHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE; descriptorHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;
descriptorHeapDesc.NumDescriptors = 10000; // For safety descriptorHeapDesc.NumDescriptors = 10000; // For safety
@ -164,7 +154,10 @@ void D3D12GSRender::ResourceStorage::Init(ID3D12Device *device)
void D3D12GSRender::ResourceStorage::WaitAndClean(const std::vector<ID3D12Resource *> &dirtyTextures) void D3D12GSRender::ResourceStorage::WaitAndClean(const std::vector<ID3D12Resource *> &dirtyTextures)
{ {
WaitForSingleObjectEx(m_frameFinishedHandle, INFINITE, FALSE); if (!m_isUseable)
WaitForSingleObjectEx(m_frameFinishedHandle, INFINITE, FALSE);
else
ThrowIfFailed(m_commandList->Close());
Reset(); Reset();
@ -178,7 +171,6 @@ void D3D12GSRender::ResourceStorage::WaitAndClean(const std::vector<ID3D12Resour
void D3D12GSRender::ResourceStorage::Release() void D3D12GSRender::ResourceStorage::Release()
{ {
// NOTE: Should be released only after gfx pipeline last command has been finished. // NOTE: Should be released only after gfx pipeline last command has been finished.
m_availableCommandLists.clear();
CloseHandle(m_frameFinishedHandle); CloseHandle(m_frameFinishedHandle);
} }
@ -452,10 +444,10 @@ void D3D12GSRender::OnReset()
void D3D12GSRender::Clear(u32 cmd) void D3D12GSRender::Clear(u32 cmd)
{ {
std::chrono::time_point<std::chrono::system_clock> startDuration = std::chrono::system_clock::now(); std::chrono::time_point<std::chrono::system_clock> startDuration = std::chrono::system_clock::now();
PrepareRenderTargets(getCurrentResourceStorage().m_currentCommandList); PrepareRenderTargets(getCurrentResourceStorage().m_commandList.Get());
assert(cmd == NV4097_CLEAR_SURFACE); assert(cmd == NV4097_CLEAR_SURFACE);
PrepareRenderTargets(getCurrentResourceStorage().m_currentCommandList); PrepareRenderTargets(getCurrentResourceStorage().m_commandList.Get());
/* if (m_set_color_mask) /* if (m_set_color_mask)
{ {
@ -473,11 +465,11 @@ void D3D12GSRender::Clear(u32 cmd)
if (m_clear_surface_mask & 0x1) if (m_clear_surface_mask & 0x1)
{ {
u32 max_depth_value = m_surface_depth_format == CELL_GCM_SURFACE_Z16 ? 0x0000ffff : 0x00ffffff; u32 max_depth_value = m_surface_depth_format == CELL_GCM_SURFACE_Z16 ? 0x0000ffff : 0x00ffffff;
getCurrentResourceStorage().m_currentCommandList->ClearDepthStencilView(m_rtts.m_depthStencilDescriptorHeap->GetCPUDescriptorHandleForHeapStart(), D3D12_CLEAR_FLAG_DEPTH, m_clear_surface_z / (float)max_depth_value, 0, 0, nullptr); getCurrentResourceStorage().m_commandList->ClearDepthStencilView(m_rtts.m_depthStencilDescriptorHeap->GetCPUDescriptorHandleForHeapStart(), D3D12_CLEAR_FLAG_DEPTH, m_clear_surface_z / (float)max_depth_value, 0, 0, nullptr);
} }
if (m_clear_surface_mask & 0x2) if (m_clear_surface_mask & 0x2)
getCurrentResourceStorage().m_currentCommandList->ClearDepthStencilView(m_rtts.m_depthStencilDescriptorHeap->GetCPUDescriptorHandleForHeapStart(), D3D12_CLEAR_FLAG_STENCIL, 0.f, m_clear_surface_s, 0, nullptr); getCurrentResourceStorage().m_commandList->ClearDepthStencilView(m_rtts.m_depthStencilDescriptorHeap->GetCPUDescriptorHandleForHeapStart(), D3D12_CLEAR_FLAG_STENCIL, 0.f, m_clear_surface_s, 0, nullptr);
if (m_clear_surface_mask & 0xF0) if (m_clear_surface_mask & 0xF0)
{ {
@ -497,26 +489,26 @@ void D3D12GSRender::Clear(u32 cmd)
case CELL_GCM_SURFACE_TARGET_0: case CELL_GCM_SURFACE_TARGET_0:
case CELL_GCM_SURFACE_TARGET_1: case CELL_GCM_SURFACE_TARGET_1:
getCurrentResourceStorage().m_currentCommandList->ClearRenderTargetView(getCPUDescriptorHandle(m_rtts.m_renderTargetsDescriptorsHeap, 0), clearColor, 0, nullptr); getCurrentResourceStorage().m_commandList->ClearRenderTargetView(getCPUDescriptorHandle(m_rtts.m_renderTargetsDescriptorsHeap, 0), clearColor, 0, nullptr);
break; break;
case CELL_GCM_SURFACE_TARGET_MRT1: case CELL_GCM_SURFACE_TARGET_MRT1:
getCurrentResourceStorage().m_currentCommandList->ClearRenderTargetView(getCPUDescriptorHandle(m_rtts.m_renderTargetsDescriptorsHeap, 0), clearColor, 0, nullptr); getCurrentResourceStorage().m_commandList->ClearRenderTargetView(getCPUDescriptorHandle(m_rtts.m_renderTargetsDescriptorsHeap, 0), clearColor, 0, nullptr);
getCurrentResourceStorage().m_currentCommandList->ClearRenderTargetView(getCPUDescriptorHandle(m_rtts.m_renderTargetsDescriptorsHeap, g_descriptorStrideRTV), clearColor, 0, nullptr); getCurrentResourceStorage().m_commandList->ClearRenderTargetView(getCPUDescriptorHandle(m_rtts.m_renderTargetsDescriptorsHeap, g_descriptorStrideRTV), clearColor, 0, nullptr);
break; break;
case CELL_GCM_SURFACE_TARGET_MRT2: case CELL_GCM_SURFACE_TARGET_MRT2:
getCurrentResourceStorage().m_currentCommandList->ClearRenderTargetView(getCPUDescriptorHandle(m_rtts.m_renderTargetsDescriptorsHeap, 0), clearColor, 0, nullptr); getCurrentResourceStorage().m_commandList->ClearRenderTargetView(getCPUDescriptorHandle(m_rtts.m_renderTargetsDescriptorsHeap, 0), clearColor, 0, nullptr);
getCurrentResourceStorage().m_currentCommandList->ClearRenderTargetView(getCPUDescriptorHandle(m_rtts.m_renderTargetsDescriptorsHeap, g_descriptorStrideRTV), clearColor, 0, nullptr); getCurrentResourceStorage().m_commandList->ClearRenderTargetView(getCPUDescriptorHandle(m_rtts.m_renderTargetsDescriptorsHeap, g_descriptorStrideRTV), clearColor, 0, nullptr);
handle.ptr += g_RTTIncrement; handle.ptr += g_RTTIncrement;
getCurrentResourceStorage().m_currentCommandList->ClearRenderTargetView(getCPUDescriptorHandle(m_rtts.m_renderTargetsDescriptorsHeap, 2 * g_descriptorStrideRTV), clearColor, 0, nullptr); getCurrentResourceStorage().m_commandList->ClearRenderTargetView(getCPUDescriptorHandle(m_rtts.m_renderTargetsDescriptorsHeap, 2 * g_descriptorStrideRTV), clearColor, 0, nullptr);
break; break;
case CELL_GCM_SURFACE_TARGET_MRT3: case CELL_GCM_SURFACE_TARGET_MRT3:
getCurrentResourceStorage().m_currentCommandList->ClearRenderTargetView(getCPUDescriptorHandle(m_rtts.m_renderTargetsDescriptorsHeap, 0), clearColor, 0, nullptr); getCurrentResourceStorage().m_commandList->ClearRenderTargetView(getCPUDescriptorHandle(m_rtts.m_renderTargetsDescriptorsHeap, 0), clearColor, 0, nullptr);
handle.ptr += g_RTTIncrement; handle.ptr += g_RTTIncrement;
getCurrentResourceStorage().m_currentCommandList->ClearRenderTargetView(getCPUDescriptorHandle(m_rtts.m_renderTargetsDescriptorsHeap, g_descriptorStrideRTV), clearColor, 0, nullptr); getCurrentResourceStorage().m_commandList->ClearRenderTargetView(getCPUDescriptorHandle(m_rtts.m_renderTargetsDescriptorsHeap, g_descriptorStrideRTV), clearColor, 0, nullptr);
handle.ptr += g_RTTIncrement; handle.ptr += g_RTTIncrement;
getCurrentResourceStorage().m_currentCommandList->ClearRenderTargetView(getCPUDescriptorHandle(m_rtts.m_renderTargetsDescriptorsHeap, 2 * g_descriptorStrideRTV), clearColor, 0, nullptr); getCurrentResourceStorage().m_commandList->ClearRenderTargetView(getCPUDescriptorHandle(m_rtts.m_renderTargetsDescriptorsHeap, 2 * g_descriptorStrideRTV), clearColor, 0, nullptr);
handle.ptr += g_RTTIncrement; handle.ptr += g_RTTIncrement;
getCurrentResourceStorage().m_currentCommandList->ClearRenderTargetView(getCPUDescriptorHandle(m_rtts.m_renderTargetsDescriptorsHeap, 3 * g_descriptorStrideRTV), clearColor, 0, nullptr); getCurrentResourceStorage().m_commandList->ClearRenderTargetView(getCPUDescriptorHandle(m_rtts.m_renderTargetsDescriptorsHeap, 3 * g_descriptorStrideRTV), clearColor, 0, nullptr);
break; break;
default: default:
LOG_ERROR(RSX, "Bad surface color target: %d", m_surface_color_target); LOG_ERROR(RSX, "Bad surface color target: %d", m_surface_color_target);
@ -526,12 +518,19 @@ void D3D12GSRender::Clear(u32 cmd)
std::chrono::time_point<std::chrono::system_clock> endDuration = std::chrono::system_clock::now(); std::chrono::time_point<std::chrono::system_clock> endDuration = std::chrono::system_clock::now();
m_timers.m_drawCallDuration += std::chrono::duration_cast<std::chrono::microseconds>(endDuration - startDuration).count(); m_timers.m_drawCallDuration += std::chrono::duration_cast<std::chrono::microseconds>(endDuration - startDuration).count();
m_timers.m_drawCallCount++; m_timers.m_drawCallCount++;
if (Ini.GSDebugOutputEnable.GetValue())
{
ThrowIfFailed(getCurrentResourceStorage().m_commandList->Close());
m_commandQueueGraphic->ExecuteCommandLists(1, (ID3D12CommandList**)getCurrentResourceStorage().m_commandList.GetAddressOf());
getCurrentResourceStorage().setNewCommandList();
}
} }
void D3D12GSRender::Draw() void D3D12GSRender::Draw()
{ {
std::chrono::time_point<std::chrono::system_clock> startDuration = std::chrono::system_clock::now(); std::chrono::time_point<std::chrono::system_clock> startDuration = std::chrono::system_clock::now();
PrepareRenderTargets(getCurrentResourceStorage().m_currentCommandList); PrepareRenderTargets(getCurrentResourceStorage().m_commandList.Get());
// Init vertex count // Init vertex count
// TODO: Very hackish, clean this // TODO: Very hackish, clean this
@ -563,9 +562,9 @@ void D3D12GSRender::Draw()
{ {
const std::vector<D3D12_VERTEX_BUFFER_VIEW> &vertexBufferViews = UploadVertexBuffers(m_indexed_array.m_count ? true : false); const std::vector<D3D12_VERTEX_BUFFER_VIEW> &vertexBufferViews = UploadVertexBuffers(m_indexed_array.m_count ? true : false);
const D3D12_INDEX_BUFFER_VIEW &indexBufferView = uploadIndexBuffers(m_indexed_array.m_count ? true : false); const D3D12_INDEX_BUFFER_VIEW &indexBufferView = uploadIndexBuffers(m_indexed_array.m_count ? true : false);
getCurrentResourceStorage().m_currentCommandList->IASetVertexBuffers(0, (UINT)vertexBufferViews.size(), vertexBufferViews.data()); getCurrentResourceStorage().m_commandList->IASetVertexBuffers(0, (UINT)vertexBufferViews.size(), vertexBufferViews.data());
if (m_renderingInfo.m_indexed) if (m_renderingInfo.m_indexed)
getCurrentResourceStorage().m_currentCommandList->IASetIndexBuffer(&indexBufferView); getCurrentResourceStorage().m_commandList->IASetIndexBuffer(&indexBufferView);
} }
if (!LoadProgram()) if (!LoadProgram())
@ -575,13 +574,13 @@ void D3D12GSRender::Draw()
return; return;
} }
getCurrentResourceStorage().m_currentCommandList->SetGraphicsRootSignature(m_rootSignatures[m_PSO->second].Get()); getCurrentResourceStorage().m_commandList->SetGraphicsRootSignature(m_rootSignatures[m_PSO->second].Get());
getCurrentResourceStorage().m_currentCommandList->OMSetStencilRef(m_stencil_func_ref); getCurrentResourceStorage().m_commandList->OMSetStencilRef(m_stencil_func_ref);
// Constants // Constants
setScaleOffset(); setScaleOffset();
getCurrentResourceStorage().m_currentCommandList->SetDescriptorHeaps(1, getCurrentResourceStorage().m_scaleOffsetDescriptorHeap.GetAddressOf()); getCurrentResourceStorage().m_commandList->SetDescriptorHeaps(1, getCurrentResourceStorage().m_scaleOffsetDescriptorHeap.GetAddressOf());
getCurrentResourceStorage().m_currentCommandList->SetGraphicsRootDescriptorTable(0, getCurrentResourceStorage().m_commandList->SetGraphicsRootDescriptorTable(0,
getGPUDescriptorHandle(getCurrentResourceStorage().m_scaleOffsetDescriptorHeap.Get(), getGPUDescriptorHandle(getCurrentResourceStorage().m_scaleOffsetDescriptorHeap.Get(),
getCurrentResourceStorage().m_currentScaleOffsetBufferIndex * g_descriptorStrideSRVCBVUAV) getCurrentResourceStorage().m_currentScaleOffsetBufferIndex * g_descriptorStrideSRVCBVUAV)
); );
@ -593,16 +592,16 @@ void D3D12GSRender::Draw()
FillPixelShaderConstantsBuffer(); FillPixelShaderConstantsBuffer();
getCurrentResourceStorage().m_constantsBufferIndex++; getCurrentResourceStorage().m_constantsBufferIndex++;
getCurrentResourceStorage().m_currentCommandList->SetDescriptorHeaps(1, getCurrentResourceStorage().m_constantsBufferDescriptorsHeap.GetAddressOf()); getCurrentResourceStorage().m_commandList->SetDescriptorHeaps(1, getCurrentResourceStorage().m_constantsBufferDescriptorsHeap.GetAddressOf());
getCurrentResourceStorage().m_currentCommandList->SetGraphicsRootDescriptorTable(1, getCurrentResourceStorage().m_commandList->SetGraphicsRootDescriptorTable(1,
getGPUDescriptorHandle(getCurrentResourceStorage().m_constantsBufferDescriptorsHeap.Get(), getGPUDescriptorHandle(getCurrentResourceStorage().m_constantsBufferDescriptorsHeap.Get(),
currentBufferIndex * g_descriptorStrideSRVCBVUAV) currentBufferIndex * g_descriptorStrideSRVCBVUAV)
); );
getCurrentResourceStorage().m_currentCommandList->SetPipelineState(m_PSO->first); getCurrentResourceStorage().m_commandList->SetPipelineState(m_PSO->first);
if (m_PSO->second > 0) if (m_PSO->second > 0)
{ {
size_t usedTexture = UploadTextures(getCurrentResourceStorage().m_currentCommandList); size_t usedTexture = UploadTextures(getCurrentResourceStorage().m_commandList.Get());
// Fill empty slots // Fill empty slots
for (; usedTexture < m_PSO->second; usedTexture++) for (; usedTexture < m_PSO->second; usedTexture++)
@ -632,14 +631,14 @@ void D3D12GSRender::Draw()
); );
} }
getCurrentResourceStorage().m_currentCommandList->SetDescriptorHeaps(1, getCurrentResourceStorage().m_textureDescriptorsHeap.GetAddressOf()); getCurrentResourceStorage().m_commandList->SetDescriptorHeaps(1, getCurrentResourceStorage().m_textureDescriptorsHeap.GetAddressOf());
getCurrentResourceStorage().m_currentCommandList->SetGraphicsRootDescriptorTable(2, getCurrentResourceStorage().m_commandList->SetGraphicsRootDescriptorTable(2,
getGPUDescriptorHandle(getCurrentResourceStorage().m_textureDescriptorsHeap.Get(), getGPUDescriptorHandle(getCurrentResourceStorage().m_textureDescriptorsHeap.Get(),
getCurrentResourceStorage().m_currentTextureIndex * g_descriptorStrideSRVCBVUAV) getCurrentResourceStorage().m_currentTextureIndex * g_descriptorStrideSRVCBVUAV)
); );
getCurrentResourceStorage().m_currentCommandList->SetDescriptorHeaps(1, getCurrentResourceStorage().m_samplerDescriptorHeap[getCurrentResourceStorage().m_samplerDescriptorHeapIndex].GetAddressOf()); getCurrentResourceStorage().m_commandList->SetDescriptorHeaps(1, getCurrentResourceStorage().m_samplerDescriptorHeap[getCurrentResourceStorage().m_samplerDescriptorHeapIndex].GetAddressOf());
getCurrentResourceStorage().m_currentCommandList->SetGraphicsRootDescriptorTable(3, getCurrentResourceStorage().m_commandList->SetGraphicsRootDescriptorTable(3,
getGPUDescriptorHandle(getCurrentResourceStorage().m_samplerDescriptorHeap[getCurrentResourceStorage().m_samplerDescriptorHeapIndex].Get(), getGPUDescriptorHandle(getCurrentResourceStorage().m_samplerDescriptorHeap[getCurrentResourceStorage().m_samplerDescriptorHeapIndex].Get(),
getCurrentResourceStorage().m_currentSamplerIndex * g_descriptorStrideSamplers) getCurrentResourceStorage().m_currentSamplerIndex * g_descriptorStrideSamplers)
); );
@ -669,7 +668,7 @@ void D3D12GSRender::Draw()
LOG_ERROR(RSX, "Bad surface color target: %d", m_surface_color_target); LOG_ERROR(RSX, "Bad surface color target: %d", m_surface_color_target);
} }
getCurrentResourceStorage().m_currentCommandList->OMSetRenderTargets((UINT)numRTT, &m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart(), true, getCurrentResourceStorage().m_commandList->OMSetRenderTargets((UINT)numRTT, &m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart(), true,
&getCPUDescriptorHandle(m_rtts.m_depthStencilDescriptorHeap, 0)); &getCPUDescriptorHandle(m_rtts.m_depthStencilDescriptorHeap, 0));
D3D12_VIEWPORT viewport = D3D12_VIEWPORT viewport =
@ -681,7 +680,7 @@ void D3D12GSRender::Draw()
-1.f, -1.f,
1.f 1.f
}; };
getCurrentResourceStorage().m_currentCommandList->RSSetViewports(1, &viewport); getCurrentResourceStorage().m_commandList->RSSetViewports(1, &viewport);
D3D12_RECT box = D3D12_RECT box =
{ {
@ -690,49 +689,56 @@ void D3D12GSRender::Draw()
(LONG)m_surface_clip_w, (LONG)m_surface_clip_w,
(LONG)m_surface_clip_h, (LONG)m_surface_clip_h,
}; };
getCurrentResourceStorage().m_currentCommandList->RSSetScissorRects(1, &box); getCurrentResourceStorage().m_commandList->RSSetScissorRects(1, &box);
switch (m_draw_mode - 1) switch (m_draw_mode - 1)
{ {
case GL_POINTS: case GL_POINTS:
getCurrentResourceStorage().m_currentCommandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_POINTLIST); getCurrentResourceStorage().m_commandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_POINTLIST);
break; break;
case GL_LINES: case GL_LINES:
getCurrentResourceStorage().m_currentCommandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_LINELIST); getCurrentResourceStorage().m_commandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_LINELIST);
break; break;
case GL_LINE_LOOP: case GL_LINE_LOOP:
getCurrentResourceStorage().m_currentCommandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_LINELIST_ADJ); getCurrentResourceStorage().m_commandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_LINELIST_ADJ);
break; break;
case GL_LINE_STRIP: case GL_LINE_STRIP:
getCurrentResourceStorage().m_currentCommandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_LINESTRIP); getCurrentResourceStorage().m_commandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_LINESTRIP);
break; break;
case GL_TRIANGLES: case GL_TRIANGLES:
getCurrentResourceStorage().m_currentCommandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); getCurrentResourceStorage().m_commandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
break; break;
case GL_TRIANGLE_STRIP: case GL_TRIANGLE_STRIP:
getCurrentResourceStorage().m_currentCommandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); getCurrentResourceStorage().m_commandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
break; break;
case GL_TRIANGLE_FAN: case GL_TRIANGLE_FAN:
case GL_QUADS: case GL_QUADS:
getCurrentResourceStorage().m_currentCommandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); getCurrentResourceStorage().m_commandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
break; break;
case GL_QUAD_STRIP: case GL_QUAD_STRIP:
case GL_POLYGON: case GL_POLYGON:
default: default:
getCurrentResourceStorage().m_currentCommandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); getCurrentResourceStorage().m_commandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
LOG_ERROR(RSX, "Unsupported primitive type"); LOG_ERROR(RSX, "Unsupported primitive type");
break; break;
} }
if (m_renderingInfo.m_indexed) if (m_renderingInfo.m_indexed)
getCurrentResourceStorage().m_currentCommandList->DrawIndexedInstanced((UINT)m_renderingInfo.m_count, 1, 0, (UINT)m_renderingInfo.m_baseVertex, 0); getCurrentResourceStorage().m_commandList->DrawIndexedInstanced((UINT)m_renderingInfo.m_count, 1, 0, (UINT)m_renderingInfo.m_baseVertex, 0);
else else
getCurrentResourceStorage().m_currentCommandList->DrawInstanced((UINT)m_renderingInfo.m_count, 1, (UINT)m_renderingInfo.m_baseVertex, 0); getCurrentResourceStorage().m_commandList->DrawInstanced((UINT)m_renderingInfo.m_count, 1, (UINT)m_renderingInfo.m_baseVertex, 0);
m_indexed_array.Reset(); m_indexed_array.Reset();
std::chrono::time_point<std::chrono::system_clock> endDuration = std::chrono::system_clock::now(); std::chrono::time_point<std::chrono::system_clock> endDuration = std::chrono::system_clock::now();
m_timers.m_drawCallDuration += std::chrono::duration_cast<std::chrono::microseconds>(endDuration - startDuration).count(); m_timers.m_drawCallDuration += std::chrono::duration_cast<std::chrono::microseconds>(endDuration - startDuration).count();
m_timers.m_drawCallCount++; m_timers.m_drawCallCount++;
if (Ini.GSDebugOutputEnable.GetValue())
{
ThrowIfFailed(getCurrentResourceStorage().m_commandList->Close());
m_commandQueueGraphic->ExecuteCommandLists(1, (ID3D12CommandList**)getCurrentResourceStorage().m_commandList.GetAddressOf());
getCurrentResourceStorage().setNewCommandList();
}
} }
static bool static bool
@ -818,20 +824,20 @@ void D3D12GSRender::Flip()
src.PlacedFootprint.Footprint.Height = (UINT)h; src.PlacedFootprint.Footprint.Height = (UINT)h;
src.PlacedFootprint.Footprint.Depth = (UINT)1; src.PlacedFootprint.Footprint.Depth = (UINT)1;
src.PlacedFootprint.Footprint.RowPitch = (UINT)rowPitch; src.PlacedFootprint.Footprint.RowPitch = (UINT)rowPitch;
getCurrentResourceStorage().m_currentCommandList->CopyTextureRegion(&dst, 0, 0, 0, &src, nullptr); getCurrentResourceStorage().m_commandList->CopyTextureRegion(&dst, 0, 0, 0, &src, nullptr);
getCurrentResourceStorage().m_currentCommandList->ResourceBarrier(1, &getResourceBarrierTransition(storage.m_RAMFramebuffer.Get(), D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_GENERIC_READ)); getCurrentResourceStorage().m_commandList->ResourceBarrier(1, &getResourceBarrierTransition(storage.m_RAMFramebuffer.Get(), D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_GENERIC_READ));
resourceToFlip = storage.m_RAMFramebuffer.Get(); resourceToFlip = storage.m_RAMFramebuffer.Get();
viewport_w = (float)w, viewport_h = (float)h; viewport_w = (float)w, viewport_h = (float)h;
} }
else else
{ {
if (m_rtts.m_currentlyBoundRenderTargets[0] != nullptr) if (m_rtts.m_currentlyBoundRenderTargets[0] != nullptr)
getCurrentResourceStorage().m_currentCommandList->ResourceBarrier(1, &getResourceBarrierTransition(m_rtts.m_currentlyBoundRenderTargets[0], D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_GENERIC_READ)); getCurrentResourceStorage().m_commandList->ResourceBarrier(1, &getResourceBarrierTransition(m_rtts.m_currentlyBoundRenderTargets[0], D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_GENERIC_READ));
resourceToFlip = m_rtts.m_currentlyBoundRenderTargets[0]; resourceToFlip = m_rtts.m_currentlyBoundRenderTargets[0];
} }
getCurrentResourceStorage().m_currentCommandList->ResourceBarrier(1, &getResourceBarrierTransition(m_backBuffer[m_swapChain->GetCurrentBackBufferIndex()].Get(), D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_RENDER_TARGET)); getCurrentResourceStorage().m_commandList->ResourceBarrier(1, &getResourceBarrierTransition(m_backBuffer[m_swapChain->GetCurrentBackBufferIndex()].Get(), D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_RENDER_TARGET));
D3D12_VIEWPORT viewport = D3D12_VIEWPORT viewport =
{ {
@ -842,7 +848,7 @@ void D3D12GSRender::Flip()
0.f, 0.f,
1.f 1.f
}; };
getCurrentResourceStorage().m_currentCommandList->RSSetViewports(1, &viewport); getCurrentResourceStorage().m_commandList->RSSetViewports(1, &viewport);
D3D12_RECT box = D3D12_RECT box =
{ {
@ -851,9 +857,9 @@ void D3D12GSRender::Flip()
(LONG)m_backBuffer[m_swapChain->GetCurrentBackBufferIndex()]->GetDesc().Width, (LONG)m_backBuffer[m_swapChain->GetCurrentBackBufferIndex()]->GetDesc().Width,
(LONG)m_backBuffer[m_swapChain->GetCurrentBackBufferIndex()]->GetDesc().Height, (LONG)m_backBuffer[m_swapChain->GetCurrentBackBufferIndex()]->GetDesc().Height,
}; };
getCurrentResourceStorage().m_currentCommandList->RSSetScissorRects(1, &box); getCurrentResourceStorage().m_commandList->RSSetScissorRects(1, &box);
getCurrentResourceStorage().m_currentCommandList->SetGraphicsRootSignature(m_outputScalingPass.m_rootSignature); getCurrentResourceStorage().m_commandList->SetGraphicsRootSignature(m_outputScalingPass.m_rootSignature);
getCurrentResourceStorage().m_currentCommandList->SetPipelineState(m_outputScalingPass.m_PSO); getCurrentResourceStorage().m_commandList->SetPipelineState(m_outputScalingPass.m_PSO);
D3D12_CPU_DESCRIPTOR_HANDLE CPUHandle; D3D12_CPU_DESCRIPTOR_HANDLE CPUHandle;
CPUHandle = m_outputScalingPass.m_textureDescriptorHeap->GetCPUDescriptorHandleForHeapStart(); CPUHandle = m_outputScalingPass.m_textureDescriptorHeap->GetCPUDescriptorHandleForHeapStart();
CPUHandle.ptr += m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV) * m_swapChain->GetCurrentBackBufferIndex(); CPUHandle.ptr += m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV) * m_swapChain->GetCurrentBackBufferIndex();
@ -885,30 +891,30 @@ void D3D12GSRender::Flip()
D3D12_GPU_DESCRIPTOR_HANDLE GPUHandle; D3D12_GPU_DESCRIPTOR_HANDLE GPUHandle;
GPUHandle = m_outputScalingPass.m_textureDescriptorHeap->GetGPUDescriptorHandleForHeapStart(); GPUHandle = m_outputScalingPass.m_textureDescriptorHeap->GetGPUDescriptorHandleForHeapStart();
GPUHandle.ptr += m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV) * m_swapChain->GetCurrentBackBufferIndex(); GPUHandle.ptr += m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV) * m_swapChain->GetCurrentBackBufferIndex();
getCurrentResourceStorage().m_currentCommandList->SetDescriptorHeaps(1, &m_outputScalingPass.m_textureDescriptorHeap); getCurrentResourceStorage().m_commandList->SetDescriptorHeaps(1, &m_outputScalingPass.m_textureDescriptorHeap);
getCurrentResourceStorage().m_currentCommandList->SetGraphicsRootDescriptorTable(0, GPUHandle); getCurrentResourceStorage().m_commandList->SetGraphicsRootDescriptorTable(0, GPUHandle);
GPUHandle = m_outputScalingPass.m_samplerDescriptorHeap->GetGPUDescriptorHandleForHeapStart(); GPUHandle = m_outputScalingPass.m_samplerDescriptorHeap->GetGPUDescriptorHandleForHeapStart();
GPUHandle.ptr += m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER) * m_swapChain->GetCurrentBackBufferIndex(); GPUHandle.ptr += m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER) * m_swapChain->GetCurrentBackBufferIndex();
getCurrentResourceStorage().m_currentCommandList->SetDescriptorHeaps(1, &m_outputScalingPass.m_samplerDescriptorHeap); getCurrentResourceStorage().m_commandList->SetDescriptorHeaps(1, &m_outputScalingPass.m_samplerDescriptorHeap);
getCurrentResourceStorage().m_currentCommandList->SetGraphicsRootDescriptorTable(1, GPUHandle); getCurrentResourceStorage().m_commandList->SetGraphicsRootDescriptorTable(1, GPUHandle);
CPUHandle = m_backbufferAsRendertarget[m_swapChain->GetCurrentBackBufferIndex()]->GetCPUDescriptorHandleForHeapStart(); CPUHandle = m_backbufferAsRendertarget[m_swapChain->GetCurrentBackBufferIndex()]->GetCPUDescriptorHandleForHeapStart();
getCurrentResourceStorage().m_currentCommandList->OMSetRenderTargets(1, &CPUHandle, true, nullptr); getCurrentResourceStorage().m_commandList->OMSetRenderTargets(1, &CPUHandle, true, nullptr);
D3D12_VERTEX_BUFFER_VIEW vbv = {}; D3D12_VERTEX_BUFFER_VIEW vbv = {};
vbv.BufferLocation = m_outputScalingPass.m_vertexBuffer->GetGPUVirtualAddress(); vbv.BufferLocation = m_outputScalingPass.m_vertexBuffer->GetGPUVirtualAddress();
vbv.StrideInBytes = 4 * sizeof(float); vbv.StrideInBytes = 4 * sizeof(float);
vbv.SizeInBytes = 16 * sizeof(float); vbv.SizeInBytes = 16 * sizeof(float);
getCurrentResourceStorage().m_currentCommandList->IASetVertexBuffers(0, 1, &vbv); getCurrentResourceStorage().m_commandList->IASetVertexBuffers(0, 1, &vbv);
getCurrentResourceStorage().m_currentCommandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); getCurrentResourceStorage().m_commandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
if (m_rtts.m_currentlyBoundRenderTargets[0] != nullptr) if (m_rtts.m_currentlyBoundRenderTargets[0] != nullptr)
getCurrentResourceStorage().m_currentCommandList->DrawInstanced(4, 1, 0, 0); getCurrentResourceStorage().m_commandList->DrawInstanced(4, 1, 0, 0);
if (!Ini.GSOverlay.GetValue()) if (!Ini.GSOverlay.GetValue())
getCurrentResourceStorage().m_currentCommandList->ResourceBarrier(1, &getResourceBarrierTransition(m_backBuffer[m_swapChain->GetCurrentBackBufferIndex()].Get(), D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_PRESENT)); getCurrentResourceStorage().m_commandList->ResourceBarrier(1, &getResourceBarrierTransition(m_backBuffer[m_swapChain->GetCurrentBackBufferIndex()].Get(), D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_PRESENT));
if (isFlipSurfaceInLocalMemory(m_surface_color_target) && m_rtts.m_currentlyBoundRenderTargets[0] != nullptr) if (isFlipSurfaceInLocalMemory(m_surface_color_target) && m_rtts.m_currentlyBoundRenderTargets[0] != nullptr)
getCurrentResourceStorage().m_currentCommandList->ResourceBarrier(1, &getResourceBarrierTransition(m_rtts.m_currentlyBoundRenderTargets[0], D3D12_RESOURCE_STATE_GENERIC_READ, D3D12_RESOURCE_STATE_RENDER_TARGET)); getCurrentResourceStorage().m_commandList->ResourceBarrier(1, &getResourceBarrierTransition(m_rtts.m_currentlyBoundRenderTargets[0], D3D12_RESOURCE_STATE_GENERIC_READ, D3D12_RESOURCE_STATE_RENDER_TARGET));
ThrowIfFailed(getCurrentResourceStorage().m_currentCommandList->Close()); ThrowIfFailed(getCurrentResourceStorage().m_commandList->Close());
m_commandQueueGraphic->ExecuteCommandLists(1, (ID3D12CommandList**)&(getCurrentResourceStorage().m_currentCommandList)); m_commandQueueGraphic->ExecuteCommandLists(1, (ID3D12CommandList**)getCurrentResourceStorage().m_commandList.GetAddressOf());
if(Ini.GSOverlay.GetValue()) if(Ini.GSOverlay.GetValue())
renderOverlay(); renderOverlay();
@ -1151,13 +1157,13 @@ void D3D12GSRender::semaphorePGRAPHBackendRelease(u32 offset, u32 value)
m_device->CreateUnorderedAccessView(depthConverted.Get(), nullptr, &uavDesc, Handle); m_device->CreateUnorderedAccessView(depthConverted.Get(), nullptr, &uavDesc, Handle);
// Convert // Convert
getCurrentResourceStorage().m_currentCommandList->ResourceBarrier(1, &getResourceBarrierTransition(m_rtts.m_currentlyBoundDepthStencil, D3D12_RESOURCE_STATE_DEPTH_WRITE, D3D12_RESOURCE_STATE_GENERIC_READ)); getCurrentResourceStorage().m_commandList->ResourceBarrier(1, &getResourceBarrierTransition(m_rtts.m_currentlyBoundDepthStencil, D3D12_RESOURCE_STATE_DEPTH_WRITE, D3D12_RESOURCE_STATE_GENERIC_READ));
getCurrentResourceStorage().m_currentCommandList->SetPipelineState(m_convertPSO); getCurrentResourceStorage().m_commandList->SetPipelineState(m_convertPSO);
getCurrentResourceStorage().m_currentCommandList->SetComputeRootSignature(m_convertRootSignature); getCurrentResourceStorage().m_commandList->SetComputeRootSignature(m_convertRootSignature);
getCurrentResourceStorage().m_currentCommandList->SetDescriptorHeaps(1, &descriptorHeap); getCurrentResourceStorage().m_commandList->SetDescriptorHeaps(1, &descriptorHeap);
getCurrentResourceStorage().m_currentCommandList->SetComputeRootDescriptorTable(0, descriptorHeap->GetGPUDescriptorHandleForHeapStart()); getCurrentResourceStorage().m_commandList->SetComputeRootDescriptorTable(0, descriptorHeap->GetGPUDescriptorHandleForHeapStart());
getCurrentResourceStorage().m_currentCommandList->Dispatch(m_surface_clip_w / 8, m_surface_clip_h / 8, 1); getCurrentResourceStorage().m_commandList->Dispatch(m_surface_clip_w / 8, m_surface_clip_h / 8, 1);
// Flush UAV // Flush UAV
D3D12_RESOURCE_BARRIER uavbarrier = {}; D3D12_RESOURCE_BARRIER uavbarrier = {};
@ -1169,8 +1175,8 @@ void D3D12GSRender::semaphorePGRAPHBackendRelease(u32 offset, u32 value)
getResourceBarrierTransition(m_rtts.m_currentlyBoundDepthStencil, D3D12_RESOURCE_STATE_GENERIC_READ, D3D12_RESOURCE_STATE_DEPTH_WRITE), getResourceBarrierTransition(m_rtts.m_currentlyBoundDepthStencil, D3D12_RESOURCE_STATE_GENERIC_READ, D3D12_RESOURCE_STATE_DEPTH_WRITE),
uavbarrier, uavbarrier,
}; };
getCurrentResourceStorage().m_currentCommandList->ResourceBarrier(2, barriers); getCurrentResourceStorage().m_commandList->ResourceBarrier(2, barriers);
getCurrentResourceStorage().m_currentCommandList->ResourceBarrier(1, &getResourceBarrierTransition(depthConverted.Get(), D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE)); getCurrentResourceStorage().m_commandList->ResourceBarrier(1, &getResourceBarrierTransition(depthConverted.Get(), D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE));
} }
if (m_set_context_dma_z && Ini.GSDumpDepthBuffer.GetValue()) if (m_set_context_dma_z && Ini.GSDumpDepthBuffer.GetValue())
@ -1187,7 +1193,7 @@ void D3D12GSRender::semaphorePGRAPHBackendRelease(u32 offset, u32 value)
dst.PlacedFootprint.Footprint.Height = m_surface_clip_h; dst.PlacedFootprint.Footprint.Height = m_surface_clip_h;
dst.PlacedFootprint.Footprint.Width = m_surface_clip_w; dst.PlacedFootprint.Footprint.Width = m_surface_clip_w;
dst.PlacedFootprint.Footprint.RowPitch = (UINT)depthRowPitch; dst.PlacedFootprint.Footprint.RowPitch = (UINT)depthRowPitch;
getCurrentResourceStorage().m_currentCommandList->CopyTextureRegion(&dst, 0, 0, 0, &src, nullptr); getCurrentResourceStorage().m_commandList->CopyTextureRegion(&dst, 0, 0, 0, &src, nullptr);
invalidateTexture(GetAddress(m_surface_offset_z, m_context_dma_z - 0xfeed0000)); invalidateTexture(GetAddress(m_surface_offset_z, m_context_dma_z - 0xfeed0000));
} }
@ -1201,29 +1207,29 @@ void D3D12GSRender::semaphorePGRAPHBackendRelease(u32 offset, u32 value)
break; break;
case CELL_GCM_SURFACE_TARGET_0: case CELL_GCM_SURFACE_TARGET_0:
if (m_context_dma_color_a) rtt0 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[0], getCurrentResourceStorage().m_currentCommandList); if (m_context_dma_color_a) rtt0 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[0], getCurrentResourceStorage().m_commandList.Get());
break; break;
case CELL_GCM_SURFACE_TARGET_1: case CELL_GCM_SURFACE_TARGET_1:
if (m_context_dma_color_b) rtt1 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[0], getCurrentResourceStorage().m_currentCommandList); if (m_context_dma_color_b) rtt1 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[0], getCurrentResourceStorage().m_commandList.Get());
break; break;
case CELL_GCM_SURFACE_TARGET_MRT1: case CELL_GCM_SURFACE_TARGET_MRT1:
if (m_context_dma_color_a) rtt0 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[0], getCurrentResourceStorage().m_currentCommandList); if (m_context_dma_color_a) rtt0 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[0], getCurrentResourceStorage().m_commandList.Get());
if (m_context_dma_color_b) rtt1 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[1], getCurrentResourceStorage().m_currentCommandList); if (m_context_dma_color_b) rtt1 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[1], getCurrentResourceStorage().m_commandList.Get());
break; break;
case CELL_GCM_SURFACE_TARGET_MRT2: case CELL_GCM_SURFACE_TARGET_MRT2:
if (m_context_dma_color_a) rtt0 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[0], getCurrentResourceStorage().m_currentCommandList); if (m_context_dma_color_a) rtt0 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[0], getCurrentResourceStorage().m_commandList.Get());
if (m_context_dma_color_b) rtt1 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[1], getCurrentResourceStorage().m_currentCommandList); if (m_context_dma_color_b) rtt1 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[1], getCurrentResourceStorage().m_commandList.Get());
if (m_context_dma_color_c) rtt2 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[2], getCurrentResourceStorage().m_currentCommandList); if (m_context_dma_color_c) rtt2 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[2], getCurrentResourceStorage().m_commandList.Get());
break; break;
case CELL_GCM_SURFACE_TARGET_MRT3: case CELL_GCM_SURFACE_TARGET_MRT3:
if (m_context_dma_color_a) rtt0 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[0], getCurrentResourceStorage().m_currentCommandList); if (m_context_dma_color_a) rtt0 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[0], getCurrentResourceStorage().m_commandList.Get());
if (m_context_dma_color_b) rtt1 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[1], getCurrentResourceStorage().m_currentCommandList); if (m_context_dma_color_b) rtt1 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[1], getCurrentResourceStorage().m_commandList.Get());
if (m_context_dma_color_c) rtt2 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[2], getCurrentResourceStorage().m_currentCommandList); if (m_context_dma_color_c) rtt2 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[2], getCurrentResourceStorage().m_commandList.Get());
if (m_context_dma_color_d) rtt3 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[3], getCurrentResourceStorage().m_currentCommandList); if (m_context_dma_color_d) rtt3 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[3], getCurrentResourceStorage().m_commandList.Get());
break; break;
} }
@ -1234,8 +1240,8 @@ void D3D12GSRender::semaphorePGRAPHBackendRelease(u32 offset, u32 value)
} }
if (needTransfer) if (needTransfer)
{ {
ThrowIfFailed(getCurrentResourceStorage().m_currentCommandList->Close()); ThrowIfFailed(getCurrentResourceStorage().m_commandList->Close());
m_commandQueueGraphic->ExecuteCommandLists(1, (ID3D12CommandList**)&(getCurrentResourceStorage().m_currentCommandList)); m_commandQueueGraphic->ExecuteCommandLists(1, (ID3D12CommandList**)getCurrentResourceStorage().m_commandList.GetAddressOf());
getCurrentResourceStorage().setNewCommandList(); getCurrentResourceStorage().setNewCommandList();
} }

View file

@ -307,8 +307,7 @@ private:
// Pointer to device, not owned by ResourceStorage // Pointer to device, not owned by ResourceStorage
ID3D12Device *m_device; ID3D12Device *m_device;
ComPtr<ID3D12CommandAllocator> m_commandAllocator; ComPtr<ID3D12CommandAllocator> m_commandAllocator;
std::vector<ComPtr<ID3D12GraphicsCommandList> > m_availableCommandLists; ComPtr<ID3D12GraphicsCommandList> m_commandList;
size_t m_nextAvailableCommandListIndex;
// Constants storage // Constants storage
ComPtr<ID3D12DescriptorHeap> m_constantsBufferDescriptorsHeap; ComPtr<ID3D12DescriptorHeap> m_constantsBufferDescriptorsHeap;
@ -328,7 +327,6 @@ private:
// List of resources that can be freed after frame is flipped // List of resources that can be freed after frame is flipped
std::vector<ComPtr<ID3D12Resource> > m_singleFrameLifetimeResources; std::vector<ComPtr<ID3D12Resource> > m_singleFrameLifetimeResources;
ID3D12GraphicsCommandList *m_currentCommandList;
void Reset(); void Reset();
void Init(ID3D12Device *device); void Init(ID3D12Device *device);