gpumemory works

This commit is contained in:
georgemoralis 2023-09-25 12:04:40 +03:00
parent 59efa477ce
commit 1f0beb0ec3
7 changed files with 45 additions and 5 deletions

View File

@ -2,4 +2,7 @@
namespace GPU {
void MemorySetAllocArea(u64 virtual_addr, u64 size) {}
void* memoryCreateObj(u64 submit_id, HLE::Libs::Graphics::GraphicCtx* ctx, void* todo, u64 virtual_addr, u64 size, const GPUObject& info) {
return nullptr;
}
} // namespace GPU

View File

@ -1,9 +1,20 @@
#pragma once
#include <types.h>
#include <Core/PS4/HLE/Graphics/graphics_ctx.h>
namespace GPU {
enum class MemoryMode : u32 { NoAccess = 0, Read = 1, Write = 2, ReadWrite = 3 };
enum class MemoryObjectType : u64 { InvalidObj, VideoOutBufferObj };
void MemorySetAllocArea(u64 virtual_addr, u64 size);
class GPUObject {
public:
GPUObject() = default;
virtual ~GPUObject() = default;
};
void* memoryCreateObj(u64 submit_id, HLE::Libs::Graphics::GraphicCtx* ctx, /*CommandBuffer* buffer*/void* todo, u64 virtual_addr, u64 size,
const GPUObject& info);
} // namespace GPU

View File

@ -1,6 +1,7 @@
#pragma once
#include <types.h>
#include "gpu_memory.h"
namespace GPU {
@ -10,7 +11,7 @@ enum class VideoOutBufferFormat : u64 {
B8G8R8A8Srgb,
};
class VideoOutBufferObj {
class VideoOutBufferObj : public GPUObject {
public:
explicit VideoOutBufferObj(VideoOutBufferFormat pixel_format, u32 width, u32 height, bool is_tiled, bool is_neo, u32 pitch) {
}

View File

@ -2,6 +2,7 @@
#include <Core/PS4/HLE/Graphics/video_out.h>
#include <Lib/Threads.h>
#include <Core/PS4/HLE/Graphics/graphics_ctx.h>
#include <emulator.h>
using namespace HLE::Libs::Graphics::VideoOut;
@ -59,9 +60,19 @@ class VideoOutCtx {
int Open();
VideoConfigInternal* getCtx(int handle);
FlipQueue& getFlipQueue() { return m_flip_queue; }
HLE::Libs::Graphics::GraphicCtx* getGraphicCtx() {
Lib::LockMutexGuard lock(m_mutex);
if (m_graphic_ctx == nullptr) {
m_graphic_ctx = Emulator::getGraphicCtx();
}
return m_graphic_ctx;
}
private:
Lib::Mutex m_mutex;
VideoConfigInternal m_video_out_ctx;
FlipQueue m_flip_queue;
HLE::Libs::Graphics::GraphicCtx* m_graphic_ctx = nullptr;
};
}; // namespace HLE::Graphics::Objects

View File

@ -15,6 +15,7 @@
#include "Objects/video_out_ctx.h"
#include "Util/Singleton.h"
#include "emulator.h"
#include <Core/PS4/GPU/gpu_memory.h>
namespace HLE::Libs::Graphics::VideoOut {
@ -162,7 +163,7 @@ s32 PS4_SYSV_ABI sceVideoOutRegisterBuffers(s32 handle, s32 startIndex, void* co
int registration_index = ctx->buffers_registration_index++;
Emulator::checkAndWaitForGraphicsInit();
// TODO Graphics::RenderCreateCxt();
// TODO Graphics::RenderCreateCtx();
// try to calculate buffer size
u64 buffer_size = 1280 * 720 * 4; // TODO hardcoded value should be redone
@ -197,7 +198,10 @@ s32 PS4_SYSV_ABI sceVideoOutRegisterBuffers(s32 handle, s32 startIndex, void* co
ctx->buffers[i + startIndex].buffer = addresses[i];
ctx->buffers[i + startIndex].buffer_size = buffer_size;
ctx->buffers[i + startIndex].buffer_pitch = buffer_pitch;
// ctx->buffers[i + startIndex].buffer_vulkan = TODO!!!
ctx->buffers[i + startIndex].buffer_render = static_cast<Graphics::VideoOutVulkanImage*>(
GPU::memoryCreateObj(
0, videoOut->getGraphicCtx(), nullptr, reinterpret_cast<uint64_t>(addresses[i]), buffer_size, buffer_info));
LOG_INFO_IF(log_file_videoout, "buffers[{}] = {}\n", i + startIndex, reinterpret_cast<uint64_t>(addresses[i]));
}

View File

@ -1,8 +1,9 @@
#include "emulator.h"
#include "Core/PS4/HLE/Graphics/video_out.h"
#include <vulkan_util.h>
#include <Util/Singleton.h>
#include <vulkan_util.h>
#include "Core/PS4/HLE/Graphics/video_out.h"
namespace Emulator {
@ -91,4 +92,12 @@ void emuRun() {
}
std::exit(0);
}
HLE::Libs::Graphics::GraphicCtx* getGraphicCtx() {
auto* window_ctx = Singleton<Emulator::WindowCtx>::Instance();
Lib::LockMutexGuard lock(window_ctx->m_mutex);
return &window_ctx->m_graphic_ctx;
}
} // namespace Emulator

View File

@ -79,4 +79,5 @@ struct EmuPrivate {
void emuInit(u32 width, u32 height);
void emuRun();
void checkAndWaitForGraphicsInit();
HLE::Libs::Graphics::GraphicCtx* getGraphicCtx();
} // namespace Emulator