Browse Source

[TEST] Discards on MSAA depth/stencil

tiled-gpu
CamilleLaVey 2 weeks ago
parent
commit
a57041d62f
  1. 7
      src/video_core/renderer_vulkan/vk_scheduler.cpp
  2. 1
      src/video_core/renderer_vulkan/vk_scheduler.h
  3. 3
      src/video_core/renderer_vulkan/vk_texture_cache.cpp
  4. 5
      src/video_core/renderer_vulkan/vk_texture_cache.h

7
src/video_core/renderer_vulkan/vk_scheduler.cpp

@ -107,6 +107,7 @@ void Scheduler::BeginDynamicRendering(const Framebuffer* framebuffer, const Defe
state.color_resolve_views = framebuffer->ColorResolveAttachments(); state.color_resolve_views = framebuffer->ColorResolveAttachments();
state.color_resolve_modes = framebuffer->ColorResolveModes(); state.color_resolve_modes = framebuffer->ColorResolveModes();
state.discards_msaa_color = framebuffer->DiscardsMsaaColor(); state.discards_msaa_color = framebuffer->DiscardsMsaaColor();
state.discards_msaa_depth = framebuffer->DiscardsMsaaDepth();
state.render_area = render_area; state.render_area = render_area;
state.num_color = framebuffer->NumColorAttachments(); state.num_color = framebuffer->NumColorAttachments();
state.has_depth = framebuffer->HasAspectDepthBit(); state.has_depth = framebuffer->HasAspectDepthBit();
@ -449,9 +450,10 @@ void Scheduler::RecordDynamicBegin(const DeferredClear* clear) {
clear ? clear->color_values : std::array<VkClearValue, 8>{}; clear ? clear->color_values : std::array<VkClearValue, 8>{};
const bool ds_clear = clear != nullptr && clear->depth_stencil; const bool ds_clear = clear != nullptr && clear->depth_stencil;
const VkClearValue ds_clear_value = clear ? clear->depth_stencil_value : VkClearValue{}; const VkClearValue ds_clear_value = clear ? clear->depth_stencil_value : VkClearValue{};
const bool ds_discard = state.discards_msaa_depth;
Record([views, resolve_views, resolve_modes, num_color, has_depth, has_stencil, layers, Record([views, resolve_views, resolve_modes, num_color, has_depth, has_stencil, layers,
render_area, color_clear_mask, color_discard_mask, color_clear_values, ds_clear, render_area, color_clear_mask, color_discard_mask, color_clear_values, ds_clear,
ds_clear_value](vk::CommandBuffer cmdbuf) {
ds_clear_value, ds_discard](vk::CommandBuffer cmdbuf) {
std::array<VkRenderingAttachmentInfo, VideoCommon::NUM_RT> color_infos{}; std::array<VkRenderingAttachmentInfo, VideoCommon::NUM_RT> color_infos{};
for (u32 index = 0; index < num_color; ++index) { for (u32 index = 0; index < num_color; ++index) {
const bool clear_slot = ((color_clear_mask >> index) & 1u) != 0; const bool clear_slot = ((color_clear_mask >> index) & 1u) != 0;
@ -482,7 +484,8 @@ void Scheduler::RecordDynamicBegin(const DeferredClear* clear) {
.resolveImageView = VK_NULL_HANDLE, .resolveImageView = VK_NULL_HANDLE,
.resolveImageLayout = VK_IMAGE_LAYOUT_UNDEFINED, .resolveImageLayout = VK_IMAGE_LAYOUT_UNDEFINED,
.loadOp = ds_clear ? VK_ATTACHMENT_LOAD_OP_CLEAR : VK_ATTACHMENT_LOAD_OP_LOAD, .loadOp = ds_clear ? VK_ATTACHMENT_LOAD_OP_CLEAR : VK_ATTACHMENT_LOAD_OP_LOAD,
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
.storeOp = ds_discard ? VK_ATTACHMENT_STORE_OP_DONT_CARE
: VK_ATTACHMENT_STORE_OP_STORE,
.clearValue = ds_clear ? ds_clear_value : VkClearValue{}, .clearValue = ds_clear ? ds_clear_value : VkClearValue{},
}; };
const VkRenderingInfo rendering_info{ const VkRenderingInfo rendering_info{

1
src/video_core/renderer_vulkan/vk_scheduler.h

@ -257,6 +257,7 @@ private:
GraphicsPipeline* graphics_pipeline = nullptr; GraphicsPipeline* graphics_pipeline = nullptr;
bool rendering = false; bool rendering = false;
bool discards_msaa_color = false; bool discards_msaa_color = false;
bool discards_msaa_depth = false;
u32 num_color = 0; u32 num_color = 0;
bool has_depth = false; bool has_depth = false;
bool has_stencil = false; bool has_stencil = false;

3
src/video_core/renderer_vulkan/vk_texture_cache.cpp

@ -54,6 +54,7 @@ using VideoCore::Surface::SurfaceType;
namespace { namespace {
constexpr bool ENABLE_MSAA_RESOLVE_CONSUME = true; constexpr bool ENABLE_MSAA_RESOLVE_CONSUME = true;
constexpr bool ENABLE_MSAA_COLOR_DISCARD = true; constexpr bool ENABLE_MSAA_COLOR_DISCARD = true;
constexpr bool ENABLE_MSAA_DEPTH_DISCARD = true;
constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) { constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) {
if (color == std::array<float, 4>{0, 0, 0, 0}) { if (color == std::array<float, 4>{0, 0, 0, 0}) {
@ -2791,6 +2792,8 @@ void Framebuffer::CreateFramebuffer(TextureCacheRuntime& runtime,
discard_msaa_color = discard_msaa_color =
ENABLE_MSAA_RESOLVE_CONSUME && ENABLE_MSAA_COLOR_DISCARD && do_resolve_color; ENABLE_MSAA_RESOLVE_CONSUME && ENABLE_MSAA_COLOR_DISCARD && do_resolve_color;
discard_msaa_depth = ENABLE_MSAA_RESOLVE_CONSUME && ENABLE_MSAA_DEPTH_DISCARD &&
samples != VK_SAMPLE_COUNT_1_BIT && has_depth && runtime.device.IsTiler();
render_pass_key = renderpass_key; render_pass_key = renderpass_key;
render_pass_cache = &runtime.render_pass_cache; render_pass_cache = &runtime.render_pass_cache;

5
src/video_core/renderer_vulkan/vk_texture_cache.h

@ -280,6 +280,10 @@ public:
return discard_msaa_color; return discard_msaa_color;
} }
[[nodiscard]] bool DiscardsMsaaDepth() const noexcept {
return discard_msaa_depth;
}
private: private:
vk::Framebuffer framebuffer; vk::Framebuffer framebuffer;
VkRenderPass renderpass{}; VkRenderPass renderpass{};
@ -306,6 +310,7 @@ private:
RenderPassKey render_pass_key{}; RenderPassKey render_pass_key{};
RenderPassCache* render_pass_cache{nullptr}; RenderPassCache* render_pass_cache{nullptr};
bool discard_msaa_color{}; bool discard_msaa_color{};
bool discard_msaa_depth{};
}; };
class Image : public VideoCommon::ImageBase { class Image : public VideoCommon::ImageBase {

Loading…
Cancel
Save