Merge pull request #150 from shadps4-emu/stabilization_one

video_core: various fixes
This commit is contained in:
georgemoralis 2024-05-29 23:58:52 +03:00 committed by GitHub
commit 10bceb1643
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 31 additions and 30 deletions

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#include <cmath> #include <cmath>
#include "common/assert.h"
#include "core/libraries/libc/libc_math.h" #include "core/libraries/libc/libc_math.h"
namespace Libraries::LibC { namespace Libraries::LibC {
@ -38,8 +39,13 @@ double PS4_SYSV_ABI ps4__Sin(double x) {
return sin(x); return sin(x);
} }
float PS4_SYSV_ABI ps4__Fsin(float arg) { float PS4_SYSV_ABI ps4__Fsin(float arg, unsigned int m, int n) {
return sinf(arg); ASSERT(n == 0);
if (m != 0) {
return cosf(arg);
} else {
return sinf(arg);
}
} }
double PS4_SYSV_ABI ps4_exp2(double arg) { double PS4_SYSV_ABI ps4_exp2(double arg) {

View File

@ -13,7 +13,7 @@ float PS4_SYSV_ABI ps4_tanf(float num);
float PS4_SYSV_ABI ps4_asinf(float num); float PS4_SYSV_ABI ps4_asinf(float num);
double PS4_SYSV_ABI ps4_pow(double base, double exponent); double PS4_SYSV_ABI ps4_pow(double base, double exponent);
double PS4_SYSV_ABI ps4__Sin(double x); double PS4_SYSV_ABI ps4__Sin(double x);
float PS4_SYSV_ABI ps4__Fsin(float arg); float PS4_SYSV_ABI ps4__Fsin(float arg, unsigned int, int);
double PS4_SYSV_ABI ps4_exp2(double arg); double PS4_SYSV_ABI ps4_exp2(double arg);
float PS4_SYSV_ABI ps4_powf(float x, float y); float PS4_SYSV_ABI ps4_powf(float x, float y);
float PS4_SYSV_ABI ps4_roundf(float arg); float PS4_SYSV_ABI ps4_roundf(float arg);

View File

@ -18,7 +18,7 @@ struct VideoOutPort {
bool is_open = false; bool is_open = false;
SceVideoOutResolutionStatus resolution; SceVideoOutResolutionStatus resolution;
std::array<VideoOutBuffer, MaxDisplayBuffers> buffer_slots; std::array<VideoOutBuffer, MaxDisplayBuffers> buffer_slots;
std::array<uintptr_t, MaxDisplayBuffers> buffer_labels; // should be contiguous in memory std::array<u64, MaxDisplayBuffers> buffer_labels; // should be contiguous in memory
static_assert(sizeof(buffer_labels[0]) == 8u); static_assert(sizeof(buffer_labels[0]) == 8u);
std::array<BufferAttributeGroup, MaxDisplayBufferGroups> groups; std::array<BufferAttributeGroup, MaxDisplayBufferGroups> groups;
FlipStatus flip_status; FlipStatus flip_status;

View File

@ -251,6 +251,7 @@ s32 sceVideoOutSubmitEopFlip(s32 handle, u32 buf_id, u32 mode, u32 arg, void** u
Platform::IrqC::Instance()->RegisterOnce( Platform::IrqC::Instance()->RegisterOnce(
Platform::InterruptId::GfxFlip, [=](Platform::InterruptId irq) { Platform::InterruptId::GfxFlip, [=](Platform::InterruptId irq) {
ASSERT_MSG(irq == Platform::InterruptId::GfxFlip, "An unexpected IRQ occured"); ASSERT_MSG(irq == Platform::InterruptId::GfxFlip, "An unexpected IRQ occured");
ASSERT_MSG(port->buffer_labels[buf_id] == 1, "Out of order flip IRQ");
const auto result = driver->SubmitFlip(port, buf_id, arg, true); const auto result = driver->SubmitFlip(port, buf_id, arg, true);
ASSERT_MSG(result, "EOP flip submission failed"); ASSERT_MSG(result, "EOP flip submission failed");
}); });

View File

@ -66,7 +66,7 @@ struct IrqController {
h(irq); h(irq);
} }
while (!ctx.one_time_subscribers.empty()) { if (!ctx.one_time_subscribers.empty()) {
const auto& h = ctx.one_time_subscribers.front(); const auto& h = ctx.one_time_subscribers.front();
h(irq); h(irq);

View File

@ -18,17 +18,16 @@ Liverpool::Liverpool() {
Liverpool::~Liverpool() { Liverpool::~Liverpool() {
process_thread.request_stop(); process_thread.request_stop();
cv_submit.notify_one(); num_submits = -1;
num_submits.notify_one();
process_thread.join();
} }
void Liverpool::Process(std::stop_token stoken) { void Liverpool::Process(std::stop_token stoken) {
Common::SetCurrentThreadName("GPU_CommandProcessor"); Common::SetCurrentThreadName("GPU_CommandProcessor");
while (!stoken.stop_requested()) { while (!stoken.stop_requested()) {
{ num_submits.wait(0);
std::unique_lock lock{m_submit};
cv_submit.wait(lock, stoken, [this]() { return num_submits != 0; });
}
if (stoken.stop_requested()) { if (stoken.stop_requested()) {
break; break;
@ -62,13 +61,14 @@ void Liverpool::Process(std::stop_token stoken) {
--num_submits; --num_submits;
} }
} }
cv_complete.notify_all(); // Notify GPU idle num_submits.notify_all();
} }
} }
void Liverpool::WaitGpuIdle() { void Liverpool::WaitGpuIdle() {
std::unique_lock lock{m_submit}; while (const auto old = num_submits.load()) {
cv_complete.wait(lock, [this]() { return num_submits == 0; }); num_submits.wait(old);
}
} }
Liverpool::Task Liverpool::ProcessCeUpdate(std::span<const u32> ccb) { Liverpool::Task Liverpool::ProcessCeUpdate(std::span<const u32> ccb) {
@ -308,11 +308,8 @@ void Liverpool::SubmitGfx(std::span<const u32> dcb, std::span<const u32> ccb) {
queue.submits.emplace(task.handle); queue.submits.emplace(task.handle);
} }
{ ++num_submits;
std::unique_lock lock{m_submit}; num_submits.notify_one();
++num_submits;
}
cv_submit.notify_one();
} }
void Liverpool::SubmitAsc(u32 vqid, std::span<const u32> acb) { void Liverpool::SubmitAsc(u32 vqid, std::span<const u32> acb) {
@ -325,11 +322,8 @@ void Liverpool::SubmitAsc(u32 vqid, std::span<const u32> acb) {
queue.submits.emplace(task.handle); queue.submits.emplace(task.handle);
} }
{ ++num_submits;
std::unique_lock lock{m_submit}; num_submits.notify_one();
++num_submits;
}
cv_submit.notify_one();
} }
} // namespace AmdGpu } // namespace AmdGpu

View File

@ -771,9 +771,6 @@ private:
Vulkan::Rasterizer* rasterizer{}; Vulkan::Rasterizer* rasterizer{};
std::jthread process_thread{}; std::jthread process_thread{};
std::condition_variable_any cv_submit{};
std::condition_variable cv_complete{};
std::mutex m_submit{};
std::atomic<u32> num_submits{}; std::atomic<u32> num_submits{};
}; };

View File

@ -206,6 +206,7 @@ bool Instance::CreateDevice() {
}, },
vk::PhysicalDeviceVulkan13Features{ vk::PhysicalDeviceVulkan13Features{
.dynamicRendering = true, .dynamicRendering = true,
.maintenance4 = true,
}, },
vk::PhysicalDeviceCustomBorderColorFeaturesEXT{ vk::PhysicalDeviceCustomBorderColorFeaturesEXT{
.customBorderColors = true, .customBorderColors = true,
@ -214,9 +215,6 @@ bool Instance::CreateDevice() {
vk::PhysicalDeviceIndexTypeUint8FeaturesEXT{ vk::PhysicalDeviceIndexTypeUint8FeaturesEXT{
.indexTypeUint8 = true, .indexTypeUint8 = true,
}, },
vk::PhysicalDeviceMaintenance4Features{
.maintenance4 = true,
},
}; };
if (!index_type_uint8) { if (!index_type_uint8) {

View File

@ -53,9 +53,14 @@ struct UniqueImage {
UniqueImage(const UniqueImage&) = delete; UniqueImage(const UniqueImage&) = delete;
UniqueImage& operator=(const UniqueImage&) = delete; UniqueImage& operator=(const UniqueImage&) = delete;
UniqueImage(UniqueImage&& other) : image{std::exchange(other.image, VK_NULL_HANDLE)} {} UniqueImage(UniqueImage&& other)
: image{std::exchange(other.image, VK_NULL_HANDLE)},
allocator{std::exchange(other.allocator, VK_NULL_HANDLE)},
allocation{std::exchange(other.allocation, VK_NULL_HANDLE)} {}
UniqueImage& operator=(UniqueImage&& other) { UniqueImage& operator=(UniqueImage&& other) {
image = std::exchange(other.image, VK_NULL_HANDLE); image = std::exchange(other.image, VK_NULL_HANDLE);
allocator = std::exchange(other.allocator, VK_NULL_HANDLE);
allocation = std::exchange(other.allocation, VK_NULL_HANDLE);
return *this; return *this;
} }