mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-01-01 04:35:59 +00:00
Clear color attachment if FCE was invoked before any draws (#1851)
* Clear RT if FCE was invoked before any draws Co-authored-by: psucien <bad_cast@protonmail.com> * address review comments --------- Co-authored-by: psucien <bad_cast@protonmail.com>
This commit is contained in:
parent
47c13c2019
commit
fb33238fc5
|
@ -52,7 +52,8 @@ bool Rasterizer::FilterDraw() {
|
||||||
// There are several cases (e.g. FCE, FMask/HTile decompression) where we don't need to do an
|
// There are several cases (e.g. FCE, FMask/HTile decompression) where we don't need to do an
|
||||||
// actual draw hence can skip pipeline creation.
|
// actual draw hence can skip pipeline creation.
|
||||||
if (regs.color_control.mode == Liverpool::ColorControl::OperationMode::EliminateFastClear) {
|
if (regs.color_control.mode == Liverpool::ColorControl::OperationMode::EliminateFastClear) {
|
||||||
LOG_TRACE(Render_Vulkan, "FCE pass skipped");
|
// Clears the render target if FCE is launched before any draws
|
||||||
|
EliminateFastClear();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (regs.color_control.mode == Liverpool::ColorControl::OperationMode::FmaskDecompress) {
|
if (regs.color_control.mode == Liverpool::ColorControl::OperationMode::FmaskDecompress) {
|
||||||
|
@ -201,6 +202,34 @@ RenderState Rasterizer::PrepareRenderState(u32 mrt_mask) {
|
||||||
return {vertex_offset, instance_offset};
|
return {vertex_offset, instance_offset};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Rasterizer::EliminateFastClear() {
|
||||||
|
auto& col_buf = liverpool->regs.color_buffers[0];
|
||||||
|
if (!col_buf || !col_buf.info.fast_clear) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!texture_cache.IsMetaCleared(col_buf.CmaskAddress(), col_buf.view.slice_start)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (u32 slice = col_buf.view.slice_start; slice <= col_buf.view.slice_max; ++slice) {
|
||||||
|
texture_cache.TouchMeta(col_buf.CmaskAddress(), slice, false);
|
||||||
|
}
|
||||||
|
const auto& hint = liverpool->last_cb_extent[0];
|
||||||
|
VideoCore::TextureCache::RenderTargetDesc desc(col_buf, hint);
|
||||||
|
const auto& image_view = texture_cache.FindRenderTarget(desc);
|
||||||
|
const auto& image = texture_cache.GetImage(image_view.image_id);
|
||||||
|
const vk::ImageSubresourceRange range = {
|
||||||
|
.aspectMask = vk::ImageAspectFlagBits::eColor,
|
||||||
|
.baseMipLevel = 0,
|
||||||
|
.levelCount = 1,
|
||||||
|
.baseArrayLayer = col_buf.view.slice_start,
|
||||||
|
.layerCount = col_buf.view.slice_max - col_buf.view.slice_start + 1,
|
||||||
|
};
|
||||||
|
scheduler.EndRendering();
|
||||||
|
scheduler.CommandBuffer().clearColorImage(image.image, vk::ImageLayout::eColorAttachmentOptimal,
|
||||||
|
LiverpoolToVK::ColorBufferClearValue(col_buf).color,
|
||||||
|
range);
|
||||||
|
}
|
||||||
|
|
||||||
void Rasterizer::Draw(bool is_indexed, u32 index_offset) {
|
void Rasterizer::Draw(bool is_indexed, u32 index_offset) {
|
||||||
RENDERER_TRACE;
|
RENDERER_TRACE;
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,7 @@ private:
|
||||||
RenderState PrepareRenderState(u32 mrt_mask);
|
RenderState PrepareRenderState(u32 mrt_mask);
|
||||||
void BeginRendering(const GraphicsPipeline& pipeline, RenderState& state);
|
void BeginRendering(const GraphicsPipeline& pipeline, RenderState& state);
|
||||||
void Resolve();
|
void Resolve();
|
||||||
|
void EliminateFastClear();
|
||||||
|
|
||||||
void UpdateDynamicState(const GraphicsPipeline& pipeline);
|
void UpdateDynamicState(const GraphicsPipeline& pipeline);
|
||||||
void UpdateViewportScissorState();
|
void UpdateViewportScissorState();
|
||||||
|
|
Loading…
Reference in a new issue