Misc fixes (#517)

* Misc fixes

* Removed the skip for draw calls without RTs

* Remove Srgb image stores to rework later
This commit is contained in:
Vladislav Mikhalin 2024-08-21 23:54:23 +03:00 committed by GitHub
parent dfd305ff77
commit 79680c50c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 89 additions and 27 deletions

View File

@ -366,6 +366,9 @@ bool AvPlayerSource::GetAudioData(SceAvPlayerFrameInfo& audio_info) {
} }
u64 AvPlayerSource::CurrentTime() { u64 AvPlayerSource::CurrentTime() {
if (!IsActive()) {
return 0;
}
using namespace std::chrono; using namespace std::chrono;
return duration_cast<milliseconds>(high_resolution_clock::now() - m_start_time).count(); return duration_cast<milliseconds>(high_resolution_clock::now() - m_start_time).count();
} }

View File

@ -6,6 +6,8 @@
#include "core/libraries/libs.h" #include "core/libraries/libs.h"
#include "core/libraries/system/msgdialog.h" #include "core/libraries/system/msgdialog.h"
#include <magic_enum.hpp>
namespace Libraries::MsgDialog { namespace Libraries::MsgDialog {
int PS4_SYSV_ABI sceMsgDialogClose() { int PS4_SYSV_ABI sceMsgDialogClose() {
@ -30,9 +32,22 @@ int PS4_SYSV_ABI sceMsgDialogInitialize() {
s32 PS4_SYSV_ABI sceMsgDialogOpen(const OrbisMsgDialogParam* param) { s32 PS4_SYSV_ABI sceMsgDialogOpen(const OrbisMsgDialogParam* param) {
LOG_ERROR(Lib_MsgDlg, "(STUBBED) called"); LOG_ERROR(Lib_MsgDlg, "(STUBBED) called");
OrbisMsgDialogUserMessageParam* userMsgParam = param->userMsgParam; switch (param->mode) {
const char* msg = userMsgParam->msg; case ORBIS_MSG_DIALOG_MODE_USER_MSG:
printf("sceMsgDialogOpen msg : %s", msg); LOG_INFO(Lib_MsgDlg, "sceMsgDialogOpen userMsg type = %s msg = %s",
magic_enum::enum_name(param->userMsgParam->buttonType), param->userMsgParam->msg);
break;
case ORBIS_MSG_DIALOG_MODE_PROGRESS_BAR:
LOG_INFO(Lib_MsgDlg, "sceMsgDialogOpen progressBar type = %s msg = %s",
magic_enum::enum_name(param->progBarParam->barType), param->progBarParam->msg);
break;
case ORBIS_MSG_DIALOG_MODE_SYSTEM_MSG:
LOG_INFO(Lib_MsgDlg, "sceMsgDialogOpen systemMsg type: %s",
magic_enum::enum_name(param->sysMsgParam->sysMsgType));
break;
default:
break;
}
return ORBIS_OK; return ORBIS_OK;
} }

View File

@ -848,6 +848,7 @@ struct Liverpool {
u32 raw; u32 raw;
BitField<0, 1, u32> depth_clear_enable; BitField<0, 1, u32> depth_clear_enable;
BitField<1, 1, u32> stencil_clear_enable; BitField<1, 1, u32> stencil_clear_enable;
BitField<5, 1, u32> stencil_compress_disable;
BitField<6, 1, u32> depth_compress_disable; BitField<6, 1, u32> depth_compress_disable;
}; };

View File

@ -5,6 +5,8 @@
#include "video_core/amdgpu/pixel_format.h" #include "video_core/amdgpu/pixel_format.h"
#include "video_core/renderer_vulkan/liverpool_to_vk.h" #include "video_core/renderer_vulkan/liverpool_to_vk.h"
#include <magic_enum.hpp>
namespace Vulkan::LiverpoolToVK { namespace Vulkan::LiverpoolToVK {
using DepthBuffer = Liverpool::DepthBuffer; using DepthBuffer = Liverpool::DepthBuffer;
@ -588,6 +590,8 @@ vk::Format AdjustColorBufferFormat(vk::Format base_format,
return is_vo_surface ? vk::Format::eB8G8R8A8Unorm : vk::Format::eB8G8R8A8Srgb; return is_vo_surface ? vk::Format::eB8G8R8A8Unorm : vk::Format::eB8G8R8A8Srgb;
case vk::Format::eB8G8R8A8Srgb: case vk::Format::eB8G8R8A8Srgb:
return is_vo_surface ? vk::Format::eR8G8B8A8Unorm : vk::Format::eR8G8B8A8Srgb; return is_vo_surface ? vk::Format::eR8G8B8A8Unorm : vk::Format::eR8G8B8A8Srgb;
default:
break;
} }
} else { } else {
if (is_vo_surface && base_format == vk::Format::eR8G8B8A8Srgb) { if (is_vo_surface && base_format == vk::Format::eR8G8B8A8Srgb) {
@ -601,27 +605,29 @@ vk::Format AdjustColorBufferFormat(vk::Format base_format,
} }
vk::Format DepthFormat(DepthBuffer::ZFormat z_format, DepthBuffer::StencilFormat stencil_format) { vk::Format DepthFormat(DepthBuffer::ZFormat z_format, DepthBuffer::StencilFormat stencil_format) {
if (z_format == DepthBuffer::ZFormat::Z32Float && using ZFormat = DepthBuffer::ZFormat;
stencil_format == DepthBuffer::StencilFormat::Stencil8) { using StencilFormat = DepthBuffer::StencilFormat;
if (z_format == ZFormat::Z32Float && stencil_format == StencilFormat::Stencil8) {
return vk::Format::eD32SfloatS8Uint; return vk::Format::eD32SfloatS8Uint;
} }
if (z_format == DepthBuffer::ZFormat::Z32Float && if (z_format == ZFormat::Z32Float && stencil_format == StencilFormat::Invalid) {
stencil_format == DepthBuffer::StencilFormat::Invalid) {
return vk::Format::eD32Sfloat; return vk::Format::eD32Sfloat;
} }
if (z_format == DepthBuffer::ZFormat::Z16 && if (z_format == ZFormat::Z16 && stencil_format == StencilFormat::Invalid) {
stencil_format == DepthBuffer::StencilFormat::Invalid) {
return vk::Format::eD16Unorm; return vk::Format::eD16Unorm;
} }
if (z_format == DepthBuffer::ZFormat::Z16 && if (z_format == ZFormat::Z16 && stencil_format == StencilFormat::Stencil8) {
stencil_format == DepthBuffer::StencilFormat::Stencil8) {
return vk::Format::eD16UnormS8Uint; return vk::Format::eD16UnormS8Uint;
} }
if (z_format == DepthBuffer::ZFormat::Invalid && if (z_format == ZFormat::Invalid && stencil_format == StencilFormat::Stencil8) {
stencil_format == DepthBuffer::StencilFormat::Invalid) { return vk::Format::eD32SfloatS8Uint;
}
if (z_format == ZFormat::Invalid && stencil_format == StencilFormat::Invalid) {
return vk::Format::eUndefined; return vk::Format::eUndefined;
} }
UNREACHABLE(); UNREACHABLE_MSG("Unsupported depth/stencil format. depth = {} stencil = {}",
magic_enum::enum_name(z_format), magic_enum::enum_name(stencil_format));
} }
void EmitQuadToTriangleListIndices(u8* out_ptr, u32 num_vertices) { void EmitQuadToTriangleListIndices(u8* out_ptr, u32 num_vertices) {

View File

@ -214,8 +214,7 @@ GraphicsPipeline::GraphicsPipeline(const Instance& instance_, Scheduler& schedul
.colorAttachmentCount = num_color_formats, .colorAttachmentCount = num_color_formats,
.pColorAttachmentFormats = key.color_formats.data(), .pColorAttachmentFormats = key.color_formats.data(),
.depthAttachmentFormat = key.depth_format, .depthAttachmentFormat = key.depth_format,
.stencilAttachmentFormat = .stencilAttachmentFormat = key.stencil_format,
key.depth.stencil_enable ? key.depth_format : vk::Format::eUndefined,
}; };
std::array<vk::PipelineColorBlendAttachmentState, Liverpool::NumColorBuffers> attachments; std::array<vk::PipelineColorBlendAttachmentState, Liverpool::NumColorBuffers> attachments;

View File

@ -26,6 +26,7 @@ struct GraphicsPipelineKey {
std::array<size_t, MaxShaderStages> stage_hashes; std::array<size_t, MaxShaderStages> stage_hashes;
std::array<vk::Format, Liverpool::NumColorBuffers> color_formats; std::array<vk::Format, Liverpool::NumColorBuffers> color_formats;
vk::Format depth_format; vk::Format depth_format;
vk::Format stencil_format;
Liverpool::DepthControl depth; Liverpool::DepthControl depth;
float depth_bounds_min; float depth_bounds_min;

View File

@ -180,11 +180,26 @@ void PipelineCache::RefreshGraphicsKey() {
key.num_samples = regs.aa_config.NumSamples(); key.num_samples = regs.aa_config.NumSamples();
const auto& db = regs.depth_buffer; const auto& db = regs.depth_buffer;
key.depth_format = LiverpoolToVK::DepthFormat(db.z_info.format, db.stencil_info.format); const auto ds_format = LiverpoolToVK::DepthFormat(db.z_info.format, db.stencil_info.format);
if (db.z_info.format != AmdGpu::Liverpool::DepthBuffer::ZFormat::Invalid) {
key.depth_format = ds_format;
} else {
key.depth_format = vk::Format::eUndefined;
}
if (key.depth.depth_enable) { if (key.depth.depth_enable) {
key.depth.depth_enable.Assign(key.depth_format != vk::Format::eUndefined); key.depth.depth_enable.Assign(key.depth_format != vk::Format::eUndefined);
} }
if (db.stencil_info.format != AmdGpu::Liverpool::DepthBuffer::StencilFormat::Invalid) {
key.stencil_format = key.depth_format;
} else {
key.stencil_format = vk::Format::eUndefined;
}
if (key.depth.stencil_enable) {
key.depth.stencil_enable.Assign(key.stencil_format != vk::Format::eUndefined);
}
const auto skip_cb_binding = const auto skip_cb_binding =
regs.color_control.mode == AmdGpu::Liverpool::ColorControl::OperationMode::Disable; regs.color_control.mode == AmdGpu::Liverpool::ColorControl::OperationMode::Disable;

View File

@ -10,6 +10,7 @@
#include "video_core/renderer_vulkan/vk_scheduler.h" #include "video_core/renderer_vulkan/vk_scheduler.h"
#include "video_core/texture_cache/image_view.h" #include "video_core/texture_cache/image_view.h"
#include "video_core/texture_cache/texture_cache.h" #include "video_core/texture_cache/texture_cache.h"
#include "vk_rasterizer.h"
namespace Vulkan { namespace Vulkan {
@ -129,8 +130,12 @@ void Rasterizer::BeginRendering() {
texture_cache.TouchMeta(col_buf.CmaskAddress(), false); texture_cache.TouchMeta(col_buf.CmaskAddress(), false);
} }
if (regs.depth_buffer.z_info.format != Liverpool::DepthBuffer::ZFormat::Invalid && using ZFormat = AmdGpu::Liverpool::DepthBuffer::ZFormat;
regs.depth_buffer.Address() != 0) { using StencilFormat = AmdGpu::Liverpool::DepthBuffer::StencilFormat;
if (regs.depth_buffer.Address() != 0 &&
((regs.depth_control.depth_enable && regs.depth_buffer.z_info.format != ZFormat::Invalid) ||
regs.depth_control.stencil_enable &&
regs.depth_buffer.stencil_info.format != StencilFormat::Invalid)) {
const auto htile_address = regs.depth_htile_data_base.GetAddress(); const auto htile_address = regs.depth_htile_data_base.GetAddress();
const bool is_clear = regs.depth_render_control.depth_clear_enable || const bool is_clear = regs.depth_render_control.depth_clear_enable ||
texture_cache.IsMetaCleared(htile_address); texture_cache.IsMetaCleared(htile_address);
@ -152,8 +157,10 @@ void Rasterizer::BeginRendering() {
.stencil = regs.stencil_clear}}, .stencil = regs.stencil_clear}},
}; };
texture_cache.TouchMeta(htile_address, false); texture_cache.TouchMeta(htile_address, false);
state.has_depth = true; state.has_depth =
state.has_stencil = regs.depth_control.stencil_enable; regs.depth_buffer.z_info.format != AmdGpu::Liverpool::DepthBuffer::ZFormat::Invalid;
state.has_stencil = regs.depth_buffer.stencil_info.format !=
AmdGpu::Liverpool::DepthBuffer::StencilFormat::Invalid;
} }
scheduler.BeginRendering(state); scheduler.BeginRendering(state);
} }

View File

@ -29,15 +29,22 @@ void Scheduler::BeginRendering(const RenderState& new_state) {
is_rendering = true; is_rendering = true;
render_state = new_state; render_state = new_state;
const auto witdh =
render_state.width != std::numeric_limits<u32>::max() ? render_state.width : 1;
const auto height =
render_state.height != std::numeric_limits<u32>::max() ? render_state.height : 1;
const vk::RenderingInfo rendering_info = { const vk::RenderingInfo rendering_info = {
.renderArea = .renderArea =
{ {
.offset = {0, 0}, .offset = {0, 0},
.extent = {render_state.width, render_state.height}, .extent = {witdh, height},
}, },
.layerCount = 1, .layerCount = 1,
.colorAttachmentCount = render_state.num_color_attachments, .colorAttachmentCount = render_state.num_color_attachments,
.pColorAttachments = render_state.color_attachments.data(), .pColorAttachments = render_state.num_color_attachments > 0
? render_state.color_attachments.data()
: nullptr,
.pDepthAttachment = render_state.has_depth ? &render_state.depth_attachment : nullptr, .pDepthAttachment = render_state.has_depth ? &render_state.depth_attachment : nullptr,
.pStencilAttachment = render_state.has_stencil ? &render_state.depth_attachment : nullptr, .pStencilAttachment = render_state.has_stencil ? &render_state.depth_attachment : nullptr,
}; };
@ -72,7 +79,7 @@ void Scheduler::EndRendering() {
}, },
}); });
} }
if (render_state.has_depth) { if (render_state.has_depth || render_state.has_stencil) {
barriers.push_back(vk::ImageMemoryBarrier{ barriers.push_back(vk::ImageMemoryBarrier{
.srcAccessMask = vk::AccessFlagBits::eDepthStencilAttachmentWrite, .srcAccessMask = vk::AccessFlagBits::eDepthStencilAttachmentWrite,
.dstAccessMask = vk::AccessFlagBits::eShaderRead | vk::AccessFlagBits::eShaderWrite, .dstAccessMask = vk::AccessFlagBits::eShaderRead | vk::AccessFlagBits::eShaderWrite,

View File

@ -131,11 +131,19 @@ Image::Image(const Vulkan::Instance& instance_, Vulkan::Scheduler& scheduler_,
usage = ImageUsageFlags(info); usage = ImageUsageFlags(info);
if (info.pixel_format == vk::Format::eD32Sfloat) { switch (info.pixel_format) {
case vk::Format::eD16Unorm:
case vk::Format::eD32Sfloat:
case vk::Format::eX8D24UnormPack32:
aspect_mask = vk::ImageAspectFlagBits::eDepth; aspect_mask = vk::ImageAspectFlagBits::eDepth;
} break;
if (info.pixel_format == vk::Format::eD32SfloatS8Uint) { case vk::Format::eD16UnormS8Uint:
case vk::Format::eD24UnormS8Uint:
case vk::Format::eD32SfloatS8Uint:
aspect_mask = vk::ImageAspectFlagBits::eDepth | vk::ImageAspectFlagBits::eStencil; aspect_mask = vk::ImageAspectFlagBits::eDepth | vk::ImageAspectFlagBits::eStencil;
break;
default:
break;
} }
const vk::ImageCreateInfo image_ci = { const vk::ImageCreateInfo image_ci = {