mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2024-12-28 18:46:06 +00:00
renderer_vulkan: Bind null color attachments when target is masked out. (#1740)
* renderer_vulkan: Bind null color attachments when target is masked out. * Simplify setting null color attachment
This commit is contained in:
parent
8db1beaec6
commit
e612e881ac
|
@ -279,7 +279,7 @@ bool PipelineCache::RefreshGraphicsKey() {
|
||||||
// recompiler.
|
// recompiler.
|
||||||
for (auto cb = 0u, remapped_cb = 0u; cb < Liverpool::NumColorBuffers; ++cb) {
|
for (auto cb = 0u, remapped_cb = 0u; cb < Liverpool::NumColorBuffers; ++cb) {
|
||||||
auto const& col_buf = regs.color_buffers[cb];
|
auto const& col_buf = regs.color_buffers[cb];
|
||||||
if (skip_cb_binding || !col_buf) {
|
if (skip_cb_binding || !col_buf || !regs.color_target_mask.GetMask(cb)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const auto base_format =
|
const auto base_format =
|
||||||
|
@ -385,7 +385,8 @@ bool PipelineCache::RefreshGraphicsKey() {
|
||||||
// Second pass to fill remain CB pipeline key data
|
// Second pass to fill remain CB pipeline key data
|
||||||
for (auto cb = 0u, remapped_cb = 0u; cb < Liverpool::NumColorBuffers; ++cb) {
|
for (auto cb = 0u, remapped_cb = 0u; cb < Liverpool::NumColorBuffers; ++cb) {
|
||||||
auto const& col_buf = regs.color_buffers[cb];
|
auto const& col_buf = regs.color_buffers[cb];
|
||||||
if (skip_cb_binding || !col_buf || (key.mrt_mask & (1u << cb)) == 0) {
|
if (skip_cb_binding || !col_buf || !regs.color_target_mask.GetMask(cb) ||
|
||||||
|
(key.mrt_mask & (1u << cb)) == 0) {
|
||||||
key.color_formats[cb] = vk::Format::eUndefined;
|
key.color_formats[cb] = vk::Format::eUndefined;
|
||||||
key.mrt_swizzles[cb] = Liverpool::ColorBuffer::SwapMode::Standard;
|
key.mrt_swizzles[cb] = Liverpool::ColorBuffer::SwapMode::Standard;
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -103,6 +103,14 @@ RenderState Rasterizer::PrepareRenderState(u32 mrt_mask) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the color buffer is still bound but rendering to it is disabled by the target
|
||||||
|
// mask, we need to prevent the render area from being affected by unbound render target
|
||||||
|
// extents.
|
||||||
|
if (!regs.color_target_mask.GetMask(col_buf_id)) {
|
||||||
|
state.color_attachments[state.num_color_attachments++].imageView = VK_NULL_HANDLE;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const auto& hint = liverpool->last_cb_extent[col_buf_id];
|
const auto& hint = liverpool->last_cb_extent[col_buf_id];
|
||||||
auto& [image_id, desc] = cb_descs.emplace_back(std::piecewise_construct, std::tuple{},
|
auto& [image_id, desc] = cb_descs.emplace_back(std::piecewise_construct, std::tuple{},
|
||||||
std::tuple{col_buf, hint});
|
std::tuple{col_buf, hint});
|
||||||
|
@ -118,7 +126,6 @@ RenderState Rasterizer::PrepareRenderState(u32 mrt_mask) {
|
||||||
const auto mip = image_view.info.range.base.level;
|
const auto mip = image_view.info.range.base.level;
|
||||||
state.width = std::min<u32>(state.width, std::max(image.info.size.width >> mip, 1u));
|
state.width = std::min<u32>(state.width, std::max(image.info.size.width >> mip, 1u));
|
||||||
state.height = std::min<u32>(state.height, std::max(image.info.size.height >> mip, 1u));
|
state.height = std::min<u32>(state.height, std::max(image.info.size.height >> mip, 1u));
|
||||||
state.color_images[state.num_color_attachments] = image.image;
|
|
||||||
state.color_attachments[state.num_color_attachments++] = {
|
state.color_attachments[state.num_color_attachments++] = {
|
||||||
.imageView = *image_view.image_view,
|
.imageView = *image_view.image_view,
|
||||||
.imageLayout = vk::ImageLayout::eUndefined,
|
.imageLayout = vk::ImageLayout::eUndefined,
|
||||||
|
@ -153,7 +160,6 @@ RenderState Rasterizer::PrepareRenderState(u32 mrt_mask) {
|
||||||
|
|
||||||
state.width = std::min<u32>(state.width, image.info.size.width);
|
state.width = std::min<u32>(state.width, image.info.size.width);
|
||||||
state.height = std::min<u32>(state.height, image.info.size.height);
|
state.height = std::min<u32>(state.height, image.info.size.height);
|
||||||
state.depth_image = image.image;
|
|
||||||
state.depth_attachment = {
|
state.depth_attachment = {
|
||||||
.imageView = *image_view.image_view,
|
.imageView = *image_view.image_view,
|
||||||
.imageLayout = vk::ImageLayout::eUndefined,
|
.imageLayout = vk::ImageLayout::eUndefined,
|
||||||
|
@ -716,7 +722,6 @@ void Rasterizer::BeginRendering(const GraphicsPipeline& pipeline, RenderState& s
|
||||||
auto& image = texture_cache.GetImage(view.image_id);
|
auto& image = texture_cache.GetImage(view.image_id);
|
||||||
state.color_attachments[cb_index].imageView = *view.image_view;
|
state.color_attachments[cb_index].imageView = *view.image_view;
|
||||||
state.color_attachments[cb_index].imageLayout = image.last_state.layout;
|
state.color_attachments[cb_index].imageLayout = image.last_state.layout;
|
||||||
state.color_images[cb_index] = image.image;
|
|
||||||
|
|
||||||
const auto mip = view.info.range.base.level;
|
const auto mip = view.info.range.base.level;
|
||||||
state.width = std::min<u32>(state.width, std::max(image.info.size.width >> mip, 1u));
|
state.width = std::min<u32>(state.width, std::max(image.info.size.width >> mip, 1u));
|
||||||
|
|
|
@ -20,9 +20,7 @@ class Instance;
|
||||||
|
|
||||||
struct RenderState {
|
struct RenderState {
|
||||||
std::array<vk::RenderingAttachmentInfo, 8> color_attachments{};
|
std::array<vk::RenderingAttachmentInfo, 8> color_attachments{};
|
||||||
std::array<vk::Image, 8> color_images{};
|
|
||||||
vk::RenderingAttachmentInfo depth_attachment{};
|
vk::RenderingAttachmentInfo depth_attachment{};
|
||||||
vk::Image depth_image{};
|
|
||||||
u32 num_color_attachments{};
|
u32 num_color_attachments{};
|
||||||
bool has_depth{};
|
bool has_depth{};
|
||||||
bool has_stencil{};
|
bool has_stencil{};
|
||||||
|
|
Loading…
Reference in a new issue