mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-03-01 16:13:23 +00:00
d3d12: Do not create/submit an extra command list for texture upload/rtt state change
This commit is contained in:
parent
4185fcb6cd
commit
befe93784f
@ -431,12 +431,12 @@ void D3D12GSRender::Clear(u32 cmd)
|
||||
{
|
||||
assert(cmd == NV4097_CLEAR_SURFACE);
|
||||
|
||||
PrepareRenderTargets();
|
||||
|
||||
ID3D12GraphicsCommandList *commandList;
|
||||
check(m_device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, getCurrentResourceStorage().m_commandAllocator, nullptr, IID_PPV_ARGS(&commandList)));
|
||||
getCurrentResourceStorage().m_inflightCommandList.push_back(commandList);
|
||||
|
||||
PrepareRenderTargets(commandList);
|
||||
|
||||
/* if (m_set_color_mask)
|
||||
{
|
||||
glColorMask(m_color_mask_r, m_color_mask_g, m_color_mask_b, m_color_mask_a);
|
||||
@ -509,7 +509,11 @@ void D3D12GSRender::Clear(u32 cmd)
|
||||
|
||||
void D3D12GSRender::Draw()
|
||||
{
|
||||
PrepareRenderTargets();
|
||||
ID3D12GraphicsCommandList *commandList;
|
||||
m_device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, getCurrentResourceStorage().m_commandAllocator, nullptr, IID_PPV_ARGS(&commandList));
|
||||
getCurrentResourceStorage().m_inflightCommandList.push_back(commandList);
|
||||
|
||||
PrepareRenderTargets(commandList);
|
||||
|
||||
// Init vertex count
|
||||
// TODO: Very hackish, clean this
|
||||
@ -536,11 +540,6 @@ void D3D12GSRender::Draw()
|
||||
}
|
||||
}
|
||||
|
||||
ID3D12GraphicsCommandList *commandList;
|
||||
m_device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, getCurrentResourceStorage().m_commandAllocator, nullptr, IID_PPV_ARGS(&commandList));
|
||||
getCurrentResourceStorage().m_inflightCommandList.push_back(commandList);
|
||||
|
||||
|
||||
std::chrono::time_point<std::chrono::system_clock> startVertexTime = std::chrono::system_clock::now();
|
||||
if (m_indexed_array.m_count || m_draw_array_count)
|
||||
{
|
||||
@ -588,7 +587,7 @@ void D3D12GSRender::Draw()
|
||||
if (m_PSO->second > 0)
|
||||
{
|
||||
std::chrono::time_point<std::chrono::system_clock> startTextureTime = std::chrono::system_clock::now();
|
||||
size_t usedTexture = UploadTextures();
|
||||
size_t usedTexture = UploadTextures(commandList);
|
||||
|
||||
// Fill empty slots
|
||||
for (; usedTexture < m_PSO->second; usedTexture++)
|
||||
|
@ -402,12 +402,19 @@ private:
|
||||
void FillVertexShaderConstantsBuffer();
|
||||
void FillPixelShaderConstantsBuffer();
|
||||
/**
|
||||
* Upload textures to Data heap if necessary and create necessary descriptor in the per frame storage struct.
|
||||
* returns the number of texture uploaded
|
||||
* Fetch all textures recorded in the state in the render target cache and in the texture cache.
|
||||
* If a texture is not cached, populate cmdlist with uploads command.
|
||||
* Create necessary resource view/sampler descriptors in the per frame storage struct.
|
||||
* returns the number of texture uploaded.
|
||||
*/
|
||||
size_t UploadTextures();
|
||||
size_t UploadTextures(ID3D12GraphicsCommandList *cmdlist);
|
||||
|
||||
void PrepareRenderTargets();
|
||||
/**
|
||||
* Creates render target if necessary.
|
||||
* Populate cmdlist with render target state change (from RTT to generic read for previous rtt,
|
||||
* from generic to rtt for rtt in cache).
|
||||
*/
|
||||
void PrepareRenderTargets(ID3D12GraphicsCommandList *cmdlist);
|
||||
protected:
|
||||
virtual void OnInit() override;
|
||||
virtual void OnInitThread() override;
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "D3D12.h"
|
||||
#include "D3D12GSRender.h"
|
||||
|
||||
void D3D12GSRender::PrepareRenderTargets()
|
||||
void D3D12GSRender::PrepareRenderTargets(ID3D12GraphicsCommandList *copycmdlist)
|
||||
{
|
||||
// FBO location has changed, previous data might be copied
|
||||
u32 address_a = m_set_context_dma_color_a ? GetAddress(m_surface_offset_a, m_context_dma_color_a - 0xfeed0000) : 0;
|
||||
@ -21,10 +21,6 @@ void D3D12GSRender::PrepareRenderTargets()
|
||||
u32 address_d = m_set_context_dma_color_d ? GetAddress(m_surface_offset_d, m_context_dma_color_d - 0xfeed0000) : 0;
|
||||
u32 address_z = m_set_context_dma_z ? GetAddress(m_surface_offset_z, m_context_dma_z - 0xfeed0000) : 0;
|
||||
|
||||
ID3D12GraphicsCommandList *copycmdlist;
|
||||
check(m_device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, getCurrentResourceStorage().m_commandAllocator, nullptr, IID_PPV_ARGS(©cmdlist)));
|
||||
getCurrentResourceStorage().m_inflightCommandList.push_back(copycmdlist);
|
||||
|
||||
// Make previous RTTs sampleable
|
||||
for (unsigned i = 0; i < 4; i++)
|
||||
{
|
||||
@ -141,9 +137,6 @@ void D3D12GSRender::PrepareRenderTargets()
|
||||
}
|
||||
depthStencilViewDesc.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2D;
|
||||
m_device->CreateDepthStencilView(ds, &depthStencilViewDesc, m_rtts.m_depthStencilDescriptorHeap->GetCPUDescriptorHandleForHeapStart());
|
||||
|
||||
check(copycmdlist->Close());
|
||||
m_commandQueueGraphic->ExecuteCommandLists(1, (ID3D12CommandList**)©cmdlist);
|
||||
}
|
||||
|
||||
ID3D12Resource *RenderTargets::bindAddressAsRenderTargets(ID3D12Device *device, ID3D12GraphicsCommandList *cmdList, size_t slot, u32 address,
|
||||
|
@ -726,7 +726,7 @@ size_t getTextureSize(const RSXTexture &texture)
|
||||
}
|
||||
}
|
||||
|
||||
size_t D3D12GSRender::UploadTextures()
|
||||
size_t D3D12GSRender::UploadTextures(ID3D12GraphicsCommandList *cmdlist)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mut);
|
||||
size_t usedTexture = 0;
|
||||
@ -758,15 +758,7 @@ size_t D3D12GSRender::UploadTextures()
|
||||
}
|
||||
else
|
||||
{
|
||||
// Upload at each iteration to take advantage of overlapping transfer
|
||||
ID3D12GraphicsCommandList *commandList;
|
||||
check(m_device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, getCurrentResourceStorage().m_textureUploadCommandAllocator, nullptr, IID_PPV_ARGS(&commandList)));
|
||||
|
||||
vramTexture = uploadSingleTexture(m_textures[i], m_device, commandList, m_textureUploadData);
|
||||
|
||||
check(commandList->Close());
|
||||
m_commandQueueGraphic->ExecuteCommandLists(1, (ID3D12CommandList**)&commandList);
|
||||
getCurrentResourceStorage().m_inflightCommandList.push_back(commandList);
|
||||
vramTexture = uploadSingleTexture(m_textures[i], m_device, cmdlist, m_textureUploadData);
|
||||
m_texturesCache[texaddr] = vramTexture;
|
||||
|
||||
u32 s = (u32)align(getTextureSize(m_textures[i]), 4096);
|
||||
|
Loading…
x
Reference in New Issue
Block a user