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
#include <cmath>
#include "common/assert.h"
#include "core/libraries/libc/libc_math.h"
namespace Libraries::LibC {
@ -38,9 +39,14 @@ double PS4_SYSV_ABI ps4__Sin(double 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) {
ASSERT(n == 0);
if (m != 0) {
return cosf(arg);
} else {
return sinf(arg);
}
}
double PS4_SYSV_ABI ps4_exp2(double arg) {
return exp2(arg);

View File

@ -13,7 +13,7 @@ float PS4_SYSV_ABI ps4_tanf(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__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);
float PS4_SYSV_ABI ps4_powf(float x, float y);
float PS4_SYSV_ABI ps4_roundf(float arg);

View File

@ -18,7 +18,7 @@ struct VideoOutPort {
bool is_open = false;
SceVideoOutResolutionStatus resolution;
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);
std::array<BufferAttributeGroup, MaxDisplayBufferGroups> groups;
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::InterruptId::GfxFlip, [=](Platform::InterruptId irq) {
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);
ASSERT_MSG(result, "EOP flip submission failed");
});

View File

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

View File

@ -18,17 +18,16 @@ Liverpool::Liverpool() {
Liverpool::~Liverpool() {
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) {
Common::SetCurrentThreadName("GPU_CommandProcessor");
while (!stoken.stop_requested()) {
{
std::unique_lock lock{m_submit};
cv_submit.wait(lock, stoken, [this]() { return num_submits != 0; });
}
num_submits.wait(0);
if (stoken.stop_requested()) {
break;
@ -62,13 +61,14 @@ void Liverpool::Process(std::stop_token stoken) {
--num_submits;
}
}
cv_complete.notify_all(); // Notify GPU idle
num_submits.notify_all();
}
}
void Liverpool::WaitGpuIdle() {
std::unique_lock lock{m_submit};
cv_complete.wait(lock, [this]() { return num_submits == 0; });
while (const auto old = num_submits.load()) {
num_submits.wait(old);
}
}
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);
}
{
std::unique_lock lock{m_submit};
++num_submits;
}
cv_submit.notify_one();
num_submits.notify_one();
}
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);
}
{
std::unique_lock lock{m_submit};
++num_submits;
}
cv_submit.notify_one();
num_submits.notify_one();
}
} // namespace AmdGpu

View File

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

View File

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

View File

@ -53,9 +53,14 @@ struct UniqueImage {
UniqueImage(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) {
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;
}