Merge pull request #68 from GPUCode/main
cmake: Refactor third party library management
This commit is contained in:
commit
89cf4dbfcb
118
CMakeLists.txt
118
CMakeLists.txt
|
@ -1,27 +1,33 @@
|
||||||
cmake_minimum_required(VERSION 3.16.3)
|
cmake_minimum_required(VERSION 3.16.3)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||||
|
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
if (NOT CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_BUILD_TYPE Release)
|
set(CMAKE_BUILD_TYPE Release)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
project(shadps4)
|
project(shadps4)
|
||||||
|
|
||||||
include_directories(third-party/)
|
# This function should be passed a list of all files in a target. It will automatically generate
|
||||||
include_directories(third-party/discord-rpc/include)
|
# file groups following the directory hierarchy, so that the layout of the files in IDEs matches the
|
||||||
include_directories(third-party/imgui/)
|
# one in the filesystem.
|
||||||
include_directories(third-party/imgui/backends)
|
function(create_target_directory_groups target_name)
|
||||||
include_directories(third-party/sdl/)
|
# Place any files that aren't in the source list in a separate group so that they don't get in
|
||||||
include_directories(third-party/fmt/include)
|
# the way.
|
||||||
include_directories(third-party/magic_enum/include)
|
source_group("Other Files" REGULAR_EXPRESSION ".")
|
||||||
include_directories(third-party/zydis/include/Zydis)
|
|
||||||
include_directories(third-party/winpthread/include)
|
get_target_property(target_sources "${target_name}" SOURCES)
|
||||||
include_directories(third-party/vulkan/include)
|
|
||||||
include_directories(third-party/xxhash/include)
|
foreach(file_name IN LISTS target_sources)
|
||||||
include_directories(third-party/result/include)
|
get_filename_component(dir_name "${file_name}" PATH)
|
||||||
add_subdirectory("third-party")
|
# Group names use '\' as a separator even though the entire rest of CMake uses '/'...
|
||||||
#=================== EXAMPLE ===================
|
string(REPLACE "/" "\\" group_name "${dir_name}")
|
||||||
|
source_group("${group_name}" FILES "${file_name}")
|
||||||
|
endforeach()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
add_subdirectory(third-party)
|
||||||
include_directories(src)
|
include_directories(src)
|
||||||
|
|
||||||
set(LIBC_SOURCES src/core/hle/libraries/Libc/Libc.cpp
|
set(LIBC_SOURCES src/core/hle/libraries/Libc/Libc.cpp
|
||||||
|
@ -52,38 +58,41 @@ set(SYSTEMSERVICE_SOURCES src/core/hle/libraries/libsystemservice/system_service
|
||||||
)
|
)
|
||||||
|
|
||||||
set(FILESYSTEM_SOURCES src/core/hle/libraries/libkernel/file_system.cpp
|
set(FILESYSTEM_SOURCES src/core/hle/libraries/libkernel/file_system.cpp
|
||||||
src/core/hle/libraries/libkernel/file_system.h
|
src/core/hle/libraries/libkernel/file_system.h
|
||||||
|
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set(HOST_SOURCES src/Emulator/Host/controller.cpp
|
set(HOST_SOURCES src/Emulator/Host/controller.cpp
|
||||||
src/Emulator/Host/controller.h
|
src/Emulator/Host/controller.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(UTIL_SOURCES src/Emulator/Util/singleton.h
|
|
||||||
)
|
|
||||||
|
|
||||||
add_executable(shadps4
|
add_executable(shadps4
|
||||||
|
src/common/debug.h
|
||||||
|
src/common/disassembler.cpp
|
||||||
|
src/common/disassembler.h
|
||||||
|
src/common/discord.cpp
|
||||||
|
src/common/discord.h
|
||||||
|
src/common/fs_file.cpp
|
||||||
|
src/common/fs_file.h
|
||||||
|
src/common/log.cpp
|
||||||
|
src/common/log.h
|
||||||
|
src/common/singleton.h
|
||||||
|
src/common/string_util.cpp
|
||||||
|
src/common/string_util.h
|
||||||
|
src/common/types.h
|
||||||
|
src/common/version.h
|
||||||
${LIBC_SOURCES}
|
${LIBC_SOURCES}
|
||||||
${USERSERVICE_SOURCES}
|
${USERSERVICE_SOURCES}
|
||||||
${PAD_SOURCES}
|
${PAD_SOURCES}
|
||||||
${SYSTEMSERVICE_SOURCES}
|
${SYSTEMSERVICE_SOURCES}
|
||||||
${FILESYSTEM_SOURCES}
|
${FILESYSTEM_SOURCES}
|
||||||
${HOST_SOURCES}
|
${HOST_SOURCES}
|
||||||
${UTIL_SOURCES}
|
|
||||||
src/Lib/Timer.cpp
|
src/Lib/Timer.cpp
|
||||||
src/Lib/Timer.h
|
src/Lib/Timer.h
|
||||||
src/main.cpp
|
src/main.cpp
|
||||||
src/types.h
|
|
||||||
src/core/FsFile.cpp
|
|
||||||
src/core/FsFile.h
|
|
||||||
src/core/PS4/Loader/Elf.cpp
|
src/core/PS4/Loader/Elf.cpp
|
||||||
src/core/PS4/Loader/Elf.h
|
src/core/PS4/Loader/Elf.h
|
||||||
src/GUI/ElfViewer.cpp
|
src/GUI/ElfViewer.cpp
|
||||||
src/GUI/ElfViewer.h
|
src/GUI/ElfViewer.h
|
||||||
src/Util/log.h
|
|
||||||
src/Util/log.cpp
|
|
||||||
src/Util/config.cpp
|
src/Util/config.cpp
|
||||||
src/Util/config.h
|
src/Util/config.h
|
||||||
src/core/virtual_memory.cpp
|
src/core/virtual_memory.cpp
|
||||||
|
@ -95,23 +104,56 @@ add_executable(shadps4
|
||||||
src/core/PS4/Util/aerolib.cpp
|
src/core/PS4/Util/aerolib.cpp
|
||||||
src/core/PS4/HLE/Kernel/Objects/physical_memory.h
|
src/core/PS4/HLE/Kernel/Objects/physical_memory.h
|
||||||
src/core/PS4/HLE/Kernel/Objects/physical_memory.cpp
|
src/core/PS4/HLE/Kernel/Objects/physical_memory.cpp
|
||||||
src/Util/string_util.cpp
|
|
||||||
src/Util/string_util.cpp
|
|
||||||
src/core/PS4/HLE/Graphics/video_out.cpp
|
src/core/PS4/HLE/Graphics/video_out.cpp
|
||||||
src/core/PS4/HLE/Graphics/video_out.h
|
src/core/PS4/HLE/Graphics/video_out.h
|
||||||
src/discord.h
|
|
||||||
src/discord.cpp
|
|
||||||
src/core/PS4/HLE/Kernel/event_queues.cpp
|
src/core/PS4/HLE/Kernel/event_queues.cpp
|
||||||
src/core/PS4/HLE/Kernel/event_queues.h
|
src/core/PS4/HLE/Kernel/event_queues.h
|
||||||
src/core/PS4/HLE/Kernel/cpu_management.cpp
|
src/core/PS4/HLE/Kernel/cpu_management.cpp
|
||||||
src/core/PS4/HLE/Kernel/cpu_management.h
|
src/core/PS4/HLE/Kernel/cpu_management.h
|
||||||
|
src/core/PS4/Util/aerolib.h
|
||||||
|
src/core/PS4/Loader/SymbolsResolver.h
|
||||||
|
src/core/PS4/Loader/SymbolsResolver.cpp
|
||||||
"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/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" "src/core/PS4/HLE/Graphics/graphics_render.cpp" "src/core/PS4/HLE/Graphics/graphics_render.h" "src/core/PS4/GPU/tile_manager.cpp" "src/core/PS4/GPU/tile_manager.h" "src/version.h" "src/emuTimer.cpp" "src/emuTimer.h" "src/core/hle/libraries/libkernel/time_management.cpp" "src/core/hle/libraries/libkernel/time_management.h")
|
src/core/PS4/HLE/Libs.cpp
|
||||||
|
src/core/PS4/HLE/Libs.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/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
|
||||||
|
src/core/PS4/HLE/Graphics/graphics_render.cpp
|
||||||
|
src/core/PS4/HLE/Graphics/graphics_render.h
|
||||||
|
src/core/PS4/GPU/tile_manager.cpp
|
||||||
|
src/core/PS4/GPU/tile_manager.h
|
||||||
|
src/emuTimer.cpp
|
||||||
|
src/emuTimer.h
|
||||||
|
src/core/hle/libraries/libkernel/time_management.cpp
|
||||||
|
src/core/hle/libraries/libkernel/time_management.h
|
||||||
|
)
|
||||||
|
|
||||||
find_package(OpenGL REQUIRED)
|
create_target_directory_groups(shadps4)
|
||||||
target_link_libraries(shadps4 PUBLIC fmt mincore spdlog IMGUI SDL3-shared ${OPENGL_LIBRARY} vulkan-1 spirv-tools-opt spirv-tools)
|
|
||||||
|
target_link_libraries(shadps4 PRIVATE magic_enum::magic_enum fmt::fmt spdlog::spdlog toml11::toml11)
|
||||||
|
target_link_libraries(shadps4 PRIVATE discord-rpc imgui SDL3-shared vulkan-1 xxhash Zydis)
|
||||||
|
if (WIN32)
|
||||||
|
target_link_libraries(shadps4 PRIVATE mincore winpthread)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_custom_command(TARGET shadps4 POST_BUILD
|
add_custom_command(TARGET shadps4 POST_BUILD
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <types.h>
|
#include "common/types.h"
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
namespace Emulator::Host::Controller {
|
namespace Emulator::Host::Controller {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../types.h"
|
#include "common/types.h"
|
||||||
|
|
||||||
namespace Lib {
|
namespace Lib {
|
||||||
class Timer final
|
class Timer final
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
#include "Disassembler.h"
|
|
||||||
#include <fmt/format.h>
|
|
||||||
|
|
||||||
Disassembler::Disassembler()
|
|
||||||
{
|
|
||||||
ZydisDecoderInit(&m_decoder, ZYDIS_MACHINE_MODE_LONG_64, ZYDIS_STACK_WIDTH_64);
|
|
||||||
ZydisFormatterInit(&m_formatter, ZYDIS_FORMATTER_STYLE_INTEL);
|
|
||||||
}
|
|
||||||
|
|
||||||
Disassembler::~Disassembler()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Disassembler::printInstruction(void* code,u64 address)//print a single instruction
|
|
||||||
{
|
|
||||||
ZydisDecodedInstruction instruction;
|
|
||||||
ZydisDecodedOperand operands[ZYDIS_MAX_OPERAND_COUNT_VISIBLE];
|
|
||||||
ZyanStatus status = ZydisDecoderDecodeFull(&m_decoder, code, sizeof(code), &instruction, operands);
|
|
||||||
if (!ZYAN_SUCCESS(status))
|
|
||||||
{
|
|
||||||
fmt::print("decode instruction failed at {}\n", fmt::ptr(code));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printInst(instruction, operands,address);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Disassembler::printInst(ZydisDecodedInstruction& inst, ZydisDecodedOperand* operands,u64 address)
|
|
||||||
{
|
|
||||||
const int bufLen = 256;
|
|
||||||
char szBuffer[bufLen];
|
|
||||||
ZydisFormatterFormatInstruction(&m_formatter, &inst, operands,inst.operand_count_visible, szBuffer, sizeof(szBuffer), address, ZYAN_NULL);
|
|
||||||
fmt::print("instruction: {}\n", szBuffer);
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "Zydis.h"
|
|
||||||
#include "../types.h"
|
|
||||||
|
|
||||||
class Disassembler
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Disassembler();
|
|
||||||
~Disassembler();
|
|
||||||
void printInst(ZydisDecodedInstruction& inst, ZydisDecodedOperand* operands,u64 address);
|
|
||||||
void printInstruction(void* code,u64 address);
|
|
||||||
|
|
||||||
private:
|
|
||||||
ZydisDecoder m_decoder;
|
|
||||||
ZydisFormatter m_formatter;
|
|
||||||
};
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
#include <toml11/toml.hpp>
|
#include <toml.hpp>
|
||||||
|
|
||||||
namespace Config {
|
namespace Config {
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <types.h>
|
#include "common/types.h"
|
||||||
|
|
||||||
namespace Config {
|
namespace Config {
|
||||||
void load(const std::filesystem::path& path);
|
void load(const std::filesystem::path& path);
|
||||||
|
@ -12,4 +12,4 @@ u32 getLogLevel();
|
||||||
u32 getScreenWidth();
|
u32 getScreenWidth();
|
||||||
u32 getScreenHeight();
|
u32 getScreenHeight();
|
||||||
|
|
||||||
}; // namespace Config
|
}; // namespace Config
|
||||||
|
|
|
@ -1,90 +0,0 @@
|
||||||
#include <spdlog/common.h>
|
|
||||||
#include <spdlog/pattern_formatter.h>
|
|
||||||
#include <spdlog/sinks/basic_file_sink.h>
|
|
||||||
#include <spdlog/sinks/stdout_color_sinks.h>
|
|
||||||
#include <spdlog/spdlog.h>
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <Util/config.h>
|
|
||||||
|
|
||||||
#ifdef _WIN64
|
|
||||||
#include <Windows.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "log.h"
|
|
||||||
|
|
||||||
namespace logging {
|
|
||||||
std::vector<spdlog::sink_ptr> sinks;
|
|
||||||
constexpr bool log_file_exceptions = true; // disable it to disable logging
|
|
||||||
|
|
||||||
void flush() { spdlog::details::registry::instance().flush_all(); }
|
|
||||||
|
|
||||||
#ifdef _WIN64
|
|
||||||
|
|
||||||
static LONG WINAPI exception_handler(PEXCEPTION_POINTERS pExp) noexcept {
|
|
||||||
const u32 ec = pExp->ExceptionRecord->ExceptionCode;
|
|
||||||
switch (ec) {
|
|
||||||
case EXCEPTION_ACCESS_VIOLATION:
|
|
||||||
LOG_CRITICAL_IF(log_file_exceptions,"Exception EXCEPTION_ACCESS_VIOLATION ({}). ", log_hex(ec));
|
|
||||||
switch (pExp->ExceptionRecord->ExceptionInformation[0]) {
|
|
||||||
case 0: LOG_CRITICAL_IF(log_file_exceptions,"Read violation at address {}.", log_hex(pExp->ExceptionRecord->ExceptionInformation[1])); break;
|
|
||||||
case 1: LOG_CRITICAL_IF(log_file_exceptions,"Write violation at address {}.", log_hex(pExp->ExceptionRecord->ExceptionInformation[1])); break;
|
|
||||||
case 8:LOG_CRITICAL_IF(log_file_exceptions,"DEP violation at address {}.", log_hex(pExp->ExceptionRecord->ExceptionInformation[1])); break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: LOG_CRITICAL_IF(log_file_exceptions,"Exception EXCEPTION_ARRAY_BOUNDS_EXCEEDED ({:#x}). ", ec); break;
|
|
||||||
case EXCEPTION_DATATYPE_MISALIGNMENT: LOG_CRITICAL_IF(log_file_exceptions,"Exception EXCEPTION_DATATYPE_MISALIGNMENT ({}). ", log_hex(ec)); break;
|
|
||||||
case EXCEPTION_FLT_DIVIDE_BY_ZERO: LOG_CRITICAL_IF(log_file_exceptions,"Exception EXCEPTION_FLT_DIVIDE_BY_ZERO ({}). ", log_hex(ec)); break;
|
|
||||||
case EXCEPTION_ILLEGAL_INSTRUCTION: LOG_CRITICAL_IF(log_file_exceptions,"Exception EXCEPTION_ILLEGAL_INSTRUCTION ({}). ", log_hex(ec)); break;
|
|
||||||
case EXCEPTION_IN_PAGE_ERROR: LOG_CRITICAL_IF(log_file_exceptions,"Exception EXCEPTION_IN_PAGE_ERROR ({}). ", log_hex(ec)); break;
|
|
||||||
case EXCEPTION_INT_DIVIDE_BY_ZERO: LOG_CRITICAL_IF(log_file_exceptions,"Exception EXCEPTION_INT_DIVIDE_BY_ZERO ({}). ", log_hex(ec)); break;
|
|
||||||
case EXCEPTION_PRIV_INSTRUCTION: LOG_CRITICAL_IF(log_file_exceptions,"Exception EXCEPTION_PRIV_INSTRUCTION ({}). ", log_hex(ec)); break;
|
|
||||||
case EXCEPTION_STACK_OVERFLOW: LOG_CRITICAL_IF(log_file_exceptions,"Exception EXCEPTION_STACK_OVERFLOW ({}). ", log_hex(ec)); break;
|
|
||||||
default: return EXCEPTION_CONTINUE_SEARCH;
|
|
||||||
}
|
|
||||||
flush();
|
|
||||||
return EXCEPTION_CONTINUE_SEARCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
void register_log_exception_handler() {
|
|
||||||
if (!AddVectoredExceptionHandler(0, exception_handler)) {
|
|
||||||
LOG_CRITICAL_IF(log_file_exceptions,"Failed to register an exception handler");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
int init(bool use_stdout) {
|
|
||||||
sinks.clear(); // clear existing sinks
|
|
||||||
if (use_stdout) // if we use stdout window then init it as well
|
|
||||||
sinks.push_back(std::make_shared<spdlog::sinks::stdout_color_sink_mt>());
|
|
||||||
sinks.push_back(std::make_shared<spdlog::sinks::basic_file_sink_mt>(L"shadps4.txt", true));
|
|
||||||
spdlog::set_default_logger(std::make_shared<spdlog::logger>("shadps4 logger", begin(sinks), end(sinks)));
|
|
||||||
auto f = std::make_unique<spdlog::pattern_formatter>("%^|%L|: %v%$", spdlog::pattern_time_type::local, std::string("")); // disable eol
|
|
||||||
spdlog::set_formatter(std::move(f));
|
|
||||||
spdlog::set_level(static_cast<spdlog::level::level_enum>(Config::getLogLevel()));
|
|
||||||
spdlog::level::level_enum t = spdlog::get_level();
|
|
||||||
|
|
||||||
#ifdef _WIN64
|
|
||||||
register_log_exception_handler();
|
|
||||||
#endif
|
|
||||||
static std::terminate_handler old_terminate = nullptr;
|
|
||||||
old_terminate = std::set_terminate([]() {
|
|
||||||
try {
|
|
||||||
std::rethrow_exception(std::current_exception());
|
|
||||||
} catch (const std::exception &e) {
|
|
||||||
LOG_CRITICAL_IF(log_file_exceptions, "Unhandled C++ exception. {}", e.what());
|
|
||||||
} catch (...) {
|
|
||||||
LOG_CRITICAL_IF(log_file_exceptions, "Unhandled C++ exception. UNKNOWN");
|
|
||||||
}
|
|
||||||
flush();
|
|
||||||
if (old_terminate) old_terminate();
|
|
||||||
});
|
|
||||||
|
|
||||||
return 0; // all ok
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_level(spdlog::level::level_enum log_level) { spdlog::set_level(log_level); }
|
|
||||||
|
|
||||||
} // namespace logging
|
|
|
@ -1,73 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_TRACE
|
|
||||||
|
|
||||||
#include <spdlog/spdlog.h>
|
|
||||||
|
|
||||||
namespace logging {
|
|
||||||
|
|
||||||
#define LOG_TRACE SPDLOG_TRACE
|
|
||||||
#define LOG_DEBUG SPDLOG_DEBUG
|
|
||||||
#define LOG_INFO SPDLOG_INFO
|
|
||||||
#define LOG_WARN SPDLOG_WARN
|
|
||||||
#define LOG_ERROR SPDLOG_ERROR
|
|
||||||
#define LOG_CRITICAL SPDLOG_CRITICAL
|
|
||||||
|
|
||||||
#define LOG_TRACE_IF(flag, ...) \
|
|
||||||
if (flag) LOG_TRACE(__VA_ARGS__)
|
|
||||||
#define LOG_DEBUG_IF(flag, ...) \
|
|
||||||
if (flag) LOG_DEBUG(__VA_ARGS__)
|
|
||||||
#define LOG_INFO_IF(flag, ...) \
|
|
||||||
if (flag) LOG_INFO(__VA_ARGS__)
|
|
||||||
#define LOG_WARN_IF(flag, ...) \
|
|
||||||
if (flag) LOG_WARN(__VA_ARGS__)
|
|
||||||
#define LOG_ERROR_IF(flag, ...) \
|
|
||||||
if (flag) LOG_ERROR(__VA_ARGS__)
|
|
||||||
#define LOG_CRITICAL_IF(flag, ...) \
|
|
||||||
if (flag) LOG_CRITICAL(__VA_ARGS__)
|
|
||||||
|
|
||||||
int init(bool use_stdout);
|
|
||||||
void set_level(spdlog::level::level_enum log_level);
|
|
||||||
} // namespace logging
|
|
||||||
|
|
||||||
// copyright vita3k emu https://github.com/Vita3K/Vita3K/blob/master/vita3k/util/include/util/log.h
|
|
||||||
/*
|
|
||||||
returns: A string with the input number formatted in hexadecimal
|
|
||||||
Examples:
|
|
||||||
* `12` returns: `"0xC"`
|
|
||||||
* `1337` returns: `"0x539"`
|
|
||||||
* `72742069` returns: `"0x455F4B5"`
|
|
||||||
*/
|
|
||||||
template <typename T>
|
|
||||||
std::string log_hex(T val) {
|
|
||||||
using unsigned_type = typename std::make_unsigned<T>::type;
|
|
||||||
std::stringstream ss;
|
|
||||||
ss << "0x";
|
|
||||||
ss << std::hex << static_cast<unsigned_type>(val);
|
|
||||||
return ss.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
returns: A string with the input number formatted in hexadecimal with padding of the inputted type size
|
|
||||||
Examples:
|
|
||||||
* `uint8_t 5` returns: `"0x05"`
|
|
||||||
* `uint8_t 15` returns: `"0x0F"`
|
|
||||||
* `uint8_t 255` returns: `"0xFF"`
|
|
||||||
|
|
||||||
* `uint16_t 15` returns: `"0x000F"`
|
|
||||||
* `uint16_t 1337` returns: `"0x0539"`
|
|
||||||
* `uint16_t 65535` returns: `"0xFFFF"`
|
|
||||||
|
|
||||||
|
|
||||||
* `uint32_t 15` returns: `"0x0000000F"`
|
|
||||||
* `uint32_t 1337` returns: `"0x00000539"`
|
|
||||||
* `uint32_t 65535` returns: `"0x0000FFFF"`
|
|
||||||
* `uint32_t 134217728` returns: `"0x08000000"`
|
|
||||||
*/
|
|
||||||
template <typename T>
|
|
||||||
std::string log_hex_full(T val) {
|
|
||||||
std::stringstream ss;
|
|
||||||
ss << "0x";
|
|
||||||
ss << std::setfill('0') << std::setw(sizeof(T) * 2) << std::hex << val;
|
|
||||||
return ss.str();
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
#include "string_util.h"
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <sstream>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace StringUtil {
|
|
||||||
|
|
||||||
std::vector<std::string> split_string(const std::string &str, char delimiter) {
|
|
||||||
std::stringstream str_stream(str);
|
|
||||||
std::string segment;
|
|
||||||
std::vector<std::string> seglist;
|
|
||||||
|
|
||||||
const size_t num_segments = std::count_if(str.begin(), str.end(), [&](char c) { return c == delimiter; }) + (str.empty() ? 1 : 0);
|
|
||||||
|
|
||||||
seglist.reserve(num_segments);
|
|
||||||
|
|
||||||
while (std::getline(str_stream, segment, delimiter)) {
|
|
||||||
seglist.push_back(segment);
|
|
||||||
}
|
|
||||||
return seglist;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace StringUtil
|
|
|
@ -1,9 +0,0 @@
|
||||||
#pragma once
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace StringUtil {
|
|
||||||
|
|
||||||
std::vector<std::string> split_string(const std::string& str, char delimiter);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,7 +1,9 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#define BREAKPOINT __debugbreak
|
#define BREAKPOINT __debugbreak
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
#define BREAKPOINT __builtin_trap
|
#define BREAKPOINT __builtin_trap
|
||||||
#else
|
#else
|
||||||
#error What the fuck is this compiler
|
#error What the fuck is this compiler
|
||||||
#endif
|
#endif
|
|
@ -0,0 +1,33 @@
|
||||||
|
#include "common/disassembler.h"
|
||||||
|
#include <fmt/format.h>
|
||||||
|
|
||||||
|
namespace Common {
|
||||||
|
|
||||||
|
Disassembler::Disassembler() {
|
||||||
|
ZydisDecoderInit(&m_decoder, ZYDIS_MACHINE_MODE_LONG_64, ZYDIS_STACK_WIDTH_64);
|
||||||
|
ZydisFormatterInit(&m_formatter, ZYDIS_FORMATTER_STYLE_INTEL);
|
||||||
|
}
|
||||||
|
|
||||||
|
Disassembler::~Disassembler() = default;
|
||||||
|
|
||||||
|
void Disassembler::printInstruction(void* code, u64 address) {
|
||||||
|
ZydisDecodedInstruction instruction;
|
||||||
|
ZydisDecodedOperand operands[ZYDIS_MAX_OPERAND_COUNT_VISIBLE];
|
||||||
|
ZyanStatus status = ZydisDecoderDecodeFull(&m_decoder, code, sizeof(code),
|
||||||
|
&instruction, operands);
|
||||||
|
if (!ZYAN_SUCCESS(status)) {
|
||||||
|
fmt::print("decode instruction failed at {}\n", fmt::ptr(code));
|
||||||
|
} else {
|
||||||
|
printInst(instruction, operands,address);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Disassembler::printInst(ZydisDecodedInstruction& inst, ZydisDecodedOperand* operands, u64 address) {
|
||||||
|
const int bufLen = 256;
|
||||||
|
char szBuffer[bufLen];
|
||||||
|
ZydisFormatterFormatInstruction(&m_formatter, &inst, operands,inst.operand_count_visible,
|
||||||
|
szBuffer, sizeof(szBuffer), address, ZYAN_NULL);
|
||||||
|
fmt::print("instruction: {}\n", szBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Common
|
|
@ -0,0 +1,21 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Zydis/Zydis.h>
|
||||||
|
#include "common/types.h"
|
||||||
|
|
||||||
|
namespace Common {
|
||||||
|
|
||||||
|
class Disassembler {
|
||||||
|
public:
|
||||||
|
Disassembler();
|
||||||
|
~Disassembler();
|
||||||
|
|
||||||
|
void printInst(ZydisDecodedInstruction& inst, ZydisDecodedOperand* operands, u64 address);
|
||||||
|
void printInstruction(void* code, u64 address);
|
||||||
|
|
||||||
|
private:
|
||||||
|
ZydisDecoder m_decoder;
|
||||||
|
ZydisFormatter m_formatter;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Common
|
|
@ -16,4 +16,4 @@ namespace Discord {
|
||||||
void update(RPCStatus status, const std::string& title);
|
void update(RPCStatus status, const std::string& title);
|
||||||
void stop();
|
void stop();
|
||||||
};
|
};
|
||||||
} // namespace Discord
|
} // namespace Discord
|
|
@ -1,4 +1,4 @@
|
||||||
#include "FsFile.h"
|
#include "common/fs_file.h"
|
||||||
|
|
||||||
namespace Common::FS {
|
namespace Common::FS {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include <span>
|
#include <span>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "../types.h"
|
#include "common/types.h"
|
||||||
|
|
||||||
namespace Common::FS {
|
namespace Common::FS {
|
||||||
|
|
|
@ -0,0 +1,114 @@
|
||||||
|
#include <spdlog/common.h>
|
||||||
|
#include <spdlog/pattern_formatter.h>
|
||||||
|
#include <spdlog/sinks/basic_file_sink.h>
|
||||||
|
#include <spdlog/sinks/stdout_color_sinks.h>
|
||||||
|
#include <spdlog/spdlog.h>
|
||||||
|
#include <vector>
|
||||||
|
#include <Util/config.h>
|
||||||
|
#include "common/log.h"
|
||||||
|
#ifdef _WIN64
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace Common::Log {
|
||||||
|
|
||||||
|
std::vector<spdlog::sink_ptr> sinks;
|
||||||
|
constexpr bool log_file_exceptions = true;
|
||||||
|
|
||||||
|
void Flush() {
|
||||||
|
spdlog::details::registry::instance().flush_all();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN64
|
||||||
|
static LONG WINAPI ExceptionHandler(PEXCEPTION_POINTERS pExp) noexcept {
|
||||||
|
const u32 ec = pExp->ExceptionRecord->ExceptionCode;
|
||||||
|
switch (ec) {
|
||||||
|
case EXCEPTION_ACCESS_VIOLATION: {
|
||||||
|
LOG_CRITICAL_IF(log_file_exceptions, "Exception EXCEPTION_ACCESS_VIOLATION ({:#x}). ", ec);
|
||||||
|
const auto info = pExp->ExceptionRecord->ExceptionInformation;
|
||||||
|
switch (info[0]) {
|
||||||
|
case 0:
|
||||||
|
LOG_CRITICAL_IF(log_file_exceptions, "Read violation at address {:#x}.", info[1]);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
LOG_CRITICAL_IF(log_file_exceptions, "Write violation at address {:#x}.", info[1]);
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
LOG_CRITICAL_IF(log_file_exceptions, "DEP violation at address {:#x}.", info[1]);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
|
||||||
|
LOG_CRITICAL_IF(log_file_exceptions, "Exception EXCEPTION_ARRAY_BOUNDS_EXCEEDED ({:#x}). ", ec);
|
||||||
|
break;
|
||||||
|
case EXCEPTION_DATATYPE_MISALIGNMENT:
|
||||||
|
LOG_CRITICAL_IF(log_file_exceptions, "Exception EXCEPTION_DATATYPE_MISALIGNMENT ({:#x}). ", ec);
|
||||||
|
break;
|
||||||
|
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
|
||||||
|
LOG_CRITICAL_IF(log_file_exceptions, "Exception EXCEPTION_FLT_DIVIDE_BY_ZERO ({:#x}). ", ec);
|
||||||
|
break;
|
||||||
|
case EXCEPTION_ILLEGAL_INSTRUCTION:
|
||||||
|
LOG_CRITICAL_IF(log_file_exceptions, "Exception EXCEPTION_ILLEGAL_INSTRUCTION ({:#x}). ", ec);
|
||||||
|
break;
|
||||||
|
case EXCEPTION_IN_PAGE_ERROR:
|
||||||
|
LOG_CRITICAL_IF(log_file_exceptions, "Exception EXCEPTION_IN_PAGE_ERROR ({:#x}). ", ec);
|
||||||
|
break;
|
||||||
|
case EXCEPTION_INT_DIVIDE_BY_ZERO:
|
||||||
|
LOG_CRITICAL_IF(log_file_exceptions, "Exception EXCEPTION_INT_DIVIDE_BY_ZERO ({:#x}). ", ec);
|
||||||
|
break;
|
||||||
|
case EXCEPTION_PRIV_INSTRUCTION:
|
||||||
|
LOG_CRITICAL_IF(log_file_exceptions, "Exception EXCEPTION_PRIV_INSTRUCTION ({:#x}). ", ec);
|
||||||
|
break;
|
||||||
|
case EXCEPTION_STACK_OVERFLOW:
|
||||||
|
LOG_CRITICAL_IF(log_file_exceptions, "Exception EXCEPTION_STACK_OVERFLOW ({:#x}). ", ec);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return EXCEPTION_CONTINUE_SEARCH;
|
||||||
|
}
|
||||||
|
Flush();
|
||||||
|
return EXCEPTION_CONTINUE_SEARCH;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
int Init(bool use_stdout) {
|
||||||
|
sinks.clear();
|
||||||
|
if (use_stdout) {
|
||||||
|
sinks.push_back(std::make_shared<spdlog::sinks::stdout_color_sink_mt>());
|
||||||
|
}
|
||||||
|
sinks.push_back(std::make_shared<spdlog::sinks::basic_file_sink_mt>(L"shadps4.txt", true));
|
||||||
|
spdlog::set_default_logger(std::make_shared<spdlog::logger>("shadps4 logger", begin(sinks), end(sinks)));
|
||||||
|
auto f = std::make_unique<spdlog::pattern_formatter>("%^|%L|: %v%$", spdlog::pattern_time_type::local, std::string("")); // disable eol
|
||||||
|
spdlog::set_formatter(std::move(f));
|
||||||
|
spdlog::set_level(static_cast<spdlog::level::level_enum>(Config::getLogLevel()));
|
||||||
|
|
||||||
|
#ifdef _WIN64
|
||||||
|
if (!AddVectoredExceptionHandler(0, ExceptionHandler)) {
|
||||||
|
LOG_CRITICAL_IF(log_file_exceptions, "Failed to register an exception handler");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static std::terminate_handler old_terminate = nullptr;
|
||||||
|
old_terminate = std::set_terminate([]() {
|
||||||
|
try {
|
||||||
|
std::rethrow_exception(std::current_exception());
|
||||||
|
} catch (const std::exception &e) {
|
||||||
|
LOG_CRITICAL_IF(log_file_exceptions, "Unhandled C++ exception. {}", e.what());
|
||||||
|
} catch (...) {
|
||||||
|
LOG_CRITICAL_IF(log_file_exceptions, "Unhandled C++ exception. UNKNOWN");
|
||||||
|
}
|
||||||
|
Flush();
|
||||||
|
if (old_terminate) old_terminate();
|
||||||
|
});
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetLevel(spdlog::level::level_enum log_level) {
|
||||||
|
spdlog::set_level(log_level);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Common::Log
|
|
@ -0,0 +1,33 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_TRACE
|
||||||
|
|
||||||
|
#include <spdlog/spdlog.h>
|
||||||
|
|
||||||
|
namespace Common::Log {
|
||||||
|
|
||||||
|
#define LOG_TRACE SPDLOG_TRACE
|
||||||
|
#define LOG_DEBUG SPDLOG_DEBUG
|
||||||
|
#define LOG_INFO SPDLOG_INFO
|
||||||
|
#define LOG_WARN SPDLOG_WARN
|
||||||
|
#define LOG_ERROR SPDLOG_ERROR
|
||||||
|
#define LOG_CRITICAL SPDLOG_CRITICAL
|
||||||
|
|
||||||
|
#define LOG_TRACE_IF(flag, ...) \
|
||||||
|
if (flag) LOG_TRACE(__VA_ARGS__)
|
||||||
|
#define LOG_DEBUG_IF(flag, ...) \
|
||||||
|
if (flag) LOG_DEBUG(__VA_ARGS__)
|
||||||
|
#define LOG_INFO_IF(flag, ...) \
|
||||||
|
if (flag) LOG_INFO(__VA_ARGS__)
|
||||||
|
#define LOG_WARN_IF(flag, ...) \
|
||||||
|
if (flag) LOG_WARN(__VA_ARGS__)
|
||||||
|
#define LOG_ERROR_IF(flag, ...) \
|
||||||
|
if (flag) LOG_ERROR(__VA_ARGS__)
|
||||||
|
#define LOG_CRITICAL_IF(flag, ...) \
|
||||||
|
if (flag) LOG_CRITICAL(__VA_ARGS__)
|
||||||
|
|
||||||
|
int Init(bool use_stdout);
|
||||||
|
|
||||||
|
void SetLevel(spdlog::level::level_enum log_level);
|
||||||
|
|
||||||
|
} // namespace Common::Log
|
|
@ -2,10 +2,12 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
namespace Common {
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
class singleton {
|
class Singleton {
|
||||||
public:
|
public:
|
||||||
static T* instance() {
|
static T* Instance() {
|
||||||
if (!m_instance) {
|
if (!m_instance) {
|
||||||
m_instance = std::make_unique<T>();
|
m_instance = std::make_unique<T>();
|
||||||
}
|
}
|
||||||
|
@ -13,9 +15,11 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
singleton();
|
Singleton();
|
||||||
~singleton();
|
~Singleton();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static inline std::unique_ptr<T> m_instance{};
|
static inline std::unique_ptr<T> m_instance{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace Common
|
|
@ -0,0 +1,20 @@
|
||||||
|
#include <algorithm>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
#include "common/string_util.h"
|
||||||
|
|
||||||
|
namespace Common {
|
||||||
|
|
||||||
|
std::vector<std::string> SplitString(const std::string &str, char delimiter) {
|
||||||
|
std::istringstream iss(str);
|
||||||
|
std::vector<std::string> output(1);
|
||||||
|
|
||||||
|
while (std::getline(iss, *output.rbegin(), delimiter)) {
|
||||||
|
output.emplace_back();
|
||||||
|
}
|
||||||
|
|
||||||
|
output.pop_back();
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Common
|
|
@ -0,0 +1,10 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace Common {
|
||||||
|
|
||||||
|
std::vector<std::string> SplitString(const std::string& str, char delimiter);
|
||||||
|
|
||||||
|
} // namespace Common
|
|
@ -1,4 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
using s08 = std::int8_t;
|
using s08 = std::int8_t;
|
||||||
|
@ -16,7 +17,6 @@ using f64 = double;
|
||||||
|
|
||||||
#define PS4_SYSV_ABI __attribute__((sysv_abi))
|
#define PS4_SYSV_ABI __attribute__((sysv_abi))
|
||||||
|
|
||||||
|
|
||||||
// UDLs for memory size values
|
// UDLs for memory size values
|
||||||
constexpr u64 operator""_KB(u64 x) { return 1024ULL * x; }
|
constexpr u64 operator""_KB(u64 x) { return 1024ULL * x; }
|
||||||
constexpr u64 operator""_MB(u64 x) { return 1024_KB * x; }
|
constexpr u64 operator""_MB(u64 x) { return 1024_KB * x; }
|
|
@ -1,7 +1,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
namespace Emulator {
|
namespace Common {
|
||||||
|
|
||||||
constexpr char VERSION[] = "0.0.3 WIP";
|
constexpr char VERSION[] = "0.0.3 WIP";
|
||||||
}
|
|
||||||
|
} // namespace Common
|
|
@ -1,18 +1,18 @@
|
||||||
#include "gpu_memory.h"
|
#include "gpu_memory.h"
|
||||||
|
|
||||||
#include <xxhash/xxh3.h>
|
#include <xxh3.h>
|
||||||
|
|
||||||
#include "Emulator/Util/singleton.h"
|
#include "common/singleton.h"
|
||||||
|
|
||||||
void* GPU::memoryCreateObj(u64 submit_id, HLE::Libs::Graphics::GraphicCtx* ctx, void* todo /*CommandBuffer?*/, u64 virtual_addr, u64 size,
|
void* GPU::memoryCreateObj(u64 submit_id, HLE::Libs::Graphics::GraphicCtx* ctx, void* todo /*CommandBuffer?*/, u64 virtual_addr, u64 size,
|
||||||
const GPUObject& info) {
|
const GPUObject& info) {
|
||||||
auto* gpumemory = singleton<GPUMemory>::instance();
|
auto* gpumemory = Common::Singleton<GPUMemory>::Instance();
|
||||||
|
|
||||||
return gpumemory->memoryCreateObj(submit_id, ctx, nullptr, &virtual_addr, &size, 1, info);
|
return gpumemory->memoryCreateObj(submit_id, ctx, nullptr, &virtual_addr, &size, 1, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPU::memorySetAllocArea(u64 virtual_addr, u64 size) {
|
void GPU::memorySetAllocArea(u64 virtual_addr, u64 size) {
|
||||||
auto* gpumemory = singleton<GPUMemory>::instance();
|
auto* gpumemory = Common::Singleton<GPUMemory>::Instance();
|
||||||
|
|
||||||
std::scoped_lock lock{gpumemory->m_mutex};
|
std::scoped_lock lock{gpumemory->m_mutex};
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ bool GPU::vulkanAllocateMemory(HLE::Libs::Graphics::GraphicCtx* ctx, HLE::Libs::
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPU::flushGarlic(HLE::Libs::Graphics::GraphicCtx* ctx) {
|
void GPU::flushGarlic(HLE::Libs::Graphics::GraphicCtx* ctx) {
|
||||||
auto* gpumemory = singleton<GPUMemory>::instance();
|
auto* gpumemory = Common::Singleton<GPUMemory>::Instance();
|
||||||
gpumemory->flushAllHeaps(ctx);
|
gpumemory->flushAllHeaps(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ int GPU::GPUMemory::getHeapId(u64 virtual_addr, u64 size) {
|
||||||
|
|
||||||
void* GPU::GPUMemory::memoryCreateObj(u64 submit_id, HLE::Libs::Graphics::GraphicCtx* ctx, void* todo, const u64* virtual_addr, const u64* size,
|
void* GPU::GPUMemory::memoryCreateObj(u64 submit_id, HLE::Libs::Graphics::GraphicCtx* ctx, void* todo, const u64* virtual_addr, const u64* size,
|
||||||
int virtual_addr_num, const GPUObject& info) {
|
int virtual_addr_num, const GPUObject& info) {
|
||||||
auto* gpumemory = singleton<GPUMemory>::instance();
|
auto* gpumemory = Common::Singleton<GPUMemory>::Instance();
|
||||||
|
|
||||||
std::scoped_lock lock{gpumemory->m_mutex};
|
std::scoped_lock lock{gpumemory->m_mutex};
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <core/PS4/HLE/Graphics/graphics_ctx.h>
|
#include <core/PS4/HLE/Graphics/graphics_ctx.h>
|
||||||
#include <types.h>
|
#include "common/types.h"
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "tile_manager.h"
|
#include "tile_manager.h"
|
||||||
#include "Emulator/Util/singleton.h"
|
#include "common/singleton.h"
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
namespace GPU {
|
namespace GPU {
|
||||||
|
@ -143,7 +143,7 @@ void convertTileToLinear(void* dst, const void* src,u32 width, u32 height, bool
|
||||||
TileManager32 t;
|
TileManager32 t;
|
||||||
t.Init(width, height, is_neo);
|
t.Init(width, height, is_neo);
|
||||||
|
|
||||||
auto* g_TileManager = singleton<TileManager>::instance();
|
auto* g_TileManager = Common::Singleton<TileManager>::Instance();
|
||||||
|
|
||||||
std::scoped_lock lock{g_TileManager->m_mutex};
|
std::scoped_lock lock{g_TileManager->m_mutex};
|
||||||
|
|
||||||
|
@ -166,4 +166,4 @@ void convertTileToLinear(void* dst, const void* src,u32 width, u32 height, bool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace GPU
|
} // namespace GPU
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "types.h"
|
#include "common/types.h"
|
||||||
|
|
||||||
namespace GPU {
|
namespace GPU {
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include "video_out_buffer.h"
|
#include "video_out_buffer.h"
|
||||||
|
|
||||||
#include <Util/log.h>
|
#include "common/log.h"
|
||||||
|
|
||||||
#include "debug.h"
|
#include "common/debug.h"
|
||||||
#include <vulkan_util.h>
|
#include <vulkan_util.h>
|
||||||
#include "tile_manager.h"
|
#include "tile_manager.h"
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <types.h>
|
#include "common/types.h"
|
||||||
|
|
||||||
#include "gpu_memory.h"
|
#include "gpu_memory.h"
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "video_out_ctx.h"
|
#include "video_out_ctx.h"
|
||||||
|
|
||||||
#include <core/PS4/HLE/LibKernel.h>
|
#include <core/PS4/HLE/LibKernel.h>
|
||||||
#include <debug.h>
|
#include "common/debug.h"
|
||||||
#include <core/hle/libraries/libkernel/time_management.h>
|
#include <core/hle/libraries/libkernel/time_management.h>
|
||||||
|
|
||||||
namespace HLE::Graphics::Objects {
|
namespace HLE::Graphics::Objects {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <types.h>
|
#include "common/types.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <vulkan/vulkan_core.h>
|
#include <vulkan/vulkan_core.h>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#include "graphics_render.h"
|
#include "graphics_render.h"
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
#include "Emulator/Util/singleton.h"
|
#include "common/singleton.h"
|
||||||
#include "emulator.h"
|
#include "emulator.h"
|
||||||
|
|
||||||
static thread_local GPU::CommandPool g_command_pool;
|
static thread_local GPU::CommandPool g_command_pool;
|
||||||
|
|
||||||
void GPU::renderCreateCtx() {
|
void GPU::renderCreateCtx() {
|
||||||
auto* render_ctx = singleton<RenderCtx>::instance();
|
auto* render_ctx = Common::Singleton<RenderCtx>::Instance();
|
||||||
|
|
||||||
render_ctx->setGraphicCtx(Emu::getGraphicCtx());
|
render_ctx->setGraphicCtx(Emu::getGraphicCtx());
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ void GPU::CommandBuffer::freeBuffer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPU::CommandBuffer::waitForFence() {
|
void GPU::CommandBuffer::waitForFence() {
|
||||||
auto* render_ctx = singleton<RenderCtx>::instance();
|
auto* render_ctx = Common::Singleton<RenderCtx>::Instance();
|
||||||
|
|
||||||
if (m_execute) {
|
if (m_execute) {
|
||||||
auto* device = render_ctx->getGraphicCtx()->m_device;
|
auto* device = render_ctx->getGraphicCtx()->m_device;
|
||||||
|
@ -89,7 +89,7 @@ void GPU::CommandBuffer::executeWithSemaphore() {
|
||||||
submit_info.signalSemaphoreCount = 1;
|
submit_info.signalSemaphoreCount = 1;
|
||||||
submit_info.pSignalSemaphores = &m_pool->semaphores[m_index];
|
submit_info.pSignalSemaphores = &m_pool->semaphores[m_index];
|
||||||
|
|
||||||
auto* render_ctx = singleton<RenderCtx>::instance();
|
auto* render_ctx = Common::Singleton<RenderCtx>::Instance();
|
||||||
const auto& queue = render_ctx->getGraphicCtx()->queues[m_queue];
|
const auto& queue = render_ctx->getGraphicCtx()->queues[m_queue];
|
||||||
auto result = vkQueueSubmit(queue.vk_queue, 1, &submit_info, fence);
|
auto result = vkQueueSubmit(queue.vk_queue, 1, &submit_info, fence);
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ void GPU::CommandBuffer::execute() {
|
||||||
submit_info.signalSemaphoreCount = 0;
|
submit_info.signalSemaphoreCount = 0;
|
||||||
submit_info.pSignalSemaphores = nullptr;
|
submit_info.pSignalSemaphores = nullptr;
|
||||||
|
|
||||||
auto* render_ctx = singleton<RenderCtx>::instance();
|
auto* render_ctx = Common::Singleton<RenderCtx>::Instance();
|
||||||
const auto& queue = render_ctx->getGraphicCtx()->queues[m_queue];
|
const auto& queue = render_ctx->getGraphicCtx()->queues[m_queue];
|
||||||
auto result = vkQueueSubmit(queue.vk_queue, 1, &submit_info, fence);
|
auto result = vkQueueSubmit(queue.vk_queue, 1, &submit_info, fence);
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ void GPU::CommandBuffer::execute() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void GPU::CommandPool::createPool(int id) {
|
void GPU::CommandPool::createPool(int id) {
|
||||||
auto* render_ctx = singleton<RenderCtx>::instance();
|
auto* render_ctx = Common::Singleton<RenderCtx>::Instance();
|
||||||
auto* ctx = render_ctx->getGraphicCtx();
|
auto* ctx = render_ctx->getGraphicCtx();
|
||||||
|
|
||||||
VkCommandPoolCreateInfo pool_info{};
|
VkCommandPoolCreateInfo pool_info{};
|
||||||
|
@ -186,7 +186,7 @@ void GPU::CommandPool::createPool(int id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPU::CommandPool::deleteAllPool() {
|
void GPU::CommandPool::deleteAllPool() {
|
||||||
auto* render_ctx = singleton<RenderCtx>::instance();
|
auto* render_ctx = Common::Singleton<RenderCtx>::Instance();
|
||||||
auto* ctx = render_ctx->getGraphicCtx();
|
auto* ctx = render_ctx->getGraphicCtx();
|
||||||
|
|
||||||
for (auto& pool : m_pool) {
|
for (auto& pool : m_pool) {
|
||||||
|
|
|
@ -7,15 +7,15 @@
|
||||||
#include <core/PS4/HLE/Libs.h>
|
#include <core/PS4/HLE/Libs.h>
|
||||||
#include <core/PS4/HLE/UserManagement/UsrMngCodes.h>
|
#include <core/PS4/HLE/UserManagement/UsrMngCodes.h>
|
||||||
#include <Util/config.h>
|
#include <Util/config.h>
|
||||||
#include <Util/log.h>
|
#include "common/log.h"
|
||||||
#include <debug.h>
|
#include "common/debug.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <magic_enum.hpp>
|
#include <magic_enum.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "Objects/video_out_ctx.h"
|
#include "Objects/video_out_ctx.h"
|
||||||
#include "Emulator/Util/singleton.h"
|
#include "common/singleton.h"
|
||||||
#include "emulator.h"
|
#include "emulator.h"
|
||||||
#include "graphics_render.h"
|
#include "graphics_render.h"
|
||||||
|
|
||||||
|
@ -24,12 +24,12 @@ namespace HLE::Libs::Graphics::VideoOut {
|
||||||
constexpr bool log_file_videoout = true; // disable it to disable logging
|
constexpr bool log_file_videoout = true; // disable it to disable logging
|
||||||
|
|
||||||
void videoOutInit(u32 width, u32 height) {
|
void videoOutInit(u32 width, u32 height) {
|
||||||
auto* videoOut = singleton<HLE::Graphics::Objects::VideoOutCtx>::instance();
|
auto* videoOut = Common::Singleton<HLE::Graphics::Objects::VideoOutCtx>::Instance();
|
||||||
videoOut->Init(width, height);
|
videoOut->Init(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool videoOutFlip(u32 micros) {
|
bool videoOutFlip(u32 micros) {
|
||||||
auto* videoOut = singleton<HLE::Graphics::Objects::VideoOutCtx>::instance();
|
auto* videoOut = Common::Singleton<HLE::Graphics::Objects::VideoOutCtx>::Instance();
|
||||||
return videoOut->getFlipQueue().flip(micros);
|
return videoOut->getFlipQueue().flip(micros);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ static void flip_delete_event_func(LibKernel::EventQueues::SceKernelEqueue eq, H
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceVideoOutAddFlipEvent(LibKernel::EventQueues::SceKernelEqueue eq, s32 handle, void* udata) {
|
s32 PS4_SYSV_ABI sceVideoOutAddFlipEvent(LibKernel::EventQueues::SceKernelEqueue eq, s32 handle, void* udata) {
|
||||||
PRINT_FUNCTION_NAME();
|
PRINT_FUNCTION_NAME();
|
||||||
auto* videoOut = singleton<HLE::Graphics::Objects::VideoOutCtx>::instance();
|
auto* videoOut = Common::Singleton<HLE::Graphics::Objects::VideoOutCtx>::Instance();
|
||||||
|
|
||||||
auto* ctx = videoOut->getCtx(handle);
|
auto* ctx = videoOut->getCtx(handle);
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ s32 PS4_SYSV_ABI sceVideoOutAddFlipEvent(LibKernel::EventQueues::SceKernelEqueue
|
||||||
s32 PS4_SYSV_ABI sceVideoOutRegisterBuffers(s32 handle, s32 startIndex, void* const* addresses, s32 bufferNum,
|
s32 PS4_SYSV_ABI sceVideoOutRegisterBuffers(s32 handle, s32 startIndex, void* const* addresses, s32 bufferNum,
|
||||||
const SceVideoOutBufferAttribute* attribute) {
|
const SceVideoOutBufferAttribute* attribute) {
|
||||||
PRINT_FUNCTION_NAME();
|
PRINT_FUNCTION_NAME();
|
||||||
auto* videoOut = singleton<HLE::Graphics::Objects::VideoOutCtx>::instance();
|
auto* videoOut = Common::Singleton<HLE::Graphics::Objects::VideoOutCtx>::Instance();
|
||||||
auto* ctx = videoOut->getCtx(handle);
|
auto* ctx = videoOut->getCtx(handle);
|
||||||
|
|
||||||
if (handle == 1) { // main port
|
if (handle == 1) { // main port
|
||||||
|
@ -154,7 +154,7 @@ s32 PS4_SYSV_ABI sceVideoOutRegisterBuffers(s32 handle, s32 startIndex, void* co
|
||||||
}
|
}
|
||||||
LOG_INFO_IF(log_file_videoout, "startIndex = {}\n", startIndex);
|
LOG_INFO_IF(log_file_videoout, "startIndex = {}\n", startIndex);
|
||||||
LOG_INFO_IF(log_file_videoout, "bufferNum = {}\n", bufferNum);
|
LOG_INFO_IF(log_file_videoout, "bufferNum = {}\n", bufferNum);
|
||||||
LOG_INFO_IF(log_file_videoout, "pixelFormat = {}\n", log_hex_full(attribute->pixelFormat));
|
LOG_INFO_IF(log_file_videoout, "pixelFormat = {:#x}\n", attribute->pixelFormat);
|
||||||
LOG_INFO_IF(log_file_videoout, "tilingMode = {}\n", attribute->tilingMode);
|
LOG_INFO_IF(log_file_videoout, "tilingMode = {}\n", attribute->tilingMode);
|
||||||
LOG_INFO_IF(log_file_videoout, "aspectRatio = {}\n", attribute->aspectRatio);
|
LOG_INFO_IF(log_file_videoout, "aspectRatio = {}\n", attribute->aspectRatio);
|
||||||
LOG_INFO_IF(log_file_videoout, "width = {}\n", attribute->width);
|
LOG_INFO_IF(log_file_videoout, "width = {}\n", attribute->width);
|
||||||
|
@ -208,26 +208,26 @@ s32 PS4_SYSV_ABI sceVideoOutRegisterBuffers(s32 handle, s32 startIndex, void* co
|
||||||
ctx->buffers[i + startIndex].buffer_render = static_cast<Graphics::VideoOutVulkanImage*>(
|
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));
|
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, log_hex_full(reinterpret_cast<uint64_t>(addresses[i])));
|
LOG_INFO_IF(log_file_videoout, "buffers[{}] = {:#x}\n", i + startIndex, reinterpret_cast<u64>(addresses[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
return registration_index;
|
return registration_index;
|
||||||
}
|
}
|
||||||
s32 PS4_SYSV_ABI sceVideoOutSetFlipRate(s32 handle, s32 rate) {
|
s32 PS4_SYSV_ABI sceVideoOutSetFlipRate(s32 handle, s32 rate) {
|
||||||
PRINT_FUNCTION_NAME();
|
PRINT_FUNCTION_NAME();
|
||||||
auto* videoOut = singleton<HLE::Graphics::Objects::VideoOutCtx>::instance();
|
auto* videoOut = Common::Singleton<HLE::Graphics::Objects::VideoOutCtx>::Instance();
|
||||||
videoOut->getCtx(handle)->m_flip_rate = rate;
|
videoOut->getCtx(handle)->m_flip_rate = rate;
|
||||||
return SCE_OK;
|
return SCE_OK;
|
||||||
}
|
}
|
||||||
s32 PS4_SYSV_ABI sceVideoOutIsFlipPending(s32 handle) {
|
s32 PS4_SYSV_ABI sceVideoOutIsFlipPending(s32 handle) {
|
||||||
PRINT_FUNCTION_NAME();
|
PRINT_FUNCTION_NAME();
|
||||||
auto* videoOut = singleton<HLE::Graphics::Objects::VideoOutCtx>::instance();
|
auto* videoOut = Common::Singleton<HLE::Graphics::Objects::VideoOutCtx>::Instance();
|
||||||
s32 pending = videoOut->getCtx(handle)->m_flip_status.flipPendingNum;
|
s32 pending = videoOut->getCtx(handle)->m_flip_status.flipPendingNum;
|
||||||
return pending;
|
return pending;
|
||||||
}
|
}
|
||||||
s32 PS4_SYSV_ABI sceVideoOutSubmitFlip(s32 handle, s32 bufferIndex, s32 flipMode, s64 flipArg) {
|
s32 PS4_SYSV_ABI sceVideoOutSubmitFlip(s32 handle, s32 bufferIndex, s32 flipMode, s64 flipArg) {
|
||||||
PRINT_FUNCTION_NAME();
|
PRINT_FUNCTION_NAME();
|
||||||
auto* videoOut = singleton<HLE::Graphics::Objects::VideoOutCtx>::instance();
|
auto* videoOut = Common::Singleton<HLE::Graphics::Objects::VideoOutCtx>::Instance();
|
||||||
auto* ctx = videoOut->getCtx(handle);
|
auto* ctx = videoOut->getCtx(handle);
|
||||||
|
|
||||||
if (flipMode != 1) {
|
if (flipMode != 1) {
|
||||||
|
@ -254,7 +254,7 @@ s32 PS4_SYSV_ABI sceVideoOutSubmitFlip(s32 handle, s32 bufferIndex, s32 flipMode
|
||||||
}
|
}
|
||||||
s32 PS4_SYSV_ABI sceVideoOutGetFlipStatus(s32 handle, SceVideoOutFlipStatus* status) {
|
s32 PS4_SYSV_ABI sceVideoOutGetFlipStatus(s32 handle, SceVideoOutFlipStatus* status) {
|
||||||
PRINT_FUNCTION_NAME();
|
PRINT_FUNCTION_NAME();
|
||||||
auto* videoOut = singleton<HLE::Graphics::Objects::VideoOutCtx>::instance();
|
auto* videoOut = Common::Singleton<HLE::Graphics::Objects::VideoOutCtx>::Instance();
|
||||||
auto* ctx = videoOut->getCtx(handle);
|
auto* ctx = videoOut->getCtx(handle);
|
||||||
videoOut->getFlipQueue().getFlipStatus(ctx, status);
|
videoOut->getFlipQueue().getFlipStatus(ctx, status);
|
||||||
|
|
||||||
|
@ -270,7 +270,7 @@ s32 PS4_SYSV_ABI sceVideoOutGetFlipStatus(s32 handle, SceVideoOutFlipStatus* sta
|
||||||
}
|
}
|
||||||
s32 PS4_SYSV_ABI sceVideoOutGetResolutionStatus(s32 handle, SceVideoOutResolutionStatus* status) {
|
s32 PS4_SYSV_ABI sceVideoOutGetResolutionStatus(s32 handle, SceVideoOutResolutionStatus* status) {
|
||||||
PRINT_FUNCTION_NAME();
|
PRINT_FUNCTION_NAME();
|
||||||
auto* videoOut = singleton<HLE::Graphics::Objects::VideoOutCtx>::instance();
|
auto* videoOut = Common::Singleton<HLE::Graphics::Objects::VideoOutCtx>::Instance();
|
||||||
*status = videoOut->getCtx(handle)->m_resolution;
|
*status = videoOut->getCtx(handle)->m_resolution;
|
||||||
return SCE_OK;
|
return SCE_OK;
|
||||||
}
|
}
|
||||||
|
@ -289,7 +289,7 @@ s32 PS4_SYSV_ABI sceVideoOutOpen(SceUserServiceUserId userId, s32 busType, s32 i
|
||||||
if (param != nullptr) {
|
if (param != nullptr) {
|
||||||
BREAKPOINT();
|
BREAKPOINT();
|
||||||
}
|
}
|
||||||
auto* videoOut = singleton<HLE::Graphics::Objects::VideoOutCtx>::instance();
|
auto* videoOut = Common::Singleton<HLE::Graphics::Objects::VideoOutCtx>::Instance();
|
||||||
int handle = videoOut->Open();
|
int handle = videoOut->Open();
|
||||||
|
|
||||||
if (handle < 0) {
|
if (handle < 0) {
|
||||||
|
@ -300,7 +300,7 @@ s32 PS4_SYSV_ABI sceVideoOutOpen(SceUserServiceUserId userId, s32 busType, s32 i
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
s32 PS4_SYSV_ABI sceVideoOutClose(s32 handle) {
|
s32 PS4_SYSV_ABI sceVideoOutClose(s32 handle) {
|
||||||
auto* videoOut = singleton<HLE::Graphics::Objects::VideoOutCtx>::instance();
|
auto* videoOut = Common::Singleton<HLE::Graphics::Objects::VideoOutCtx>::Instance();
|
||||||
videoOut->Close(handle);
|
videoOut->Close(handle);
|
||||||
return SCE_OK;
|
return SCE_OK;
|
||||||
}
|
}
|
||||||
|
@ -319,4 +319,4 @@ void videoOutRegisterLib(SymbolsResolver* sym) {
|
||||||
LIB_FUNCTION("N5KDtkIjjJ4", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, sceVideoOutUnregisterBuffers);
|
LIB_FUNCTION("N5KDtkIjjJ4", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, sceVideoOutUnregisterBuffers);
|
||||||
LIB_FUNCTION("uquVH4-Du78", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, sceVideoOutClose);
|
LIB_FUNCTION("uquVH4-Du78", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, sceVideoOutClose);
|
||||||
}
|
}
|
||||||
} // namespace HLE::Libs::Graphics::VideoOut
|
} // namespace HLE::Libs::Graphics::VideoOut
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <core/PS4/HLE/Kernel/event_queues.h>
|
#include <core/PS4/HLE/Kernel/event_queues.h>
|
||||||
#include <core/PS4/Loader/SymbolsResolver.h>
|
#include <core/PS4/Loader/SymbolsResolver.h>
|
||||||
#include <types.h>
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@ -111,4 +110,4 @@ s32 PS4_SYSV_ABI sceVideoOutGetFlipStatus(s32 handle, SceVideoOutFlipStatus* sta
|
||||||
s32 PS4_SYSV_ABI sceVideoOutGetResolutionStatus(s32 handle, SceVideoOutResolutionStatus* status);
|
s32 PS4_SYSV_ABI sceVideoOutGetResolutionStatus(s32 handle, SceVideoOutResolutionStatus* status);
|
||||||
s32 PS4_SYSV_ABI sceVideoOutOpen(SceUserServiceUserId userId, s32 busType, s32 index, const void* param);
|
s32 PS4_SYSV_ABI sceVideoOutOpen(SceUserServiceUserId userId, s32 busType, s32 index, const void* param);
|
||||||
s32 PS4_SYSV_ABI sceVideoOutClose(s32 handle);
|
s32 PS4_SYSV_ABI sceVideoOutClose(s32 handle);
|
||||||
} // namespace HLE::Libs::Graphics::VideoOut
|
} // namespace HLE::Libs::Graphics::VideoOut
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include <Lib/Timer.h>
|
#include <Lib/Timer.h>
|
||||||
|
|
||||||
#include "debug.h"
|
#include "common/debug.h"
|
||||||
|
|
||||||
namespace HLE::Kernel::Objects {
|
namespace HLE::Kernel::Objects {
|
||||||
EqueueInternal::~EqueueInternal() {}
|
EqueueInternal::~EqueueInternal() {}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <types.h>
|
#include "common/types.h"
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -76,4 +76,4 @@ class EqueueInternal {
|
||||||
std::vector<EqueueEvent> m_events;
|
std::vector<EqueueEvent> m_events;
|
||||||
std::condition_variable m_cond;
|
std::condition_variable m_cond;
|
||||||
};
|
};
|
||||||
}; // namespace HLE::Kernel::Objects
|
}; // namespace HLE::Kernel::Objects
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <types.h>
|
#include "common/types.h"
|
||||||
#include <core/virtual_memory.h>
|
#include <core/virtual_memory.h>
|
||||||
#include <core/PS4/GPU/gpu_memory.h>
|
#include <core/PS4/GPU/gpu_memory.h>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "ThreadManagement.h"
|
#include "ThreadManagement.h"
|
||||||
|
|
||||||
#include <debug.h>
|
#include "common/debug.h"
|
||||||
|
|
||||||
#include "../ErrorCodes.h"
|
#include "../ErrorCodes.h"
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include "../../../../types.h"
|
#include "common/types.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace HLE::Libs::LibKernel::ThreadManagement {
|
namespace HLE::Libs::LibKernel::ThreadManagement {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "cpu_management.h"
|
#include "cpu_management.h"
|
||||||
#include "Util/config.h"
|
#include "Util/config.h"
|
||||||
#include <Util/log.h>
|
#include "common/log.h"
|
||||||
#include <core/PS4/HLE/Libs.h>
|
#include <core/PS4/HLE/Libs.h>
|
||||||
|
|
||||||
namespace HLE::Libs::LibKernel::CPUManagement {
|
namespace HLE::Libs::LibKernel::CPUManagement {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <types.h>
|
#include "common/types.h"
|
||||||
|
|
||||||
namespace HLE::Libs::LibKernel::CPUManagement {
|
namespace HLE::Libs::LibKernel::CPUManagement {
|
||||||
int PS4_SYSV_ABI sceKernelIsNeoMode();
|
int PS4_SYSV_ABI sceKernelIsNeoMode();
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
#include <core/PS4/HLE/ErrorCodes.h>
|
#include <core/PS4/HLE/ErrorCodes.h>
|
||||||
#include <core/PS4/HLE/Libs.h>
|
#include <core/PS4/HLE/Libs.h>
|
||||||
#include <Util/log.h>
|
#include "common/log.h"
|
||||||
#include <debug.h>
|
#include "common/debug.h"
|
||||||
|
|
||||||
namespace HLE::Libs::LibKernel::EventQueues {
|
namespace HLE::Libs::LibKernel::EventQueues {
|
||||||
constexpr bool log_file_equeues = true; // disable it to disable logging
|
constexpr bool log_file_equeues = true; // disable it to disable logging
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <types.h>
|
|
||||||
|
|
||||||
#include "Objects/event_queue.h"
|
#include "Objects/event_queue.h"
|
||||||
|
|
||||||
namespace HLE::Libs::LibKernel::EventQueues {
|
namespace HLE::Libs::LibKernel::EventQueues {
|
||||||
|
@ -11,4 +9,4 @@ using SceKernelEqueue = Kernel::Objects::EqueueInternal*;
|
||||||
int PS4_SYSV_ABI sceKernelCreateEqueue(SceKernelEqueue* eq, const char* name);
|
int PS4_SYSV_ABI sceKernelCreateEqueue(SceKernelEqueue* eq, const char* name);
|
||||||
int PS4_SYSV_ABI sceKernelWaitEqueue(SceKernelEqueue eq, HLE::Kernel::Objects::SceKernelEvent* ev, int num, int* out, SceKernelUseconds *timo);
|
int PS4_SYSV_ABI sceKernelWaitEqueue(SceKernelEqueue eq, HLE::Kernel::Objects::SceKernelEvent* ev, int num, int* out, SceKernelUseconds *timo);
|
||||||
|
|
||||||
}; // namespace HLE::Libs::LibKernel::EventQueues
|
}; // namespace HLE::Libs::LibKernel::EventQueues
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
|
|
||||||
#include <core/PS4/GPU/gpu_memory.h>
|
#include <core/PS4/GPU/gpu_memory.h>
|
||||||
#include <core/virtual_memory.h>
|
#include <core/virtual_memory.h>
|
||||||
#include <Util/log.h>
|
#include "common/log.h"
|
||||||
#include <debug.h>
|
#include "common/debug.h"
|
||||||
|
|
||||||
#include <bit>
|
#include <bit>
|
||||||
#include <magic_enum.hpp>
|
#include <magic_enum.hpp>
|
||||||
|
|
||||||
#include "Emulator/Util/singleton.h"
|
#include "common/singleton.h"
|
||||||
#include "../ErrorCodes.h"
|
#include "../ErrorCodes.h"
|
||||||
#include "../Libs.h"
|
#include "../Libs.h"
|
||||||
#include "Objects/physical_memory.h"
|
#include "Objects/physical_memory.h"
|
||||||
|
@ -48,20 +48,20 @@ int PS4_SYSV_ABI sceKernelAllocateDirectMemory(s64 searchStart, s64 searchEnd, u
|
||||||
}
|
}
|
||||||
auto memtype = magic_enum::enum_cast<MemoryTypes>(memoryType);
|
auto memtype = magic_enum::enum_cast<MemoryTypes>(memoryType);
|
||||||
|
|
||||||
LOG_INFO_IF(log_file_memory, "search_start = {}\n", log_hex_full(searchStart));
|
LOG_INFO_IF(log_file_memory, "search_start = {:#x}\n", searchStart);
|
||||||
LOG_INFO_IF(log_file_memory, "search_end = {}\n", log_hex_full(searchEnd));
|
LOG_INFO_IF(log_file_memory, "search_end = {:#x}\n", searchEnd);
|
||||||
LOG_INFO_IF(log_file_memory, "len = {}\n", log_hex_full(len));
|
LOG_INFO_IF(log_file_memory, "len = {:#x}\n", len);
|
||||||
LOG_INFO_IF(log_file_memory, "alignment = {}\n", log_hex_full(alignment));
|
LOG_INFO_IF(log_file_memory, "alignment = {:#x}\n", alignment);
|
||||||
LOG_INFO_IF(log_file_memory, "memory_type = {}\n", magic_enum::enum_name(memtype.value()));
|
LOG_INFO_IF(log_file_memory, "memory_type = {}\n", magic_enum::enum_name(memtype.value()));
|
||||||
|
|
||||||
u64 physical_addr = 0;
|
u64 physical_addr = 0;
|
||||||
auto* physical_memory = singleton<HLE::Kernel::Objects::PhysicalMemory>::instance();
|
auto* physical_memory = Common::Singleton<HLE::Kernel::Objects::PhysicalMemory>::Instance();
|
||||||
if (!physical_memory->Alloc(searchStart, searchEnd, len, alignment, &physical_addr, memoryType)) {
|
if (!physical_memory->Alloc(searchStart, searchEnd, len, alignment, &physical_addr, memoryType)) {
|
||||||
LOG_TRACE_IF(log_file_memory, "sceKernelAllocateDirectMemory returned SCE_KERNEL_ERROR_EAGAIN can't allocate physical memory\n");
|
LOG_TRACE_IF(log_file_memory, "sceKernelAllocateDirectMemory returned SCE_KERNEL_ERROR_EAGAIN can't allocate physical memory\n");
|
||||||
return SCE_KERNEL_ERROR_EAGAIN;
|
return SCE_KERNEL_ERROR_EAGAIN;
|
||||||
}
|
}
|
||||||
*physAddrOut = static_cast<s64>(physical_addr);
|
*physAddrOut = static_cast<s64>(physical_addr);
|
||||||
LOG_INFO_IF(true, "physAddrOut = {}\n", log_hex_full(physical_addr));
|
LOG_INFO_IF(true, "physAddrOut = {:#x}\n", physical_addr);
|
||||||
return SCE_OK;
|
return SCE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,11 +82,11 @@ int PS4_SYSV_ABI sceKernelMapDirectMemory(void** addr, u64 len, int prot, int fl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_INFO_IF(log_file_memory, "len = {}\n", log_hex_full(len));
|
LOG_INFO_IF(log_file_memory, "len = {:#x}\n", len);
|
||||||
LOG_INFO_IF(log_file_memory, "prot = {}\n", log_hex_full(prot));
|
LOG_INFO_IF(log_file_memory, "prot = {:#x}\n", prot);
|
||||||
LOG_INFO_IF(log_file_memory, "flags = {}\n", log_hex_full(flags));
|
LOG_INFO_IF(log_file_memory, "flags = {:#x}\n", flags);
|
||||||
LOG_INFO_IF(log_file_memory, "directMemoryStart = {}\n", log_hex_full(directMemoryStart));
|
LOG_INFO_IF(log_file_memory, "directMemoryStart = {:#x}\n", directMemoryStart);
|
||||||
LOG_INFO_IF(log_file_memory, "alignment = {}\n", log_hex_full(alignment));
|
LOG_INFO_IF(log_file_memory, "alignment = {:#x}\n", alignment);
|
||||||
|
|
||||||
VirtualMemory::MemoryMode cpu_mode = VirtualMemory::MemoryMode::NoAccess;
|
VirtualMemory::MemoryMode cpu_mode = VirtualMemory::MemoryMode::NoAccess;
|
||||||
GPU::MemoryMode gpu_mode = GPU::MemoryMode::NoAccess;
|
GPU::MemoryMode gpu_mode = GPU::MemoryMode::NoAccess;
|
||||||
|
@ -106,8 +106,8 @@ int PS4_SYSV_ABI sceKernelMapDirectMemory(void** addr, u64 len, int prot, int fl
|
||||||
if (flags == 0) {
|
if (flags == 0) {
|
||||||
out_addr = VirtualMemory::memory_alloc_aligned(in_addr, len, cpu_mode, alignment);
|
out_addr = VirtualMemory::memory_alloc_aligned(in_addr, len, cpu_mode, alignment);
|
||||||
}
|
}
|
||||||
LOG_INFO_IF(log_file_memory, "in_addr = {}\n", log_hex_full(in_addr));
|
LOG_INFO_IF(log_file_memory, "in_addr = {:#x}\n", in_addr);
|
||||||
LOG_INFO_IF(log_file_memory, "out_addr = {}\n", log_hex_full(out_addr));
|
LOG_INFO_IF(log_file_memory, "out_addr = {:#x}\n", out_addr);
|
||||||
|
|
||||||
*addr = reinterpret_cast<void*>(out_addr); // return out_addr to first functions parameter
|
*addr = reinterpret_cast<void*>(out_addr); // return out_addr to first functions parameter
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ int PS4_SYSV_ABI sceKernelMapDirectMemory(void** addr, u64 len, int prot, int fl
|
||||||
return SCE_KERNEL_ERROR_ENOMEM;
|
return SCE_KERNEL_ERROR_ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* physical_memory = singleton<HLE::Kernel::Objects::PhysicalMemory>::instance();
|
auto* physical_memory = Common::Singleton<HLE::Kernel::Objects::PhysicalMemory>::Instance();
|
||||||
if (!physical_memory->Map(out_addr, directMemoryStart, len, prot, cpu_mode, gpu_mode)) {
|
if (!physical_memory->Map(out_addr, directMemoryStart, len, prot, cpu_mode, gpu_mode)) {
|
||||||
BREAKPOINT();
|
BREAKPOINT();
|
||||||
}
|
}
|
||||||
|
@ -126,4 +126,4 @@ int PS4_SYSV_ABI sceKernelMapDirectMemory(void** addr, u64 len, int prot, int fl
|
||||||
return SCE_OK;
|
return SCE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace HLE::Libs::LibKernel::MemoryManagement
|
} // namespace HLE::Libs::LibKernel::MemoryManagement
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <types.h>
|
#include "common/types.h"
|
||||||
|
|
||||||
// constants
|
// constants
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#include "LibKernel.h"
|
#include "LibKernel.h"
|
||||||
|
|
||||||
#include <Util/log.h>
|
#include "common/log.h"
|
||||||
#include <debug.h>
|
#include "common/debug.h"
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#include "Emulator/Util/singleton.h"
|
#include "common/singleton.h"
|
||||||
#include "../Loader/Elf.h"
|
#include "../Loader/Elf.h"
|
||||||
#include "Kernel/Objects/physical_memory.h"
|
#include "Kernel/Objects/physical_memory.h"
|
||||||
#include "Kernel/cpu_management.h"
|
#include "Kernel/cpu_management.h"
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include "LibSceGnmDriver.h"
|
#include "LibSceGnmDriver.h"
|
||||||
#include "Libs.h"
|
#include "Libs.h"
|
||||||
#include "../Loader/Elf.h"
|
#include "../Loader/Elf.h"
|
||||||
#include <Util/log.h>
|
#include "common/log.h"
|
||||||
#include <debug.h>
|
#include "common/debug.h"
|
||||||
#include <core/PS4/GPU/gpu_memory.h>
|
#include <core/PS4/GPU/gpu_memory.h>
|
||||||
#include <emulator.h>
|
#include <emulator.h>
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#include "Linker.h"
|
#include "Linker.h"
|
||||||
#include "../virtual_memory.h"
|
#include "../virtual_memory.h"
|
||||||
#include <Util/log.h>
|
#include "common/log.h"
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
#include "Zydis.h"
|
#include <Zydis/Zydis.h>
|
||||||
#include <Util/string_util.h>
|
#include "common/string_util.h"
|
||||||
#include "Util/aerolib.h"
|
#include "Util/aerolib.h"
|
||||||
#include "Loader/SymbolsResolver.h"
|
#include "Loader/SymbolsResolver.h"
|
||||||
#include "HLE/Kernel/ThreadManagement.h"
|
#include "HLE/Kernel/ThreadManagement.h"
|
||||||
|
@ -412,7 +412,7 @@ void Linker::LoadSymbols(Module* m)
|
||||||
sym++)
|
sym++)
|
||||||
{
|
{
|
||||||
std::string id = std::string(m->dynamic_info.str_table + sym->st_name);
|
std::string id = std::string(m->dynamic_info.str_table + sym->st_name);
|
||||||
auto ids = StringUtil::split_string(id, '#');
|
const auto ids = Common::SplitString(id, '#');
|
||||||
if (ids.size() == 3)//symbols are 3 parts name , library , module
|
if (ids.size() == 3)//symbols are 3 parts name , library , module
|
||||||
{
|
{
|
||||||
const auto* library = FindLibrary(*m, ids.at(1));
|
const auto* library = FindLibrary(*m, ids.at(1));
|
||||||
|
@ -575,9 +575,8 @@ void Linker::Relocate(Module* m)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Linker::Resolve(const std::string& name, int Symtype, Module* m, SymbolRecord* return_info) {
|
void Linker::Resolve(const std::string& name, int Symtype, Module* m, SymbolRecord* return_info) {
|
||||||
auto ids = StringUtil::split_string(name, '#');
|
const auto ids = Common::SplitString(name, '#');
|
||||||
|
|
||||||
if (ids.size() == 3) // symbols are 3 parts name , library , module
|
if (ids.size() == 3) // symbols are 3 parts name , library , module
|
||||||
{
|
{
|
||||||
const auto* library = FindLibrary(*m, ids.at(1));
|
const auto* library = FindLibrary(*m, ids.at(1));
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "Elf.h"
|
#include "Elf.h"
|
||||||
|
|
||||||
#include <Util/log.h>
|
#include "common/log.h"
|
||||||
#include <debug.h>
|
#include "common/debug.h"
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
|
|
||||||
constexpr bool log_file_loader = true; // disable it to disable logging
|
constexpr bool log_file_loader = true; // disable it to disable logging
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
#include <span>
|
#include <span>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "../../../types.h"
|
#include "common/types.h"
|
||||||
#include "../../FsFile.h"
|
#include "common/fs_file.h"
|
||||||
|
|
||||||
struct self_header
|
struct self_header
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "../../../types.h"
|
#include "common/types.h"
|
||||||
#include "SymbolsResolver.h"
|
#include "SymbolsResolver.h"
|
||||||
#include <Util/log.h>
|
#include "common/log.h"
|
||||||
|
|
||||||
void SymbolsResolver::AddSymbol(const SymbolRes& s, u64 virtual_addr)
|
void SymbolsResolver::AddSymbol(const SymbolRes& s, u64 virtual_addr)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include "../../../types.h"
|
#include "common/types.h"
|
||||||
|
|
||||||
|
|
||||||
struct SymbolRecord
|
struct SymbolRecord
|
||||||
{
|
{
|
||||||
|
@ -37,4 +36,4 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<SymbolRecord> m_symbols;
|
std::vector<SymbolRecord> m_symbols;
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include "Util/aerolib.h"
|
#include "Util/aerolib.h"
|
||||||
|
|
||||||
#include "Util/log.h"
|
#include "common/log.h"
|
||||||
|
|
||||||
// Helper to provide stub implementations for missing functions
|
// Helper to provide stub implementations for missing functions
|
||||||
//
|
//
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "types.h"
|
#include "common/types.h"
|
||||||
|
|
||||||
u64 UnresolvedStub();
|
u64 UnresolvedStub();
|
||||||
u64 GetStub(const char *nid);
|
u64 GetStub(const char *nid);
|
|
@ -1,10 +1,10 @@
|
||||||
#include "aerolib.h"
|
#include "aerolib.h"
|
||||||
|
|
||||||
#include "types.h"
|
#include "common/types.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "Util/log.h"
|
#include "common/log.h"
|
||||||
|
|
||||||
namespace aerolib {
|
namespace aerolib {
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#include "libc.h"
|
#include "libc.h"
|
||||||
|
|
||||||
#include <debug.h>
|
#include "common/debug.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "Emulator/Util/singleton.h"
|
#include "common/singleton.h"
|
||||||
#include "Util/log.h"
|
#include "common/log.h"
|
||||||
#include "core/PS4/HLE/Libs.h"
|
#include "core/PS4/HLE/Libs.h"
|
||||||
#include "core/hle/libraries/libc/libc.h"
|
#include "core/hle/libraries/libc/libc.h"
|
||||||
#include "core/hle/libraries/libc/libc_cxa.h"
|
#include "core/hle/libraries/libc/libc_cxa.h"
|
||||||
|
@ -30,7 +30,7 @@ struct CContext {
|
||||||
};
|
};
|
||||||
|
|
||||||
static PS4_SYSV_ABI int __cxa_atexit(void (*func)(void*), void* arg, void* dso_handle) {
|
static PS4_SYSV_ABI int __cxa_atexit(void (*func)(void*), void* arg, void* dso_handle) {
|
||||||
auto* cc = singleton<CContext>::instance();
|
auto* cc = Common::Singleton<CContext>::Instance();
|
||||||
CxaDestructor c{};
|
CxaDestructor c{};
|
||||||
c.destructor_func = func;
|
c.destructor_func = func;
|
||||||
c.destructor_object = arg;
|
c.destructor_object = arg;
|
||||||
|
@ -127,4 +127,4 @@ void libcSymbolsRegister(SymbolsResolver* sym) {
|
||||||
LIB_FUNCTION("zr094EQ39Ww", "libc", 1, "libc", 1, 1, __cxa_pure_virtual);
|
LIB_FUNCTION("zr094EQ39Ww", "libc", 1, "libc", 1, 1, __cxa_pure_virtual);
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // namespace Core::Libraries::LibC
|
}; // namespace Core::Libraries::LibC
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <types.h>
|
#include "common/types.h"
|
||||||
#include "core/PS4/Loader/SymbolsResolver.h"
|
#include "core/PS4/Loader/SymbolsResolver.h"
|
||||||
|
|
||||||
namespace Core::Libraries::LibC {
|
namespace Core::Libraries::LibC {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "libc_cxa.h"
|
#include "libc_cxa.h"
|
||||||
|
|
||||||
#include "Util/log.h"
|
#include "common/log.h"
|
||||||
#include "debug.h"
|
#include "common/debug.h"
|
||||||
|
|
||||||
// adapted from https://opensource.apple.com/source/libcppabi/libcppabi-14/src/cxa_guard.cxx.auto.html
|
// adapted from https://opensource.apple.com/source/libcppabi/libcppabi-14/src/cxa_guard.cxx.auto.html
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#define _TIMESPEC_DEFINED
|
#define _TIMESPEC_DEFINED
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <types.h>
|
#include "common/types.h"
|
||||||
|
|
||||||
namespace Core::Libraries::LibC {
|
namespace Core::Libraries::LibC {
|
||||||
int PS4_SYSV_ABI __cxa_guard_acquire(u64* guard_object);
|
int PS4_SYSV_ABI __cxa_guard_acquire(u64* guard_object);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <types.h>
|
#include "common/types.h"
|
||||||
|
|
||||||
namespace Core::Libraries::LibC {
|
namespace Core::Libraries::LibC {
|
||||||
float PS4_SYSV_ABI atan2f(float y, float x);
|
float PS4_SYSV_ABI atan2f(float y, float x);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "libc_stdio.h"
|
#include "libc_stdio.h"
|
||||||
|
|
||||||
#include <debug.h>
|
#include "common/debug.h"
|
||||||
#include <Util/log.h>
|
#include "common/log.h"
|
||||||
|
|
||||||
namespace Core::Libraries::LibC {
|
namespace Core::Libraries::LibC {
|
||||||
constexpr bool log_file_libc = true; // disable it to disable logging
|
constexpr bool log_file_libc = true; // disable it to disable logging
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <types.h>
|
#include "common/types.h"
|
||||||
|
|
||||||
#include "printf.h"
|
#include "printf.h"
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "libc_stdlib.h"
|
#include "libc_stdlib.h"
|
||||||
|
|
||||||
#include <Util/log.h>
|
#include "common/log.h"
|
||||||
#include <debug.h>
|
#include "common/debug.h"
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <types.h>
|
#include "common/types.h"
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <types.h>
|
#include "common/types.h"
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include <types.h>
|
#include "common/types.h"
|
||||||
#include <xmmintrin.h>
|
#include <xmmintrin.h>
|
||||||
|
|
||||||
#define VA_ARGS \
|
#define VA_ARGS \
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include "file_system.h"
|
#include "file_system.h"
|
||||||
|
|
||||||
#include <core/PS4/HLE/Libs.h>
|
#include <core/PS4/HLE/Libs.h>
|
||||||
#include <Util/log.h>
|
#include "common/log.h"
|
||||||
#include <debug.h>
|
#include "common/debug.h"
|
||||||
|
|
||||||
namespace Core::Libraries::LibKernel {
|
namespace Core::Libraries::LibKernel {
|
||||||
constexpr bool log_file_fs = true; // disable it to disable logging
|
constexpr bool log_file_fs = true; // disable it to disable logging
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <types.h>
|
#include "common/types.h"
|
||||||
#include "core/PS4/Loader/SymbolsResolver.h"
|
#include "core/PS4/Loader/SymbolsResolver.h"
|
||||||
|
|
||||||
namespace Core::Libraries::LibKernel {
|
namespace Core::Libraries::LibKernel {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "types.h"
|
#include "common/types.h"
|
||||||
#include "core/PS4/Loader/SymbolsResolver.h"
|
#include "core/PS4/Loader/SymbolsResolver.h"
|
||||||
|
|
||||||
namespace Core::Libraries::LibKernel {
|
namespace Core::Libraries::LibKernel {
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
#include <core/PS4/HLE/ErrorCodes.h>
|
#include <core/PS4/HLE/ErrorCodes.h>
|
||||||
#include <core/PS4/HLE/Libs.h>
|
#include <core/PS4/HLE/Libs.h>
|
||||||
|
|
||||||
#include "Emulator/Util/singleton.h"
|
#include "common/singleton.h"
|
||||||
#include "Emulator/Host/controller.h"
|
#include "Emulator/Host/controller.h"
|
||||||
#include <debug.h>
|
#include "common/debug.h"
|
||||||
#include <Util/log.h>
|
#include "common/log.h"
|
||||||
|
|
||||||
namespace Core::Libraries::LibPad {
|
namespace Core::Libraries::LibPad {
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ int PS4_SYSV_ABI scePadOpen(Core::Libraries::LibUserService::SceUserServiceUserI
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI scePadReadState(int32_t handle, ScePadData* pData) {
|
int PS4_SYSV_ABI scePadReadState(int32_t handle, ScePadData* pData) {
|
||||||
auto* controller = singleton<Emulator::Host::Controller::GameController>::instance();
|
auto* controller = Common::Singleton<Emulator::Host::Controller::GameController>::Instance();
|
||||||
|
|
||||||
int connectedCount = 0;
|
int connectedCount = 0;
|
||||||
bool isConnected = false;
|
bool isConnected = false;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <types.h>
|
#include "common/types.h"
|
||||||
|
|
||||||
#include "core/PS4/Loader/SymbolsResolver.h"
|
#include "core/PS4/Loader/SymbolsResolver.h"
|
||||||
#include "core/hle/libraries/libuserservice/user_service.h"
|
#include "core/hle/libraries/libuserservice/user_service.h"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include <core/PS4/HLE/ErrorCodes.h>
|
#include <core/PS4/HLE/ErrorCodes.h>
|
||||||
#include <core/PS4/HLE/Libs.h>
|
#include <core/PS4/HLE/Libs.h>
|
||||||
#include <Util/log.h>
|
#include "common/log.h"
|
||||||
#include "system_service.h"
|
#include "system_service.h"
|
||||||
|
|
||||||
namespace Core::Libraries::LibSystemService {
|
namespace Core::Libraries::LibSystemService {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include <core/PS4/HLE/ErrorCodes.h>
|
#include <core/PS4/HLE/ErrorCodes.h>
|
||||||
#include <core/PS4/HLE/Libs.h>
|
#include <core/PS4/HLE/Libs.h>
|
||||||
|
|
||||||
#include "Util/log.h"
|
#include "common/log.h"
|
||||||
|
|
||||||
namespace Core::Libraries::LibUserService {
|
namespace Core::Libraries::LibUserService {
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
#include "common/debug.h"
|
||||||
|
#include "common/log.h"
|
||||||
#include "virtual_memory.h"
|
#include "virtual_memory.h"
|
||||||
|
|
||||||
#include "core/PS4/Loader/Elf.h"
|
#include "core/PS4/Loader/Elf.h"
|
||||||
|
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
|
@ -19,10 +20,6 @@ enum PosixPageProtection {
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <debug.h>
|
|
||||||
|
|
||||||
#include "../Util/Log.h"
|
|
||||||
|
|
||||||
namespace VirtualMemory {
|
namespace VirtualMemory {
|
||||||
static u32 convertMemoryMode(MemoryMode mode) {
|
static u32 convertMemoryMode(MemoryMode mode) {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <types.h>
|
#include "common/types.h"
|
||||||
|
|
||||||
constexpr u64 SYSTEM_RESERVED = 0x800000000u;
|
constexpr u64 SYSTEM_RESERVED = 0x800000000u;
|
||||||
constexpr u64 CODE_BASE_OFFSET = 0x100000000u;
|
constexpr u64 CODE_BASE_OFFSET = 0x100000000u;
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "types.h"
|
|
||||||
|
#include "common/types.h"
|
||||||
|
|
||||||
namespace Emulator::emuTimer {
|
namespace Emulator::emuTimer {
|
||||||
void start();
|
void start();
|
||||||
double getTimeMsec();
|
double getTimeMsec();
|
||||||
u64 getTimeCounter();
|
u64 getTimeCounter();
|
||||||
u64 getTimeFrequency();
|
u64 getTimeFrequency();
|
||||||
} // namespace Emulator::emuTimer
|
} // namespace Emulator::emuTimer
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
|
|
||||||
#include "core/PS4/HLE/Graphics/video_out.h"
|
#include "core/PS4/HLE/Graphics/video_out.h"
|
||||||
#include "core/hle/libraries/libpad/pad.h"
|
#include "core/hle/libraries/libpad/pad.h"
|
||||||
#include "Emulator/Util/singleton.h"
|
#include "common/singleton.h"
|
||||||
#include "version.h"
|
#include "common/version.h"
|
||||||
|
|
||||||
namespace Emu {
|
namespace Emu {
|
||||||
|
|
||||||
|
@ -27,14 +27,13 @@ int m_fps_frames_num = {0};
|
||||||
double m_fps_start_time = {0};
|
double m_fps_start_time = {0};
|
||||||
|
|
||||||
void emuInit(u32 width, u32 height) {
|
void emuInit(u32 width, u32 height) {
|
||||||
auto* window_ctx = singleton<Emu::WindowCtx>::instance();
|
auto window_ctx = Common::Singleton<Emu::WindowCtx>::Instance();
|
||||||
|
|
||||||
window_ctx->m_graphic_ctx.screen_width = width;
|
window_ctx->m_graphic_ctx.screen_width = width;
|
||||||
window_ctx->m_graphic_ctx.screen_height = height;
|
window_ctx->m_graphic_ctx.screen_height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkAndWaitForGraphicsInit() {
|
void checkAndWaitForGraphicsInit() {
|
||||||
auto* window_ctx = singleton<Emu::WindowCtx>::instance();
|
auto window_ctx = Common::Singleton<Emu::WindowCtx>::Instance();
|
||||||
std::unique_lock lock{window_ctx->m_mutex};
|
std::unique_lock lock{window_ctx->m_mutex};
|
||||||
|
|
||||||
while (!window_ctx->m_is_graphic_initialized) {
|
while (!window_ctx->m_is_graphic_initialized) {
|
||||||
|
@ -49,7 +48,7 @@ static void CreateSdlWindow(WindowCtx* ctx) {
|
||||||
fmt::print("{}\n", SDL_GetError());
|
fmt::print("{}\n", SDL_GetError());
|
||||||
std::exit(0);
|
std::exit(0);
|
||||||
}
|
}
|
||||||
std::string title = "shadps4 v" + std::string(Emulator::VERSION);
|
std::string title = "shadps4 v" + std::string(Common::VERSION);
|
||||||
ctx->m_window = SDL_CreateWindowWithPosition(title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height,
|
ctx->m_window = SDL_CreateWindowWithPosition(title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height,
|
||||||
(static_cast<uint32_t>(SDL_WINDOW_HIDDEN) | static_cast<uint32_t>(SDL_WINDOW_VULKAN)));
|
(static_cast<uint32_t>(SDL_WINDOW_HIDDEN) | static_cast<uint32_t>(SDL_WINDOW_VULKAN)));
|
||||||
|
|
||||||
|
@ -95,7 +94,7 @@ static void calculateFps(double game_time_s) {
|
||||||
void emuRun() {
|
void emuRun() {
|
||||||
Lib::Timer timer;
|
Lib::Timer timer;
|
||||||
timer.Start();
|
timer.Start();
|
||||||
auto* window_ctx = singleton<Emu::WindowCtx>::instance();
|
auto window_ctx = Common::Singleton<Emu::WindowCtx>::Instance();
|
||||||
{
|
{
|
||||||
// init window and wait until init finishes
|
// init window and wait until init finishes
|
||||||
std::scoped_lock lock{window_ctx->m_mutex};
|
std::scoped_lock lock{window_ctx->m_mutex};
|
||||||
|
@ -197,19 +196,19 @@ void emuRun() {
|
||||||
}
|
}
|
||||||
|
|
||||||
HLE::Libs::Graphics::GraphicCtx* getGraphicCtx() {
|
HLE::Libs::Graphics::GraphicCtx* getGraphicCtx() {
|
||||||
auto* window_ctx = singleton<Emu::WindowCtx>::instance();
|
auto window_ctx = Common::Singleton<Emu::WindowCtx>::Instance();
|
||||||
std::scoped_lock lock{window_ctx->m_mutex};
|
std::scoped_lock lock{window_ctx->m_mutex};
|
||||||
return &window_ctx->m_graphic_ctx;
|
return &window_ctx->m_graphic_ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateSDLTitle() {
|
void updateSDLTitle() {
|
||||||
char title[256];
|
const auto title = fmt::format("shadps4 v {} FPS: {}", Common::VERSION, m_current_fps);
|
||||||
sprintf(title, "shadps4 v %s FPS: %f", Emulator::VERSION, m_current_fps);
|
auto window_ctx = Common::Singleton<Emu::WindowCtx>::Instance();
|
||||||
auto* window_ctx = singleton<Emu::WindowCtx>::instance();
|
SDL_SetWindowTitle(window_ctx->m_window, title.c_str());
|
||||||
SDL_SetWindowTitle(window_ctx->m_window, title);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawBuffer(HLE::Libs::Graphics::VideoOutVulkanImage* image) {
|
void DrawBuffer(HLE::Libs::Graphics::VideoOutVulkanImage* image) {
|
||||||
auto* window_ctx = singleton<Emu::WindowCtx>::instance();
|
auto window_ctx = Common::Singleton<Emu::WindowCtx>::Instance();
|
||||||
if (window_ctx->is_window_hidden) {
|
if (window_ctx->is_window_hidden) {
|
||||||
SDL_ShowWindow(window_ctx->m_window);
|
SDL_ShowWindow(window_ctx->m_window);
|
||||||
window_ctx->is_window_hidden = false;
|
window_ctx->is_window_hidden = false;
|
||||||
|
@ -316,11 +315,10 @@ void keyboardEvent(SDL_Event* event) {
|
||||||
case SDLK_KP_2: button = ScePadButton ::SCE_PAD_BUTTON_CROSS; break;
|
case SDLK_KP_2: button = ScePadButton ::SCE_PAD_BUTTON_CROSS; break;
|
||||||
case SDLK_KP_4: button = ScePadButton ::SCE_PAD_BUTTON_SQUARE; break;
|
case SDLK_KP_4: button = ScePadButton ::SCE_PAD_BUTTON_SQUARE; break;
|
||||||
case SDLK_RETURN: button = ScePadButton ::SCE_PAD_BUTTON_OPTIONS; break;
|
case SDLK_RETURN: button = ScePadButton ::SCE_PAD_BUTTON_OPTIONS; break;
|
||||||
|
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
if (button != 0) {
|
if (button != 0) {
|
||||||
auto* controller = singleton<Emulator::Host::Controller::GameController>::instance();
|
auto* controller = Common::Singleton<Emulator::Host::Controller::GameController>::Instance();
|
||||||
controller->checKButton(0, button, event->type == SDL_EVENT_KEY_DOWN);
|
controller->checKButton(0, button, event->type == SDL_EVENT_KEY_DOWN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
21
src/main.cpp
21
src/main.cpp
|
@ -1,8 +1,10 @@
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
#include "types.h"
|
#include "common/discord.h"
|
||||||
#include "Util/log.h"
|
#include "common/types.h"
|
||||||
|
#include "common/log.h"
|
||||||
|
#include "common/singleton.h"
|
||||||
#include <core/PS4/HLE/Graphics/video_out.h>
|
#include <core/PS4/HLE/Graphics/video_out.h>
|
||||||
#include <Util/config.h>
|
#include <Util/config.h>
|
||||||
#include <Zydis/Zydis.h>
|
#include <Zydis/Zydis.h>
|
||||||
|
@ -11,32 +13,29 @@
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include "core/PS4/HLE/Libs.h"
|
#include "core/PS4/HLE/Libs.h"
|
||||||
#include "core/PS4/Linker.h"
|
#include "core/PS4/Linker.h"
|
||||||
#include "Emulator/Util\singleton.h"
|
|
||||||
#include "discord.h"
|
|
||||||
#include "emuTimer.h"
|
#include "emuTimer.h"
|
||||||
|
|
||||||
// Main code
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
fmt::print("Usage: {} <elf or eboot.bin path>\n", argv[0]);
|
fmt::print("Usage: {} <elf or eboot.bin path>\n", argv[0]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
Config::load("config.toml");
|
Config::load("config.toml");
|
||||||
logging::init(true); // init logging
|
Common::Log::Init(true);
|
||||||
auto width = Config::getScreenWidth();
|
auto width = Config::getScreenWidth();
|
||||||
auto height = Config::getScreenHeight();
|
auto height = Config::getScreenHeight();
|
||||||
Emu::emuInit(width, height);
|
Emu::emuInit(width, height);
|
||||||
HLE::Libs::Graphics::VideoOut::videoOutInit(width, height);
|
HLE::Libs::Graphics::VideoOut::videoOutInit(width, height);
|
||||||
Emulator::emuTimer::start();
|
Emulator::emuTimer::start();
|
||||||
|
|
||||||
const char* const path = argv[1]; // argument 1 is the path of self file to boot
|
// Argument 1 is the path of self file to boot
|
||||||
|
const char* const path = argv[1];
|
||||||
|
|
||||||
auto linker = singleton<Linker>::instance();
|
auto linker = Common::Singleton<Linker>::Instance();
|
||||||
HLE::Libs::Init_HLE_Libs(&linker->getHLESymbols());
|
HLE::Libs::Init_HLE_Libs(&linker->getHLESymbols());
|
||||||
linker->LoadModule(path); // Load main executable
|
linker->LoadModule(path);
|
||||||
std::jthread mainthread(
|
std::jthread mainthread(
|
||||||
[](std::stop_token stop_token, void*) {
|
[linker](std::stop_token stop_token, void*) {
|
||||||
auto* linker = singleton<Linker>::instance();
|
|
||||||
linker->Execute();
|
linker->Execute();
|
||||||
},
|
},
|
||||||
nullptr);
|
nullptr);
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
#include <core/PS4/GPU/gpu_memory.h>
|
#include <core/PS4/GPU/gpu_memory.h>
|
||||||
#include <SDL_vulkan.h>
|
#include <SDL_vulkan.h>
|
||||||
#include <Emulator/Util/singleton.h>
|
#include "common/singleton.h"
|
||||||
#include <Util/log.h>
|
#include "common/log.h"
|
||||||
#include <debug.h>
|
#include "common/debug.h"
|
||||||
#include <vulkan/vk_enum_string_helper.h>
|
#include <vulkan/vk_enum_string_helper.h>
|
||||||
#include <vulkan/vulkan_core.h>
|
#include <vulkan/vulkan_core.h>
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ void Graphics::Vulkan::vulkanCreate(Emu::WindowCtx* ctx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Emu::VulkanSwapchain Graphics::Vulkan::vulkanCreateSwapchain(HLE::Libs::Graphics::GraphicCtx* ctx, u32 image_count) {
|
Emu::VulkanSwapchain Graphics::Vulkan::vulkanCreateSwapchain(HLE::Libs::Graphics::GraphicCtx* ctx, u32 image_count) {
|
||||||
auto window_ctx = singleton<Emu::WindowCtx>::instance();
|
auto window_ctx = Common::Singleton<Emu::WindowCtx>::Instance();
|
||||||
const auto& capabilities = window_ctx->m_surface_capabilities.capabilities;
|
const auto& capabilities = window_ctx->m_surface_capabilities.capabilities;
|
||||||
Emu::VulkanSwapchain s{};
|
Emu::VulkanSwapchain s{};
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <core/PS4/HLE/Graphics/graphics_render.h>
|
#include <core/PS4/HLE/Graphics/graphics_render.h>
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <src/video/khronos/vulkan/vulkan_core.h>
|
#include <vulkan/vulkan_core.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
|
@ -1,69 +1,71 @@
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
if (MSVC)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
# Silence "deprecation" warnings
|
||||||
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Discord-RPC
|
||||||
|
set(BUILD_EXAMPLES OFF CACHE BOOL "")
|
||||||
|
add_subdirectory(discord-rpc EXCLUDE_FROM_ALL)
|
||||||
|
target_include_directories(discord-rpc INTERFACE ./discord-rpc/include)
|
||||||
|
|
||||||
#====================FMT ====================
|
# fmtlib
|
||||||
set(fmt_DIR ${CMAKE_CURRENT_SOURCE_DIR}/fmt)
|
add_subdirectory(fmt EXCLUDE_FROM_ALL)
|
||||||
add_subdirectory(${fmt_DIR})
|
|
||||||
|
|
||||||
#=================== SPD ====================
|
# MagicEnum
|
||||||
|
add_subdirectory(magic_enum EXCLUDE_FROM_ALL)
|
||||||
|
|
||||||
|
# Spdlog
|
||||||
set(SPDLOG_WCHAR_FILENAMES ON CACHE BOOL "")
|
set(SPDLOG_WCHAR_FILENAMES ON CACHE BOOL "")
|
||||||
set(SPDLOG_NO_THREAD_ID ON CACHE BOOL "")
|
set(SPDLOG_NO_THREAD_ID ON CACHE BOOL "")
|
||||||
set(SPDLOG_FMT_EXTERNAL ON CACHE BOOL "")
|
set(SPDLOG_FMT_EXTERNAL ON CACHE BOOL "")
|
||||||
add_subdirectory(spdlog EXCLUDE_FROM_ALL)
|
add_subdirectory(spdlog EXCLUDE_FROM_ALL)
|
||||||
add_library(stb INTERFACE)
|
add_library(stb INTERFACE)
|
||||||
target_include_directories(stb INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/stb")
|
target_include_directories(stb INTERFACE ./stb)
|
||||||
|
|
||||||
#=================== SDL3 ===================
|
# SDL3
|
||||||
|
add_subdirectory(SDL EXCLUDE_FROM_ALL)
|
||||||
|
|
||||||
set(SDL3_DIR ${CMAKE_CURRENT_SOURCE_DIR}/SDL)
|
# Toml11
|
||||||
add_subdirectory(${SDL3_DIR})
|
add_subdirectory(toml11 EXCLUDE_FROM_ALL)
|
||||||
|
|
||||||
#================ Zydis ========================
|
# Vulkan
|
||||||
# Register Zydis dependency.
|
add_subdirectory(vulkan EXCLUDE_FROM_ALL)
|
||||||
# Disable build of tools and examples.
|
target_include_directories(vulkan-1 INTERFACE vulkan/include)
|
||||||
|
|
||||||
|
# Winpthreads
|
||||||
|
if (WIN32)
|
||||||
|
add_subdirectory(winpthread EXCLUDE_FROM_ALL)
|
||||||
|
target_include_directories(winpthread INTERFACE winpthread/include)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# xxHash
|
||||||
|
add_library(xxhash INTERFACE)
|
||||||
|
target_include_directories(xxhash INTERFACE xxhash)
|
||||||
|
|
||||||
|
# Zydis
|
||||||
option(ZYDIS_BUILD_TOOLS "" OFF)
|
option(ZYDIS_BUILD_TOOLS "" OFF)
|
||||||
option(ZYDIS_BUILD_EXAMPLES "" OFF)
|
option(ZYDIS_BUILD_EXAMPLES "" OFF)
|
||||||
set(zydis_DIR ${CMAKE_CURRENT_SOURCE_DIR}/zydis)
|
add_subdirectory(zydis EXCLUDE_FROM_ALL)
|
||||||
add_subdirectory(${zydis_DIR})
|
|
||||||
|
|
||||||
#========== winpthreads ======================
|
# Imgui
|
||||||
add_subdirectory(winpthread)
|
add_library(imgui STATIC)
|
||||||
#=================== discord-rpc ===================
|
|
||||||
add_subdirectory(discord-rpc)
|
|
||||||
#=================== toml11 ===================
|
|
||||||
add_subdirectory(toml11)
|
|
||||||
#=================== vulkan ==================
|
|
||||||
add_subdirectory(vulkan)
|
|
||||||
#=================== IMGUI ===================
|
|
||||||
|
|
||||||
set(IMGUI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/imgui)
|
target_sources(imgui PRIVATE
|
||||||
add_library(IMGUI STATIC)
|
imgui/imgui_demo.cpp
|
||||||
|
imgui/imgui_draw.cpp
|
||||||
|
imgui/imgui_tables.cpp
|
||||||
target_sources( IMGUI
|
imgui/imgui_widgets.cpp
|
||||||
PRIVATE
|
imgui/imgui.cpp
|
||||||
${IMGUI_DIR}/imgui_demo.cpp
|
imgui/backends/imgui_impl_opengl3.cpp
|
||||||
${IMGUI_DIR}/imgui_draw.cpp
|
imgui/backends/imgui_impl_sdl3.cpp
|
||||||
${IMGUI_DIR}/imgui_tables.cpp
|
)
|
||||||
${IMGUI_DIR}/imgui_widgets.cpp
|
|
||||||
${IMGUI_DIR}/imgui.cpp
|
target_include_directories(imgui PUBLIC
|
||||||
|
imgui
|
||||||
PRIVATE
|
imgui/backends
|
||||||
${IMGUI_DIR}/backends/imgui_impl_opengl3.cpp
|
imgui/include
|
||||||
${IMGUI_DIR}/backends/imgui_impl_sdl3.cpp
|
)
|
||||||
)
|
|
||||||
|
target_link_libraries(imgui PRIVATE SDL3-shared ${CMAKE_DL_LIBS} Zydis winpthread discord-rpc)
|
||||||
target_include_directories( IMGUI
|
|
||||||
PUBLIC ${IMGUI_DIR}
|
|
||||||
PUBLIC ${IMGUI_DIR}/backends
|
|
||||||
PUBLIC ${SDL3_DIR}/include
|
|
||||||
)
|
|
||||||
|
|
||||||
find_package(OpenGL REQUIRED)
|
|
||||||
target_link_libraries(IMGUI PUBLIC ${OPENGL_LIBRARIES})
|
|
||||||
|
|
||||||
|
|
||||||
target_link_libraries(IMGUI PUBLIC SDL3-shared ${CMAKE_DL_LIBS} Zydis winpthread discord-rpc)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue