mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-08-11 02:29:29 +00:00
d3d12: Use a dummy texture to fill unused slots
This commit is contained in:
parent
79420e52a2
commit
88d05a08cf
4 changed files with 69 additions and 14 deletions
|
@ -60,4 +60,33 @@ void streamBuffer(void* dst, void* src, size_t sizeInBytes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
D3D12_RESOURCE_DESC getBufferResourceDesc(size_t sizeInByte)
|
||||||
|
{
|
||||||
|
D3D12_RESOURCE_DESC BufferDesc = {};
|
||||||
|
BufferDesc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
|
||||||
|
BufferDesc.Width = (UINT)sizeInByte;
|
||||||
|
BufferDesc.Height = 1;
|
||||||
|
BufferDesc.DepthOrArraySize = 1;
|
||||||
|
BufferDesc.SampleDesc.Count = 1;
|
||||||
|
BufferDesc.MipLevels = 1;
|
||||||
|
BufferDesc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
|
||||||
|
return BufferDesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
D3D12_RESOURCE_DESC getTexture2DResourceDesc(size_t width, size_t height, DXGI_FORMAT dxgiFormat)
|
||||||
|
{
|
||||||
|
D3D12_RESOURCE_DESC result;
|
||||||
|
result = {};
|
||||||
|
result.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
|
||||||
|
result.Width = width;
|
||||||
|
result.Height = height;
|
||||||
|
result.Format = dxgiFormat;
|
||||||
|
result.DepthOrArraySize = 1;
|
||||||
|
result.SampleDesc.Count = 1;
|
||||||
|
result.MipLevels = 1;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -132,19 +132,7 @@ void expandIndexedQuads(DstType *dst, const SrcType *src, size_t indexCount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
|
||||||
D3D12_RESOURCE_DESC getBufferResourceDesc(size_t sizeInByte)
|
|
||||||
{
|
|
||||||
D3D12_RESOURCE_DESC BufferDesc = {};
|
|
||||||
BufferDesc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
|
|
||||||
BufferDesc.Width = (UINT)sizeInByte;
|
|
||||||
BufferDesc.Height = 1;
|
|
||||||
BufferDesc.DepthOrArraySize = 1;
|
|
||||||
BufferDesc.SampleDesc.Count = 1;
|
|
||||||
BufferDesc.MipLevels = 1;
|
|
||||||
BufferDesc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
|
|
||||||
return BufferDesc;
|
|
||||||
}
|
|
||||||
|
|
||||||
// D3D12GS member handling buffers
|
// D3D12GS member handling buffers
|
||||||
|
|
||||||
|
|
|
@ -303,10 +303,23 @@ D3D12GSRender::D3D12GSRender()
|
||||||
|
|
||||||
p.first->Release();
|
p.first->Release();
|
||||||
p.second->Release();
|
p.second->Release();
|
||||||
|
|
||||||
|
D3D12_HEAP_PROPERTIES hp = {};
|
||||||
|
hp.Type = D3D12_HEAP_TYPE_DEFAULT;
|
||||||
|
check(
|
||||||
|
m_device->CreateCommittedResource(
|
||||||
|
&hp,
|
||||||
|
D3D12_HEAP_FLAG_NONE,
|
||||||
|
&getTexture2DResourceDesc(2, 2, DXGI_FORMAT_R8G8B8A8_UNORM),
|
||||||
|
D3D12_RESOURCE_STATE_GENERIC_READ,
|
||||||
|
nullptr,
|
||||||
|
IID_PPV_ARGS(&m_dummyTexture))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
D3D12GSRender::~D3D12GSRender()
|
D3D12GSRender::~D3D12GSRender()
|
||||||
{
|
{
|
||||||
|
m_dummyTexture->Release();
|
||||||
m_convertPSO->Release();
|
m_convertPSO->Release();
|
||||||
m_convertRootSignature->Release();
|
m_convertRootSignature->Release();
|
||||||
m_perFrameStorage.Release();
|
m_perFrameStorage.Release();
|
||||||
|
@ -634,6 +647,28 @@ void D3D12GSRender::ExecCMD()
|
||||||
commandList->SetPipelineState(m_PSO);
|
commandList->SetPipelineState(m_PSO);
|
||||||
|
|
||||||
size_t usedTexture = UploadTextures();
|
size_t usedTexture = UploadTextures();
|
||||||
|
// Drivers don't like undefined texture descriptors
|
||||||
|
for (; usedTexture < 16; usedTexture++)
|
||||||
|
{
|
||||||
|
D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
|
||||||
|
srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;
|
||||||
|
srvDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||||
|
srvDesc.Texture2D.MipLevels = 1;
|
||||||
|
srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
|
||||||
|
D3D12_CPU_DESCRIPTOR_HANDLE Handle = m_perFrameStorage.m_textureDescriptorsHeap->GetCPUDescriptorHandleForHeapStart();
|
||||||
|
Handle.ptr += (m_perFrameStorage.m_currentTextureIndex + usedTexture) * m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
|
||||||
|
m_device->CreateShaderResourceView(m_dummyTexture, &srvDesc, Handle);
|
||||||
|
|
||||||
|
D3D12_SAMPLER_DESC samplerDesc = {};
|
||||||
|
samplerDesc.Filter = D3D12_FILTER_MIN_MAG_MIP_POINT;
|
||||||
|
samplerDesc.AddressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP;
|
||||||
|
samplerDesc.AddressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP;
|
||||||
|
samplerDesc.AddressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP;
|
||||||
|
Handle = m_perFrameStorage.m_samplerDescriptorHeap->GetCPUDescriptorHandleForHeapStart();
|
||||||
|
Handle.ptr += (m_perFrameStorage.m_currentTextureIndex + usedTexture) * m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
|
||||||
|
m_device->CreateSampler(&samplerDesc, Handle);
|
||||||
|
}
|
||||||
|
|
||||||
Handle = m_perFrameStorage.m_textureDescriptorsHeap->GetGPUDescriptorHandleForHeapStart();
|
Handle = m_perFrameStorage.m_textureDescriptorsHeap->GetGPUDescriptorHandleForHeapStart();
|
||||||
Handle.ptr += m_perFrameStorage.m_currentTextureIndex * m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
|
Handle.ptr += m_perFrameStorage.m_currentTextureIndex * m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
|
||||||
commandList->SetDescriptorHeaps(1, &m_perFrameStorage.m_textureDescriptorsHeap);
|
commandList->SetDescriptorHeaps(1, &m_perFrameStorage.m_textureDescriptorsHeap);
|
||||||
|
@ -644,7 +679,7 @@ void D3D12GSRender::ExecCMD()
|
||||||
commandList->SetDescriptorHeaps(1, &m_perFrameStorage.m_samplerDescriptorHeap);
|
commandList->SetDescriptorHeaps(1, &m_perFrameStorage.m_samplerDescriptorHeap);
|
||||||
commandList->SetGraphicsRootDescriptorTable(3, Handle);
|
commandList->SetGraphicsRootDescriptorTable(3, Handle);
|
||||||
|
|
||||||
m_perFrameStorage.m_currentTextureIndex += usedTexture;
|
m_perFrameStorage.m_currentTextureIndex += 16;
|
||||||
|
|
||||||
InitDrawBuffers();
|
InitDrawBuffers();
|
||||||
|
|
||||||
|
|
|
@ -104,6 +104,9 @@ private:
|
||||||
ID3D12CommandQueue *m_commandQueueCopy;
|
ID3D12CommandQueue *m_commandQueueCopy;
|
||||||
ID3D12CommandQueue *m_commandQueueGraphic;
|
ID3D12CommandQueue *m_commandQueueGraphic;
|
||||||
|
|
||||||
|
// Used to fill unused texture slot
|
||||||
|
ID3D12Resource *m_dummyTexture;
|
||||||
|
|
||||||
struct IDXGISwapChain3 *m_swapChain;
|
struct IDXGISwapChain3 *m_swapChain;
|
||||||
//BackBuffers
|
//BackBuffers
|
||||||
ID3D12Resource* m_backBuffer[2];
|
ID3D12Resource* m_backBuffer[2];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue