mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-05 06:21:26 +12:00
Remove clear_surface_color
This commit is contained in:
parent
28cdfa9feb
commit
ed61023dd3
6 changed files with 55 additions and 81 deletions
|
@ -318,23 +318,32 @@ void D3D12GSRender::clear_surface(u32 arg)
|
|||
}*/
|
||||
|
||||
// TODO: Merge depth and stencil clear when possible
|
||||
if (m_clear_surface_mask & 0x1)
|
||||
if (arg & 0x1)
|
||||
{
|
||||
u32 clear_depth = rsx::method_registers[NV4097_SET_ZSTENCIL_CLEAR_VALUE] >> 8;
|
||||
u32 max_depth_value = m_surface_depth_format == CELL_GCM_SURFACE_Z16 ? 0x0000ffff : 0x00ffffff;
|
||||
getCurrentResourceStorage().m_commandList->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, clear_depth / (float)max_depth_value, 0, 0, nullptr);
|
||||
}
|
||||
|
||||
if (m_clear_surface_mask & 0x2)
|
||||
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 (arg & 0x2)
|
||||
{
|
||||
u8 clear_stencil = rsx::method_registers[NV4097_SET_ZSTENCIL_CLEAR_VALUE] & 0xff;
|
||||
getCurrentResourceStorage().m_commandList->ClearDepthStencilView(m_rtts.m_depthStencilDescriptorHeap->GetCPUDescriptorHandleForHeapStart(), D3D12_CLEAR_FLAG_STENCIL, 0.f, clear_stencil, 0, nullptr);
|
||||
}
|
||||
|
||||
if (arg & 0xF0)
|
||||
{
|
||||
u32 clear_color = rsx::method_registers[NV4097_SET_COLOR_CLEAR_VALUE];
|
||||
u8 clear_a = clear_color >> 24;
|
||||
u8 clear_r = clear_color >> 16;
|
||||
u8 clear_g = clear_color >> 8;
|
||||
u8 clear_b = clear_color;
|
||||
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
|
||||
clear_r / 255.0f,
|
||||
clear_g / 255.0f,
|
||||
clear_b / 255.0f,
|
||||
clear_a / 255.0f
|
||||
};
|
||||
|
||||
size_t g_RTTIncrement = m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
|
||||
|
|
|
@ -69,64 +69,77 @@ void D3D12GSRender::PrepareRenderTargets(ID3D12GraphicsCommandList *copycmdlist)
|
|||
rttViewDesc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D;
|
||||
rttViewDesc.Format = dxgiFormat;
|
||||
|
||||
u32 clear_color = rsx::method_registers[NV4097_SET_COLOR_CLEAR_VALUE];
|
||||
u8 clear_a = clear_color >> 24;
|
||||
u8 clear_r = clear_color >> 16;
|
||||
u8 clear_g = clear_color >> 8;
|
||||
u8 clear_b = clear_color;
|
||||
std::array<float, 4> clearColor =
|
||||
{
|
||||
clear_r / 255.0f,
|
||||
clear_g / 255.0f,
|
||||
clear_b / 255.0f,
|
||||
clear_a / 255.0f
|
||||
};
|
||||
|
||||
switch (m_surface_color_target)
|
||||
{
|
||||
case CELL_GCM_SURFACE_TARGET_0:
|
||||
{
|
||||
ID3D12Resource *rttA = m_rtts.bindAddressAsRenderTargets(m_device.Get(), copycmdlist, 0, address_a, m_surface_clip_w, m_surface_clip_h, m_surface_color_format,
|
||||
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);
|
||||
clearColor);
|
||||
m_device->CreateRenderTargetView(rttA, &rttViewDesc, Handle);
|
||||
break;
|
||||
}
|
||||
case CELL_GCM_SURFACE_TARGET_1:
|
||||
{
|
||||
ID3D12Resource *rttB = m_rtts.bindAddressAsRenderTargets(m_device.Get(), copycmdlist, 0, address_b, m_surface_clip_w, m_surface_clip_h, m_surface_color_format,
|
||||
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);
|
||||
clearColor);
|
||||
m_device->CreateRenderTargetView(rttB, &rttViewDesc, Handle);
|
||||
break;
|
||||
}
|
||||
case CELL_GCM_SURFACE_TARGET_MRT1:
|
||||
{
|
||||
ID3D12Resource *rttA = m_rtts.bindAddressAsRenderTargets(m_device.Get(), copycmdlist, 0, address_a, m_surface_clip_w, m_surface_clip_h, m_surface_color_format,
|
||||
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);
|
||||
clearColor);
|
||||
m_device->CreateRenderTargetView(rttA, &rttViewDesc, Handle);
|
||||
Handle.ptr += g_RTTIncrement;
|
||||
ID3D12Resource *rttB = m_rtts.bindAddressAsRenderTargets(m_device.Get(), copycmdlist, 1, address_b, m_surface_clip_w, m_surface_clip_h, m_surface_color_format,
|
||||
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);
|
||||
clearColor);
|
||||
m_device->CreateRenderTargetView(rttB, &rttViewDesc, Handle);
|
||||
}
|
||||
break;
|
||||
case CELL_GCM_SURFACE_TARGET_MRT2:
|
||||
{
|
||||
ID3D12Resource *rttA = m_rtts.bindAddressAsRenderTargets(m_device.Get(), copycmdlist, 0, address_a, m_surface_clip_w, m_surface_clip_h, m_surface_color_format,
|
||||
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);
|
||||
clearColor);
|
||||
m_device->CreateRenderTargetView(rttA, &rttViewDesc, Handle);
|
||||
Handle.ptr += g_RTTIncrement;
|
||||
ID3D12Resource *rttB = m_rtts.bindAddressAsRenderTargets(m_device.Get(), copycmdlist, 1, address_b, m_surface_clip_w, m_surface_clip_h, m_surface_color_format,
|
||||
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);
|
||||
clearColor);
|
||||
m_device->CreateRenderTargetView(rttB, &rttViewDesc, Handle);
|
||||
Handle.ptr += g_RTTIncrement;
|
||||
ID3D12Resource *rttC = m_rtts.bindAddressAsRenderTargets(m_device.Get(), copycmdlist, 2, address_c, m_surface_clip_w, m_surface_clip_h, m_surface_color_format,
|
||||
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);
|
||||
clearColor);
|
||||
m_device->CreateRenderTargetView(rttC, &rttViewDesc, Handle);
|
||||
break;
|
||||
}
|
||||
case CELL_GCM_SURFACE_TARGET_MRT3:
|
||||
{
|
||||
ID3D12Resource *rttA = m_rtts.bindAddressAsRenderTargets(m_device.Get(), copycmdlist, 0, address_a, m_surface_clip_w, m_surface_clip_h, m_surface_color_format,
|
||||
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);
|
||||
clearColor);
|
||||
m_device->CreateRenderTargetView(rttA, &rttViewDesc, Handle);
|
||||
Handle.ptr += g_RTTIncrement;
|
||||
ID3D12Resource *rttB = m_rtts.bindAddressAsRenderTargets(m_device.Get(), copycmdlist, 1, address_b, m_surface_clip_w, m_surface_clip_h, m_surface_color_format,
|
||||
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);
|
||||
clearColor);
|
||||
m_device->CreateRenderTargetView(rttB, &rttViewDesc, Handle);
|
||||
Handle.ptr += g_RTTIncrement;
|
||||
ID3D12Resource *rttC = m_rtts.bindAddressAsRenderTargets(m_device.Get(), copycmdlist, 2, address_c, m_surface_clip_w, m_surface_clip_h, m_surface_color_format,
|
||||
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);
|
||||
clearColor);
|
||||
m_device->CreateRenderTargetView(rttC, &rttViewDesc, Handle);
|
||||
Handle.ptr += g_RTTIncrement;
|
||||
ID3D12Resource *rttD = m_rtts.bindAddressAsRenderTargets(m_device.Get(), copycmdlist, 3, address_d, m_surface_clip_w, m_surface_clip_h, m_surface_color_format,
|
||||
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);
|
||||
clearColor);
|
||||
m_device->CreateRenderTargetView(rttD, &rttViewDesc, Handle);
|
||||
break;
|
||||
}
|
||||
|
@ -154,7 +167,7 @@ void D3D12GSRender::PrepareRenderTargets(ID3D12GraphicsCommandList *copycmdlist)
|
|||
}
|
||||
|
||||
ID3D12Resource *RenderTargets::bindAddressAsRenderTargets(ID3D12Device *device, ID3D12GraphicsCommandList *cmdList, size_t slot, u32 address,
|
||||
size_t width, size_t height, u8 surfaceColorFormat, float clearColorR, float clearColorG, float clearColorB, float clearColorA)
|
||||
size_t width, size_t height, u8 surfaceColorFormat, const std::array<float, 4> &clearColor)
|
||||
{
|
||||
ID3D12Resource* rtt;
|
||||
auto It = m_renderTargets.find(address);
|
||||
|
@ -179,10 +192,10 @@ ID3D12Resource *RenderTargets::bindAddressAsRenderTargets(ID3D12Device *device,
|
|||
}
|
||||
D3D12_CLEAR_VALUE clearColorValue = {};
|
||||
clearColorValue.Format = dxgiFormat;
|
||||
clearColorValue.Color[0] = clearColorR;
|
||||
clearColorValue.Color[1] = clearColorG;
|
||||
clearColorValue.Color[2] = clearColorB;
|
||||
clearColorValue.Color[3] = clearColorA;
|
||||
clearColorValue.Color[0] = clearColor[0];
|
||||
clearColorValue.Color[1] = clearColor[1];
|
||||
clearColorValue.Color[2] = clearColor[2];
|
||||
clearColorValue.Color[3] = clearColor[3];
|
||||
|
||||
device->CreateCommittedResource(
|
||||
&CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_DEFAULT),
|
||||
|
|
|
@ -20,7 +20,7 @@ struct RenderTargets
|
|||
* returns the corresponding render target resource.
|
||||
*/
|
||||
ID3D12Resource *bindAddressAsRenderTargets(ID3D12Device *device, ID3D12GraphicsCommandList *cmdList, size_t slot, u32 address,
|
||||
size_t width, size_t height, u8 surfaceColorFormat, float clearColorR, float clearColorG, float clearColorB, float clearColorA);
|
||||
size_t width, size_t height, u8 surfaceColorFormat, const std::array<float, 4> &clearColor);
|
||||
|
||||
ID3D12Resource *bindAddressAsDepthStencil(ID3D12Device *device, ID3D12GraphicsCommandList *cmdList, u32 address,
|
||||
size_t width, size_t height, u8 surfaceDepthFormat, float depthClear, u8 stencilClear);
|
||||
|
|
|
@ -1594,7 +1594,7 @@ void GLGSRender::clear_surface(u32 arg)
|
|||
|
||||
if (m_clear_surface_mask & 0x1)
|
||||
{
|
||||
glClearDepth(m_clear_surface_z / (float)0xffffff);
|
||||
// glClearDepth(m_clear_surface_z / (float)0xffffff);
|
||||
checkForGlError("glClearDepth");
|
||||
|
||||
f |= GL_DEPTH_BUFFER_BIT;
|
||||
|
@ -1602,7 +1602,7 @@ void GLGSRender::clear_surface(u32 arg)
|
|||
|
||||
if (m_clear_surface_mask & 0x2)
|
||||
{
|
||||
glClearStencil(m_clear_surface_s);
|
||||
// glClearStencil(m_clear_surface_s);
|
||||
checkForGlError("glClearStencil");
|
||||
|
||||
f |= GL_STENCIL_BUFFER_BIT;
|
||||
|
@ -1610,11 +1610,11 @@ void GLGSRender::clear_surface(u32 arg)
|
|||
|
||||
if (m_clear_surface_mask & 0xF0)
|
||||
{
|
||||
glClearColor(
|
||||
/* glClearColor(
|
||||
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_clear_surface_color_a / 255.0f);*/
|
||||
checkForGlError("glClearColor");
|
||||
|
||||
f |= GL_COLOR_BUFFER_BIT;
|
||||
|
|
|
@ -898,49 +898,17 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const
|
|||
|
||||
// Clearing
|
||||
case NV4097_CLEAR_ZCULL_SURFACE:
|
||||
{
|
||||
u32 a0 = ARGS(0);
|
||||
|
||||
if (a0 & 0x01) m_clear_surface_z = m_clear_z;
|
||||
if (a0 & 0x02) m_clear_surface_s = m_clear_s;
|
||||
|
||||
m_clear_surface_mask |= a0 & 0x3;
|
||||
break;
|
||||
}
|
||||
|
||||
case NV4097_CLEAR_SURFACE:
|
||||
{
|
||||
const u32 a0 = ARGS(0);
|
||||
|
||||
if (a0 & 0x01) m_clear_surface_z = m_clear_z;
|
||||
if (a0 & 0x02) m_clear_surface_s = m_clear_s;
|
||||
if (a0 & 0x10) m_clear_surface_color_r = m_clear_color_r;
|
||||
if (a0 & 0x20) m_clear_surface_color_g = m_clear_color_g;
|
||||
if (a0 & 0x40) m_clear_surface_color_b = m_clear_color_b;
|
||||
if (a0 & 0x80) m_clear_surface_color_a = m_clear_color_a;
|
||||
|
||||
m_clear_surface_mask = a0;
|
||||
clear_surface(a0);
|
||||
break;
|
||||
}
|
||||
|
||||
case NV4097_SET_ZSTENCIL_CLEAR_VALUE:
|
||||
{
|
||||
const u32 value = ARGS(0);
|
||||
m_clear_s = value & 0xff;
|
||||
m_clear_z = value >> 8;
|
||||
break;
|
||||
}
|
||||
|
||||
case NV4097_SET_COLOR_CLEAR_VALUE:
|
||||
{
|
||||
const u32 color = ARGS(0);
|
||||
m_clear_color_a = (color >> 24) & 0xff;
|
||||
m_clear_color_r = (color >> 16) & 0xff;
|
||||
m_clear_color_g = (color >> 8) & 0xff;
|
||||
m_clear_color_b = color & 0xff;
|
||||
break;
|
||||
}
|
||||
|
||||
case NV4097_SET_CLEAR_RECT_HORIZONTAL:
|
||||
{
|
||||
|
|
|
@ -258,18 +258,6 @@ public:
|
|||
|
||||
// Clearing
|
||||
u32 m_clear_surface_mask;
|
||||
u32 m_clear_surface_z;
|
||||
u8 m_clear_surface_s;
|
||||
u8 m_clear_surface_color_r;
|
||||
u8 m_clear_surface_color_g;
|
||||
u8 m_clear_surface_color_b;
|
||||
u8 m_clear_surface_color_a;
|
||||
u8 m_clear_color_r;
|
||||
u8 m_clear_color_g;
|
||||
u8 m_clear_color_b;
|
||||
u8 m_clear_color_a;
|
||||
u8 m_clear_s;
|
||||
u32 m_clear_z;
|
||||
|
||||
// Blending
|
||||
bool m_set_blend;
|
||||
|
@ -509,12 +497,8 @@ protected:
|
|||
|
||||
// Default value
|
||||
// TODO: Check against the default value on PS3
|
||||
m_clear_color_r = 0;
|
||||
m_clear_color_g = 0;
|
||||
m_clear_color_b = 0;
|
||||
m_clear_color_a = 0;
|
||||
m_clear_z = 0xffffff;
|
||||
m_clear_s = 0;
|
||||
rsx::method_registers[NV4097_SET_COLOR_CLEAR_VALUE] = 0;
|
||||
rsx::method_registers[NV4097_SET_ZSTENCIL_CLEAR_VALUE] = 0xffffff << 8;
|
||||
m_poly_offset_scale_factor = 0.0;
|
||||
m_poly_offset_bias = 0.0;
|
||||
m_restart_index = 0xffffffff;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue