mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-03-14 10:21:21 +00:00
d3d12: Pass first clear value as clear optimised value to RTTs
This commit is contained in:
parent
eb1b8b748a
commit
a9425fcf2a
@ -264,8 +264,15 @@ void D3D12GSRender::InitDrawBuffers()
|
||||
m_lastWidth = RSXThread::m_width;
|
||||
m_lastHeight = RSXThread::m_height;
|
||||
m_lastDepth = m_surface_depth_format;
|
||||
float clearColor[] =
|
||||
{
|
||||
m_clear_surface_color_r / 255.0f,
|
||||
m_clear_surface_color_g / 255.0f,
|
||||
m_clear_surface_color_b / 255.0f,
|
||||
m_clear_surface_color_a / 255.0f
|
||||
};
|
||||
|
||||
m_fbo = new D3D12RenderTargetSets(m_device, (u8)m_lastDepth, m_lastWidth, m_lastHeight);
|
||||
m_fbo = new D3D12RenderTargetSets(m_device, (u8)m_lastDepth, m_lastWidth, m_lastHeight, clearColor, 1.f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "Emu/System.h"
|
||||
#include "Emu/RSX/GSRender.h"
|
||||
|
||||
D3D12RenderTargetSets::D3D12RenderTargetSets(ID3D12Device *device, u8 surfaceDepthFormat, size_t width, size_t height)
|
||||
D3D12RenderTargetSets::D3D12RenderTargetSets(ID3D12Device *device, u8 surfaceDepthFormat, size_t width, size_t height, float clearColor[4], float clearDepth)
|
||||
{
|
||||
D3D12_DESCRIPTOR_HEAP_DESC descriptorHeapDesc = {};
|
||||
descriptorHeapDesc.NumDescriptors = 1;
|
||||
@ -20,6 +20,9 @@ D3D12RenderTargetSets::D3D12RenderTargetSets(ID3D12Device *device, u8 surfaceDep
|
||||
descriptorHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV;
|
||||
device->CreateDescriptorHeap(&descriptorHeapDesc, IID_PPV_ARGS(&m_rttDescriptorHeap));
|
||||
|
||||
D3D12_CLEAR_VALUE clearDepthValue = {};
|
||||
clearDepthValue.DepthStencil.Depth = clearDepth;
|
||||
|
||||
// Every resource are committed for simplicity, later we could use heap
|
||||
D3D12_HEAP_PROPERTIES heapProp = {};
|
||||
heapProp.Type = D3D12_HEAP_TYPE_DEFAULT;
|
||||
@ -37,9 +40,11 @@ D3D12RenderTargetSets::D3D12RenderTargetSets(ID3D12Device *device, u8 surfaceDep
|
||||
break;
|
||||
case CELL_GCM_SURFACE_Z16:
|
||||
resourceDesc.Format = DXGI_FORMAT_R16_TYPELESS;
|
||||
clearDepthValue.Format = DXGI_FORMAT_D16_UNORM;
|
||||
break;
|
||||
case CELL_GCM_SURFACE_Z24S8:
|
||||
resourceDesc.Format = DXGI_FORMAT_R24G8_TYPELESS;
|
||||
clearDepthValue.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR(RSX, "Bad depth format! (%d)", surfaceDepthFormat);
|
||||
@ -51,7 +56,7 @@ D3D12RenderTargetSets::D3D12RenderTargetSets(ID3D12Device *device, u8 surfaceDep
|
||||
D3D12_HEAP_FLAG_NONE,
|
||||
&resourceDesc,
|
||||
D3D12_RESOURCE_STATE_DEPTH_WRITE,
|
||||
nullptr, // TODO: Assign sensible default clearvalue here
|
||||
&clearDepthValue,
|
||||
IID_PPV_ARGS(&m_depthStencilTexture)
|
||||
);
|
||||
D3D12_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc = {};
|
||||
@ -72,6 +77,12 @@ D3D12RenderTargetSets::D3D12RenderTargetSets(ID3D12Device *device, u8 surfaceDep
|
||||
depthStencilViewDesc.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2D;
|
||||
device->CreateDepthStencilView(m_depthStencilTexture, &depthStencilViewDesc, m_depthStencilDescriptorHeap->GetCPUDescriptorHandleForHeapStart());
|
||||
|
||||
D3D12_CLEAR_VALUE clearColorValue = {};
|
||||
clearColorValue.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
clearColorValue.Color[0] = clearColor[0];
|
||||
clearColorValue.Color[1] = clearColor[1];
|
||||
clearColorValue.Color[2] = clearColor[2];
|
||||
clearColorValue.Color[3] = clearColor[3];
|
||||
g_RTTIncrement = device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE Handle = m_rttDescriptorHeap->GetCPUDescriptorHandleForHeapStart();
|
||||
for (int i = 0; i < 4; ++i)
|
||||
@ -90,7 +101,7 @@ D3D12RenderTargetSets::D3D12RenderTargetSets(ID3D12Device *device, u8 surfaceDep
|
||||
D3D12_HEAP_FLAG_NONE,
|
||||
&resourceDesc,
|
||||
D3D12_RESOURCE_STATE_RENDER_TARGET,
|
||||
nullptr, // TODO: Assign sensible default clearvalue here
|
||||
&clearColorValue,
|
||||
IID_PPV_ARGS(&m_rtts[i])
|
||||
);
|
||||
|
||||
|
@ -15,7 +15,7 @@ class D3D12RenderTargetSets
|
||||
ID3D12DescriptorHeap *m_rttDescriptorHeap;
|
||||
ID3D12DescriptorHeap *m_depthStencilDescriptorHeap;
|
||||
public:
|
||||
D3D12RenderTargetSets(ID3D12Device *device, u8 surfaceDepthFormat, size_t width, size_t height);
|
||||
D3D12RenderTargetSets(ID3D12Device *device, u8 surfaceDepthFormat, size_t width, size_t height, float clearColor[4], float clearDepth);
|
||||
~D3D12RenderTargetSets();
|
||||
/**
|
||||
* Return the base descriptor address for the give surface target.
|
||||
|
Loading…
x
Reference in New Issue
Block a user