diff --git a/src/Core/PS4/GPU/gpu_memory.cpp b/src/Core/PS4/GPU/gpu_memory.cpp index 41a73896..4e92e1fa 100644 --- a/src/Core/PS4/GPU/gpu_memory.cpp +++ b/src/Core/PS4/GPU/gpu_memory.cpp @@ -50,20 +50,28 @@ void* GPU::GPUMemory::memoryCreateObj(u64 submit_id, HLE::Libs::Graphics::Graphi return nullptr; } - ObjInfo obj = {}; + ObjInfo objInfo = {}; // copy parameters from info to obj for (int i = 0; i < 8; i++) { - obj.obj_params[i] = info.obj_params[i]; + objInfo.obj_params[i] = info.obj_params[i]; } - u64 hash[3] = {}; // assuming virtual_addr_num shouldn't be more that 3 + + objInfo.gpu_object.objectType = info.objectType; + objInfo.gpu_object.obj = nullptr; for (int h = 0; h < virtual_addr_num; h++) { - if (info.hasHash) { - hash[h] = GPU::calculate_hash(reinterpret_cast(virtual_addr[h]), size[h]); + if (info.check_hash) { + objInfo.hash[h] = GPU::calculate_hash(reinterpret_cast(virtual_addr[h]), size[h]); } else { - hash[h] = 0; + objInfo.hash[h] = 0; } } + objInfo.submit_id = submit_id; + objInfo.check_hash = info.check_hash; + + objInfo.gpu_object.obj = info.getCreateFunc()(ctx, objInfo.obj_params, virtual_addr, size, virtual_addr_num, &objInfo.mem); + + // TODO we need more ... return nullptr; } diff --git a/src/Core/PS4/GPU/gpu_memory.h b/src/Core/PS4/GPU/gpu_memory.h index a13697f8..05ef74e7 100644 --- a/src/Core/PS4/GPU/gpu_memory.h +++ b/src/Core/PS4/GPU/gpu_memory.h @@ -16,9 +16,21 @@ struct MemoryHeap { u64 allocated_size = 0; }; +struct GpuMemoryObject { + MemoryObjectType objectType = MemoryObjectType::InvalidObj; + void* obj = nullptr; +}; + struct ObjInfo { u64 obj_params[8] = {}; + GpuMemoryObject gpu_object; + u64 hash[3] = {}; + u64 submit_id = 0; + bool check_hash = false; + HLE::Libs::Graphics::VulkanMemory mem; }; + + class GPUMemory { public: GPUMemory() {} @@ -34,10 +46,14 @@ class GPUObject { GPUObject() = default; virtual ~GPUObject() = default; u64 obj_params[8] = {}; - bool hasHash = false; + bool check_hash = false; bool isReadOnly = false; MemoryObjectType objectType = MemoryObjectType::InvalidObj; + using create_func_t = void* (*)(HLE::Libs::Graphics::GraphicCtx* ctx, const u64* params, const u64* vaddr, const u64* size, int vaddr_num, + HLE::Libs::Graphics::VulkanMemory* mem); + + virtual create_func_t getCreateFunc() const = 0; }; void memorySetAllocArea(u64 virtual_addr, u64 size); diff --git a/src/Core/PS4/GPU/video_out_buffer.cpp b/src/Core/PS4/GPU/video_out_buffer.cpp index e69de29b..1f4c8fe3 100644 --- a/src/Core/PS4/GPU/video_out_buffer.cpp +++ b/src/Core/PS4/GPU/video_out_buffer.cpp @@ -0,0 +1,8 @@ +#include "video_out_buffer.h" + +static void* create_func(HLE::Libs::Graphics::GraphicCtx* ctx, const u64* params, const u64* vaddr, const u64* size, int vaddr_num, + HLE::Libs::Graphics::VulkanMemory* mem) { + return nullptr;//TODO +} + +GPU::GPUObject::create_func_t GPU::VideoOutBufferObj::getCreateFunc() const { return create_func; } \ No newline at end of file diff --git a/src/Core/PS4/GPU/video_out_buffer.h b/src/Core/PS4/GPU/video_out_buffer.h index 7d9478b9..65da864b 100644 --- a/src/Core/PS4/GPU/video_out_buffer.h +++ b/src/Core/PS4/GPU/video_out_buffer.h @@ -28,8 +28,10 @@ class VideoOutBufferObj : public GPUObject { obj_params[IS_TILE_PARAM] = is_tiled ? 1 : 0; obj_params[IS_NEO_PARAM] = is_neo ? 1 : 0; obj_params[PITCH_PARAM] = pitch; - hasHash = true; + check_hash = true; objectType = GPU::MemoryObjectType::VideoOutBufferObj; } + + create_func_t getCreateFunc() const override; }; } // namespace GPU