From f469296b788f7f0a32f82c9b47e82337b874263a Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Fri, 22 Sep 2023 10:38:21 +0300 Subject: [PATCH] some video buffer work --- CMakeLists.txt | 2 +- src/Core/PS4/GPU/gpu_memory.h | 4 ++-- src/Core/PS4/GPU/video_out_buffer.cpp | 0 src/Core/PS4/GPU/video_out_buffer.h | 12 ++++++++++++ src/Core/PS4/HLE/Graphics/Objects/video_out_ctx.h | 1 + src/Core/PS4/HLE/Graphics/video_out.cpp | 11 +++++++++++ src/Core/PS4/HLE/Graphics/video_out.h | 7 +++++++ 7 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 src/Core/PS4/GPU/video_out_buffer.cpp create mode 100644 src/Core/PS4/GPU/video_out_buffer.h diff --git a/CMakeLists.txt b/CMakeLists.txt index ef8319ce..d720ec92 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,7 +53,7 @@ add_executable(shadps4 src/Core/PS4/HLE/Kernel/event_queues.h src/Core/PS4/HLE/Kernel/cpu_management.cpp src/Core/PS4/HLE/Kernel/cpu_management.h - "src/Util/Singleton.h" "src/Util/Disassembler.cpp" "src/Util/Disassembler.h" "src/Core/PS4/Util/aerolib.h" "src/Core/PS4/Loader/SymbolsResolver.h" "src/Core/PS4/Loader/SymbolsResolver.cpp" "src/Core/PS4/HLE/Libs.cpp" "src/Core/PS4/HLE/Libs.h" "src/Core/PS4/HLE/LibC.cpp" "src/Core/PS4/HLE/LibC.h" "src/Lib/Timer.cpp" "src/Lib/Timer.h" "src/Core/PS4/HLE/LibKernel.cpp" "src/Core/PS4/HLE/LibKernel.h" "src/Core/PS4/HLE/LibSceGnmDriver.cpp" "src/Core/PS4/HLE/LibSceGnmDriver.h" "src/Core/PS4/HLE/Kernel/ThreadManagement.cpp" "src/Core/PS4/HLE/Kernel/ThreadManagement.h" "src/Core/PS4/HLE/ErrorCodes.h" "src/debug.h" "src/Core/PS4/HLE/Kernel/memory_management.cpp" "src/Core/PS4/HLE/Kernel/memory_management.h" "src/Core/PS4/GPU/gpu_memory.cpp" "src/Core/PS4/GPU/gpu_memory.h" "src/emulator.cpp" "src/emulator.h" "src/Core/PS4/HLE/Kernel/Objects/event_queue.h" "src/Core/PS4/HLE/Kernel/Objects/event_queue.cpp" "src/Core/PS4/HLE/Graphics/Objects/video_out_ctx.cpp" "src/Core/PS4/HLE/Graphics/Objects/video_out_ctx.h" "src/Core/PS4/HLE/Graphics/graphics_ctx.h" "src/vulkan_util.cpp" "src/vulkan_util.h") + "src/Util/Singleton.h" "src/Util/Disassembler.cpp" "src/Util/Disassembler.h" "src/Core/PS4/Util/aerolib.h" "src/Core/PS4/Loader/SymbolsResolver.h" "src/Core/PS4/Loader/SymbolsResolver.cpp" "src/Core/PS4/HLE/Libs.cpp" "src/Core/PS4/HLE/Libs.h" "src/Core/PS4/HLE/LibC.cpp" "src/Core/PS4/HLE/LibC.h" "src/Lib/Timer.cpp" "src/Lib/Timer.h" "src/Core/PS4/HLE/LibKernel.cpp" "src/Core/PS4/HLE/LibKernel.h" "src/Core/PS4/HLE/LibSceGnmDriver.cpp" "src/Core/PS4/HLE/LibSceGnmDriver.h" "src/Core/PS4/HLE/Kernel/ThreadManagement.cpp" "src/Core/PS4/HLE/Kernel/ThreadManagement.h" "src/Core/PS4/HLE/ErrorCodes.h" "src/debug.h" "src/Core/PS4/HLE/Kernel/memory_management.cpp" "src/Core/PS4/HLE/Kernel/memory_management.h" "src/Core/PS4/GPU/gpu_memory.cpp" "src/Core/PS4/GPU/gpu_memory.h" "src/emulator.cpp" "src/emulator.h" "src/Core/PS4/HLE/Kernel/Objects/event_queue.h" "src/Core/PS4/HLE/Kernel/Objects/event_queue.cpp" "src/Core/PS4/HLE/Graphics/Objects/video_out_ctx.cpp" "src/Core/PS4/HLE/Graphics/Objects/video_out_ctx.h" "src/Core/PS4/HLE/Graphics/graphics_ctx.h" "src/vulkan_util.cpp" "src/vulkan_util.h" "src/Core/PS4/GPU/video_out_buffer.cpp" "src/Core/PS4/GPU/video_out_buffer.h") find_package(OpenGL REQUIRED) target_link_libraries(shadps4 PUBLIC fmt mincore spdlog IMGUI SDL3-shared ${OPENGL_LIBRARY} vulkan-1 spirv-tools-opt spirv-tools) diff --git a/src/Core/PS4/GPU/gpu_memory.h b/src/Core/PS4/GPU/gpu_memory.h index 3f667bbf..14084de9 100644 --- a/src/Core/PS4/GPU/gpu_memory.h +++ b/src/Core/PS4/GPU/gpu_memory.h @@ -4,6 +4,6 @@ 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); -} \ No newline at end of file +} // namespace GPU \ No newline at end of file diff --git a/src/Core/PS4/GPU/video_out_buffer.cpp b/src/Core/PS4/GPU/video_out_buffer.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/Core/PS4/GPU/video_out_buffer.h b/src/Core/PS4/GPU/video_out_buffer.h new file mode 100644 index 00000000..d3be8090 --- /dev/null +++ b/src/Core/PS4/GPU/video_out_buffer.h @@ -0,0 +1,12 @@ +#pragma once + +#include + +namespace GPU { + +enum class VideoOutBufferFormat : u64 { + Unknown, + R8G8B8A8Srgb, + B8G8R8A8Srgb, +}; +} diff --git a/src/Core/PS4/HLE/Graphics/Objects/video_out_ctx.h b/src/Core/PS4/HLE/Graphics/Objects/video_out_ctx.h index 8adf22ef..238697f9 100644 --- a/src/Core/PS4/HLE/Graphics/Objects/video_out_ctx.h +++ b/src/Core/PS4/HLE/Graphics/Objects/video_out_ctx.h @@ -17,6 +17,7 @@ struct VideoConfigInternal { std::vector m_flip_evtEq; int m_flip_rate = 0; + std::vector buffers_sets; int buffers_registration_index = 0; }; diff --git a/src/Core/PS4/HLE/Graphics/video_out.cpp b/src/Core/PS4/HLE/Graphics/video_out.cpp index c470df6f..f5ddeb19 100644 --- a/src/Core/PS4/HLE/Graphics/video_out.cpp +++ b/src/Core/PS4/HLE/Graphics/video_out.cpp @@ -165,6 +165,17 @@ s32 PS4_SYSV_ABI sceVideoOutRegisterBuffers(s32 handle, s32 startIndex, void* co u64 buffer_size = 1280 * 720 * 4; //TODO hardcoded value should be redone u64 buffer_pitch = attribute->pitchInPixel; + VideoOutBufferSetInternal buf{}; + + buf.start_index = startIndex; + buf.num = bufferNum; + buf.set_id = registration_index; + buf.attr = *attribute; + + ctx->buffers_sets.push_back(buf); + + + return registration_index; } s32 PS4_SYSV_ABI sceVideoOutSetFlipRate(s32 handle, s32 rate) { diff --git a/src/Core/PS4/HLE/Graphics/video_out.h b/src/Core/PS4/HLE/Graphics/video_out.h index 3ea6fb54..c3250891 100644 --- a/src/Core/PS4/HLE/Graphics/video_out.h +++ b/src/Core/PS4/HLE/Graphics/video_out.h @@ -87,6 +87,13 @@ struct SceVideoOutVblankStatus { u08 pad1[7] = {}; }; +struct VideoOutBufferSetInternal { + SceVideoOutBufferAttribute attr; + int start_index = 0; + int num = 0; + int set_id = 0; +}; + void videoOutInit(u32 width, u32 height); std::string getPixelFormatString(s32 format); void videoOutRegisterLib(SymbolsResolver* sym);