Merge branch 'master' into gl-flip

This commit is contained in:
raven02 2016-06-19 00:28:02 +08:00 committed by GitHub
commit f6b5f02501
23 changed files with 846 additions and 68 deletions

View File

@ -1,3 +1,3 @@
{
"userBlacklist": ["AlexAltea"]
}
"userBlacklist": ["AlexAltea", "tambry"]
}

View File

@ -0,0 +1,60 @@
#include "stdafx.h"
#include "dynamic_library.h"
#ifdef _WIN32
#include <Windows.h>
#else
#include <dlfcn.h>
#endif
namespace utils
{
dynamic_library::dynamic_library(const std::string &path)
{
load(path);
}
dynamic_library::~dynamic_library()
{
close();
}
bool dynamic_library::load(const std::string &path)
{
#ifdef _WIN32
m_handle = LoadLibraryA(path.c_str());
#else
m_handle = dlopen(path.c_str(), RTLD_LAZY);
#endif
return loaded();
}
void dynamic_library::close()
{
#ifdef _WIN32
FreeLibrary((HMODULE)m_handle);
#else
dlclose(m_handle);
#endif
m_handle = nullptr;
}
void *dynamic_library::get_impl(const std::string &name) const
{
#ifdef _WIN32
return GetProcAddress((HMODULE)m_handle, name.c_str());
#else
return dlsym(m_handle, (char *)name.c_str());
#endif
}
bool dynamic_library::loaded() const
{
return !m_handle;
}
dynamic_library::operator bool() const
{
return loaded();
}
}

View File

@ -0,0 +1,41 @@
#include <string>
namespace utils
{
class dynamic_library
{
void *m_handle = nullptr;
public:
dynamic_library() = default;
dynamic_library(const std::string &path);
~dynamic_library();
bool load(const std::string &path);
void close();
private:
void *get_impl(const std::string &name) const;
public:
template<typename Type = void>
Type *get(const std::string &name) const
{
Type *result;
*(void **)(&result) = get_impl(name);
return result;
}
template<typename Type>
bool get(Type *&function, const std::string &name) const
{
*(void **)(&function) = get_impl(name);
return !!function;
}
bool loaded() const;
explicit operator bool() const;
};
}

65
Utilities/version.cpp Normal file
View File

@ -0,0 +1,65 @@
#include "stdafx.h"
#include "version.h"
namespace utils
{
std::string to_string(version_type type)
{
switch (type)
{
case version_type::pre_alpha: return "Pre-Alpha";
case version_type::alpha: return "Alpha";
case version_type::beta: return "Beta";
case version_type::release_candidate: return "RC";
case version_type::release: return "Release";
}
throw;
}
version::version(std::uint8_t hi, std::uint8_t mid, std::uint8_t lo)
: m_hi(hi)
, m_mid(mid)
, m_lo(lo)
{
}
version& version::type(version_type type, std::uint8_t type_index)
{
m_type = type;
m_type_index = type_index;
return *this;
}
std::uint16_t version::to_hex() const
{
return (m_hi << 24) | (m_mid << 16) | (m_lo << 8) | ((std::uint8_t(m_type) & 0xf) << 4) | (m_type_index & 0xf);
}
std::string version::to_string() const
{
std::string version = std::to_string(hi()) + "." + std::to_string(mid());
if (lo())
{
version += "." + std::to_string(lo());
}
if (type() != version_type::release)
{
if (!postfix().empty())
{
version += "-" + postfix();
}
version += " " + utils::to_string(type());
if (type_index() > 1)
{
version += " " + std::to_string(type_index());
}
}
return version;
}
}

71
Utilities/version.h Normal file
View File

@ -0,0 +1,71 @@
#pragma once
#include <string>
#include <cstdint>
namespace utils
{
enum class version_type : std::uint8_t
{
pre_alpha,
alpha,
beta,
release_candidate,
release
};
std::string to_string(version_type type);
class version
{
std::uint8_t m_hi;
std::uint8_t m_mid;
std::uint8_t m_lo;
version_type m_type = version_type::release;
std::uint8_t m_type_index = 1;
std::string m_postfix;
public:
version(std::uint8_t hi, std::uint8_t mid, std::uint8_t lo = 0);
version& type(version_type type, std::uint8_t type_index = 1);
std::uint8_t hi() const
{
return m_hi;
}
std::uint8_t mid() const
{
return m_mid;
}
std::uint8_t lo() const
{
return m_lo;
}
version_type type() const
{
return m_type;
}
std::string postfix() const
{
return m_postfix;
}
version& postfix(const std::string& value)
{
m_postfix = value;
return *this;
}
std::uint8_t type_index() const
{
return m_type_index;
}
std::uint16_t to_hex() const;
std::string to_string() const;
};
}

65
ps3emu_api/ps3emu_api.cpp Normal file
View File

@ -0,0 +1,65 @@
#include "ps3emu_api.h"
ps3emu_api::ps3emu_api(const std::string &path)
{
load(path);
}
bool ps3emu_api::load(const std::string &path)
{
if (!m_library.load(path))
{
return false;
}
bool is_no_errors = true;
if (!m_library.get(get_api_version, "ps3emu_api_get_api_version") || get_api_version() != ps3emu_api_version)
{
is_no_errors = false;
}
is_no_errors = is_no_errors && m_library.get(initialize, "ps3emu_api_initialize");
is_no_errors = is_no_errors && m_library.get(destroy, "ps3emu_api_destroy");
is_no_errors = is_no_errors && m_library.get(get_version_string, "ps3emu_api_get_version_string");
is_no_errors = is_no_errors && m_library.get(get_version_number, "ps3emu_api_get_version_number");
is_no_errors = is_no_errors && m_library.get(get_name_string, "ps3emu_api_get_name_string");
is_no_errors = is_no_errors && m_library.get(load_elf, "ps3emu_api_load_elf");
is_no_errors = is_no_errors && m_library.get(set_state, "ps3emu_api_set_state");
is_no_errors = is_no_errors && m_library.get(get_state, "ps3emu_api_get_state");
if (!is_no_errors)
{
close();
return false;
}
return true;
}
bool ps3emu_api::loaded() const
{
return m_library.loaded();
}
void ps3emu_api::close()
{
initialize = nullptr;
destroy = nullptr;
get_version_string = nullptr;
get_version_number = nullptr;
get_name_string = nullptr;
load_elf = nullptr;
set_state = nullptr;
get_state = nullptr;
m_library.close();
}
ps3emu_api::operator bool() const
{
return loaded();
}

35
ps3emu_api/ps3emu_api.h Normal file
View File

@ -0,0 +1,35 @@
#pragma once
#include <Utilities/dynamic_library.h>
#include <string>
#include "ps3emu_api_enums.h"
#include "ps3emu_api_structs.h"
class ps3emu_api
{
utils::dynamic_library m_library;
public:
ps3emu_api() = default;
ps3emu_api(const std::string &path);
unsigned int(*get_api_version)() = nullptr;
ps3emu_api_error_code(*initialize)(const ps3emu_api_initialize_callbacks *callbacks) = nullptr;
ps3emu_api_error_code(*destroy)() = nullptr;
ps3emu_api_error_code(*get_version_string)(char *dest_buffer, int dest_buffer_size) = nullptr;
ps3emu_api_error_code(*get_version_number)(int *version_number) = nullptr;
ps3emu_api_error_code(*get_name_string)(char *dest_buffer, int dest_buffer_size) = nullptr;
ps3emu_api_error_code(*load_elf)(const char *path) = nullptr;
ps3emu_api_error_code(*set_state)(ps3emu_api_state state) = nullptr;
ps3emu_api_error_code(*get_state)(ps3emu_api_state *state) = nullptr;
bool load(const std::string &path);
bool loaded() const;
void close();
explicit operator bool() const;
};

View File

@ -198,7 +198,7 @@ if(WIN32)
target_link_libraries(rpcs3 avformat.lib avcodec.lib avutil.lib swresample.lib swscale.lib png16_static ${wxWidgets_LIBRARIES} ${OPENAL_LIBRARY} ${ADDITIONAL_LIBS})
else()
target_link_libraries(rpcs3 ${wxWidgets_LIBRARIES} ${OPENAL_LIBRARY} ${GLEW_LIBRARY} ${OPENGL_LIBRARIES})
target_link_libraries(rpcs3 libavformat.a libavcodec.a libavutil.a libswresample.a libswscale.a png16_static ${ZLIB_LIBRARIES} ${ADDITIONAL_LIBS})
target_link_libraries(rpcs3 libavformat.a libavcodec.a libavutil.a libswresample.a libswscale.a -ldl png16_static ${ZLIB_LIBRARIES} ${ADDITIONAL_LIBS})
if (NOT APPLE)
target_link_libraries(rpcs3 vulkan glslang OSDependent OGLCompiler SPIRV)
endif()

View File

@ -264,6 +264,7 @@ void D3D12GSRender::upload_textures(ID3D12GraphicsCommandList *command_list, siz
case CELL_GCM_TEXTURE_DEPTH16:
case CELL_GCM_TEXTURE_DEPTH16_FLOAT:
case CELL_GCM_TEXTURE_X32_FLOAT:
case CELL_GCM_TEXTURE_W16_Z16_Y16_X16_FLOAT:
case CELL_GCM_TEXTURE_W32_Z32_Y32_X32_FLOAT:
case CELL_GCM_TEXTURE_R5G5B5A1:
case CELL_GCM_TEXTURE_D1R5G5B5:
@ -333,7 +334,6 @@ void D3D12GSRender::upload_textures(ID3D12GraphicsCommandList *command_list, siz
D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_0);
break;
case CELL_GCM_TEXTURE_W16_Z16_Y16_X16_FLOAT:
case CELL_GCM_TEXTURE_A8R8G8B8:
case CELL_GCM_TEXTURE_D8R8G8B8:
{

View File

@ -430,7 +430,9 @@ VKGSRender::VKGSRender() : GSRender(frame_type::Vulkan)
vk::set_current_thread_ctx(m_thread_context);
vk::set_current_renderer(m_swap_chain->get_device());
m_swap_chain->init_swapchain(m_frame->client_width(), m_frame->client_height());
m_client_width = m_frame->client_width();
m_client_height = m_frame->client_height();
m_swap_chain->init_swapchain(m_client_width, m_client_height);
//create command buffer...
m_command_buffer_pool.create((*m_device));
@ -1135,13 +1137,9 @@ void VKGSRender::prepare_rtts()
return;
m_rtts_dirty = false;
bool reconfigure_render_pass = true;
if (m_surface.format != surface_format)
{
m_surface.unpack(surface_format);
reconfigure_render_pass = true;
}
u32 clip_horizontal = rsx::method_registers[NV4097_SET_SURFACE_CLIP_HORIZONTAL];
u32 clip_vertical = rsx::method_registers[NV4097_SET_SURFACE_CLIP_VERTICAL];
@ -1202,18 +1200,27 @@ void VKGSRender::prepare_rtts()
void VKGSRender::flip(int buffer)
{
//LOG_NOTICE(Log::RSX, "flip(%d)", buffer);
u32 buffer_width = gcm_buffers[buffer].width;
u32 buffer_height = gcm_buffers[buffer].height;
u32 buffer_pitch = gcm_buffers[buffer].pitch;
bool resize_screen = false;
rsx::tiled_region buffer_region = get_tiled_address(gcm_buffers[buffer].offset, CELL_GCM_LOCATION_LOCAL);
if (m_client_height != m_frame->client_height() ||
m_client_width != m_frame->client_width())
{
if (!!m_frame->client_height() && !!m_frame->client_width())
resize_screen = true;
}
areai screen_area = coordi({}, { (int)buffer_width, (int)buffer_height });
coordi aspect_ratio;
if (1) //enable aspect ratio
if (!resize_screen)
{
u32 buffer_width = gcm_buffers[buffer].width;
u32 buffer_height = gcm_buffers[buffer].height;
u32 buffer_pitch = gcm_buffers[buffer].pitch;
rsx::tiled_region buffer_region = get_tiled_address(gcm_buffers[buffer].offset, CELL_GCM_LOCATION_LOCAL);
areai screen_area = coordi({}, { (int)buffer_width, (int)buffer_height });
coordi aspect_ratio;
sizei csize = { m_frame->client_width(), m_frame->client_height() };
sizei new_size = csize;
@ -1233,53 +1240,112 @@ void VKGSRender::flip(int buffer)
}
aspect_ratio.size = new_size;
VkSwapchainKHR swap_chain = (VkSwapchainKHR)(*m_swap_chain);
//Prepare surface for new frame
CHECK_RESULT(vkAcquireNextImageKHR((*m_device), (*m_swap_chain), 0, m_present_semaphore, VK_NULL_HANDLE, &m_current_present_image));
//Blit contents to screen..
VkImage image_to_flip = nullptr;
if (std::get<1>(m_rtts.m_bound_render_targets[0]) != nullptr)
image_to_flip = std::get<1>(m_rtts.m_bound_render_targets[0])->value;
else if (std::get<1>(m_rtts.m_bound_render_targets[1]) != nullptr)
image_to_flip = std::get<1>(m_rtts.m_bound_render_targets[1])->value;
VkImage target_image = m_swap_chain->get_swap_chain_image(m_current_present_image);
if (image_to_flip)
{
vk::copy_scaled_image(m_command_buffer, image_to_flip, target_image, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,
buffer_width, buffer_height, aspect_ratio.width, aspect_ratio.height, 1, VK_IMAGE_ASPECT_COLOR_BIT);
}
else
{
//No draw call was issued!
VkImageSubresourceRange range = vk::get_image_subresource_range(0, 0, 1, 1, VK_IMAGE_ASPECT_COLOR_BIT);
VkClearColorValue clear_black = { 0 };
vk::change_image_layout(m_command_buffer, m_swap_chain->get_swap_chain_image(m_current_present_image), VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, VK_IMAGE_LAYOUT_GENERAL, range);
vkCmdClearColorImage(m_command_buffer, m_swap_chain->get_swap_chain_image(m_current_present_image), VK_IMAGE_LAYOUT_GENERAL, &clear_black, 1, &range);
vk::change_image_layout(m_command_buffer, m_swap_chain->get_swap_chain_image(m_current_present_image), VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, range);
}
close_and_submit_command_buffer({ m_present_semaphore }, m_submit_fence);
CHECK_RESULT(vkWaitForFences((*m_device), 1, &m_submit_fence, VK_TRUE, ~0ULL));
VkPresentInfoKHR present = {};
present.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
present.pNext = nullptr;
present.swapchainCount = 1;
present.pSwapchains = &swap_chain;
present.pImageIndices = &m_current_present_image;
CHECK_RESULT(m_swap_chain->queuePresentKHR(m_swap_chain->get_present_queue(), &present));
}
else
{
aspect_ratio.size = { m_frame->client_width(), m_frame->client_height() };
/**
* Since we are about to destroy the old swapchain and its images, we just discard the commandbuffer.
* Waiting for the commands to process does not work reliably as the fence can be signaled before swap images are released
* and there are no explicit methods to ensure that the presentation engine is not using the images at all.
*/
CHECK_RESULT(vkEndCommandBuffer(m_command_buffer));
//Will have to block until rendering is completed
VkFence resize_fence = VK_NULL_HANDLE;
VkFenceCreateInfo infos = {};
infos.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
vkQueueWaitIdle(m_swap_chain->get_present_queue());
vkDeviceWaitIdle(*m_device);
vkCreateFence((*m_device), &infos, nullptr, &resize_fence);
//Wait for all grpahics tasks to complete
VkPipelineStageFlags pipe_stage_flags = VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT;
VkSubmitInfo submit_infos = {};
submit_infos.commandBufferCount = 0;
submit_infos.pCommandBuffers = nullptr;
submit_infos.pWaitDstStageMask = &pipe_stage_flags;
submit_infos.pWaitSemaphores = nullptr;
submit_infos.waitSemaphoreCount = 0;
submit_infos.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
CHECK_RESULT(vkQueueSubmit(m_swap_chain->get_present_queue(), 1, &submit_infos, resize_fence));
vkWaitForFences((*m_device), 1, &resize_fence, VK_TRUE, UINT64_MAX);
vkResetFences((*m_device), 1, &resize_fence);
vkDeviceWaitIdle(*m_device);
//Rebuild swapchain. Old swapchain destruction is handled by the init_swapchain call
m_client_width = m_frame->client_width();
m_client_height = m_frame->client_height();
m_swap_chain->init_swapchain(m_client_width, m_client_height);
//Prepare new swapchain images for use
CHECK_RESULT(vkResetCommandPool(*m_device, m_command_buffer_pool, 0));
open_command_buffer();
for (u32 i = 0; i < m_swap_chain->get_swap_image_count(); ++i)
{
vk::change_image_layout(m_command_buffer, m_swap_chain->get_swap_chain_image(i),
VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_GENERAL,
vk::get_image_subresource_range(0, 0, 1, 1, VK_IMAGE_ASPECT_COLOR_BIT));
VkClearColorValue clear_color{};
auto range = vk::get_image_subresource_range(0, 0, 1, 1, VK_IMAGE_ASPECT_COLOR_BIT);
vkCmdClearColorImage(m_command_buffer, m_swap_chain->get_swap_chain_image(i), VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range);
vk::change_image_layout(m_command_buffer, m_swap_chain->get_swap_chain_image(i),
VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,
vk::get_image_subresource_range(0, 0, 1, 1, VK_IMAGE_ASPECT_COLOR_BIT));
}
//Flush the command buffer
close_and_submit_command_buffer({}, resize_fence);
CHECK_RESULT(vkWaitForFences((*m_device), 1, &resize_fence, VK_TRUE, UINT64_MAX));
vkDestroyFence((*m_device), resize_fence, nullptr);
}
VkSwapchainKHR swap_chain = (VkSwapchainKHR)(*m_swap_chain);
//Prepare surface for new frame
CHECK_RESULT(vkAcquireNextImageKHR((*m_device), (*m_swap_chain), 0, m_present_semaphore, VK_NULL_HANDLE, &m_current_present_image));
//Blit contents to screen..
VkImage image_to_flip = nullptr;
if (std::get<1>(m_rtts.m_bound_render_targets[0]) != nullptr)
image_to_flip = std::get<1>(m_rtts.m_bound_render_targets[0])->value;
else if (std::get<1>(m_rtts.m_bound_render_targets[1]) != nullptr)
image_to_flip = std::get<1>(m_rtts.m_bound_render_targets[1])->value;
VkImage target_image = m_swap_chain->get_swap_chain_image(m_current_present_image);
if (image_to_flip)
{
vk::copy_scaled_image(m_command_buffer, image_to_flip, target_image, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,
buffer_width, buffer_height, aspect_ratio.width, aspect_ratio.height, 1, VK_IMAGE_ASPECT_COLOR_BIT);
}
else
{
//No draw call was issued!
VkImageSubresourceRange range = vk::get_image_subresource_range(0, 0, 1, 1, VK_IMAGE_ASPECT_COLOR_BIT);
VkClearColorValue clear_black = { 0 };
vk::change_image_layout(m_command_buffer, m_swap_chain->get_swap_chain_image(m_current_present_image), VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, VK_IMAGE_LAYOUT_GENERAL, range);
vkCmdClearColorImage(m_command_buffer, m_swap_chain->get_swap_chain_image(m_current_present_image), VK_IMAGE_LAYOUT_GENERAL, &clear_black, 1, &range);
vk::change_image_layout(m_command_buffer, m_swap_chain->get_swap_chain_image(m_current_present_image), VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, range);
}
close_and_submit_command_buffer({ m_present_semaphore }, m_submit_fence);
CHECK_RESULT(vkWaitForFences((*m_device), 1, &m_submit_fence, VK_TRUE, ~0ULL));
VkPresentInfoKHR present = {};
present.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
present.pNext = nullptr;
present.swapchainCount = 1;
present.pSwapchains = &swap_chain;
present.pImageIndices = &m_current_present_image;
CHECK_RESULT(m_swap_chain->queuePresentKHR(m_swap_chain->get_present_queue(), &present));
m_uniform_buffer_ring_info.m_get_pos = m_uniform_buffer_ring_info.get_current_put_pos_minus_one();
m_index_buffer_ring_info.m_get_pos = m_index_buffer_ring_info.get_current_put_pos_minus_one();
m_attrib_ring_info.m_get_pos = m_attrib_ring_info.get_current_put_pos_minus_one();

View File

@ -69,6 +69,9 @@ private:
std::vector<std::unique_ptr<vk::framebuffer> > m_framebuffer_to_clean;
std::vector<std::unique_ptr<vk::sampler> > m_sampler_to_clean;
u32 m_client_width = 0;
u32 m_client_height = 0;
u32 m_draw_calls = 0;
u32 m_used_descriptors = 0;
u8 m_draw_buffers_count = 0;

View File

@ -1,4 +1,5 @@
#pragma once
#include "rpcs3_version.h"
class AboutDialog : public wxDialog
{
@ -30,7 +31,7 @@ public:
t_descr->SetForegroundColour(wxColor(255, 255, 255));
t_descr->SetPosition(wxPoint(12, 50));
wxStaticText* t_version = new wxStaticText(this, wxID_ANY, wxString::Format(_PRGNAME_ " Version: " _PRGVER_ "-" RPCS3_GIT_VERSION));
wxStaticText* t_version = new wxStaticText(this, wxID_ANY, std::string(_PRGNAME_ " Version: ") + rpcs3::version.to_string());
t_version->SetBackgroundColour(wxColor(100, 100, 100));
t_version->SetForegroundColour(wxColor(200, 200, 200));
t_version->SetPosition(wxPoint(12, 66));

View File

@ -2,7 +2,7 @@
#include "stdafx_gui.h"
#include "rpcs3.h"
#include "MainFrame.h"
#include "git-version.h"
#include "rpcs3_version.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
@ -69,7 +69,7 @@ MainFrame::MainFrame()
, m_sys_menu_opened(false)
{
SetLabel(_PRGNAME_ " v" _PRGVER_ "-" RPCS3_GIT_VERSION);
SetLabel(std::string(_PRGNAME_ " v") + rpcs3::version.to_string());
wxMenuBar* menubar = new wxMenuBar();
@ -158,7 +158,7 @@ MainFrame::MainFrame()
wxGetApp().Bind(wxEVT_KEY_DOWN, &MainFrame::OnKeyDown, this);
wxGetApp().Bind(wxEVT_DBG_COMMAND, &MainFrame::UpdateUI, this);
LOG_NOTICE(GENERAL, "%s", _PRGNAME_ " v" _PRGVER_ "-" RPCS3_GIT_VERSION);
LOG_NOTICE(GENERAL, "%s", (std::string(_PRGNAME_ " v") + rpcs3::version.to_string()).c_str());
LOG_NOTICE(GENERAL, "");
}

View File

@ -63,9 +63,37 @@
<PrecompiledHeader>Use</PrecompiledHeader>
<AdditionalIncludeDirectories>..\llvm\include;..\llvm_build\include;</AdditionalIncludeDirectories>
</ClCompile>
<PreBuildEvent>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug - MemLeak|x64'">%windir%\sysnative\cmd.exe /c "$(SolutionDir)\Utilities\git-version-gen.cmd"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug - MemLeak|x64'">Updating git-version.h</Message>
</PreBuildEvent>
<PreBuildEvent>
<Command Condition="'$(Configuration)|$(Platform)'=='Release - LLVM|x64'">%windir%\sysnative\cmd.exe /c "$(SolutionDir)\Utilities\git-version-gen.cmd"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Release - LLVM|x64'">Updating git-version.h</Message>
</PreBuildEvent>
<PreBuildEvent>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%windir%\sysnative\cmd.exe /c "$(SolutionDir)\Utilities\git-version-gen.cmd"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Updating git-version.h</Message>
</PreBuildEvent>
<PreBuildEvent>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%windir%\sysnative\cmd.exe /c "$(SolutionDir)\Utilities\git-version-gen.cmd"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Updating git-version.h</Message>
</PreBuildEvent>
<PreBuildEvent>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug - LLVM|x64'">%windir%\sysnative\cmd.exe /c "$(SolutionDir)\Utilities\git-version-gen.cmd"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug - LLVM|x64'">Updating git-version.h</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\ps3emu_api\ps3emu_api.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug - LLVM|x64'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release - LLVM|x64'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug - MemLeak|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\Utilities\AutoPause.cpp" />
<ClCompile Include="..\Utilities\dynamic_library.cpp" />
<ClCompile Include="..\Utilities\Log.cpp">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
@ -84,6 +112,7 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\Utilities\Thread.cpp" />
<ClCompile Include="..\Utilities\version.cpp" />
<ClCompile Include="..\Utilities\VirtualMemory.cpp" />
<ClCompile Include="Emu\PSP2\ARMv7Module.cpp" />
<ClCompile Include="Emu\Cell\lv2\lv2.cpp" />
@ -348,6 +377,8 @@
<ClCompile Include="Loader\PSF.cpp" />
<ClCompile Include="Loader\TROPUSR.cpp" />
<ClCompile Include="Loader\TRP.cpp" />
<ClCompile Include="rpcs3_api.cpp" />
<ClCompile Include="rpcs3_version.cpp" />
<ClCompile Include="stb_image.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
@ -355,12 +386,14 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\3rdparty\stblib\stb_image.h" />
<ClInclude Include="..\ps3emu_api\ps3emu_api.h" />
<ClInclude Include="..\Utilities\Atomic.h" />
<ClInclude Include="..\Utilities\AtomicPtr.h" />
<ClInclude Include="..\Utilities\AutoPause.h" />
<ClInclude Include="..\Utilities\BEType.h" />
<ClInclude Include="..\Utilities\BitField.h" />
<ClInclude Include="..\Utilities\BitSet.h" />
<ClInclude Include="..\Utilities\dynamic_library.h" />
<ClInclude Include="..\Utilities\event.h" />
<ClInclude Include="..\Utilities\geometry.h" />
<ClInclude Include="..\Utilities\GSL.h" />
@ -379,6 +412,7 @@
<ClInclude Include="..\Utilities\Thread.h" />
<ClInclude Include="..\Utilities\Timer.h" />
<ClInclude Include="..\Utilities\types.h" />
<ClInclude Include="..\Utilities\version.h" />
<ClInclude Include="..\Utilities\VirtualMemory.h" />
<ClInclude Include="Crypto\aes.h" />
<ClInclude Include="Crypto\ec.h" />
@ -608,7 +642,10 @@
<ClInclude Include="Loader\PSF.h" />
<ClInclude Include="Loader\TROPUSR.h" />
<ClInclude Include="Loader\TRP.h" />
<ClInclude Include="ps3emu_api_enums.h" />
<ClInclude Include="ps3emu_api_structs.h" />
<ClInclude Include="restore_new.h" />
<ClInclude Include="rpcs3_version.h" />
<ClInclude Include="stdafx.h" />
</ItemGroup>
<ItemGroup>

View File

@ -854,6 +854,15 @@
<ClCompile Include="Emu\PSP2\Modules\sceVoiceQoS.cpp">
<Filter>Emu\PSP2\Modules</Filter>
</ClCompile>
<ClCompile Include="..\Utilities\dynamic_library.cpp">
<Filter>Utilities</Filter>
</ClCompile>
<ClCompile Include="rpcs3_api.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\ps3emu_api\ps3emu_api.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Crypto\aes.h">
@ -1624,5 +1633,17 @@
<ClInclude Include="..\Utilities\sync.h">
<Filter>Utilities</Filter>
</ClInclude>
<ClInclude Include="..\Utilities\dynamic_library.h">
<Filter>Utilities</Filter>
</ClInclude>
<ClInclude Include="ps3emu_api_enums.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ps3emu_api_structs.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\ps3emu_api\ps3emu_api.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

51
rpcs3/ps3emu_api_enums.h Normal file
View File

@ -0,0 +1,51 @@
#pragma once
#ifndef _PS3EMU_API_ENUMS
#define _PS3EMU_API_ENUMS
#ifdef __cplusplus
extern"C"
{
#endif /* __cplusplus */
typedef enum
{
ps3emu_api_ok,
ps3emu_api_bad_argument,
ps3emu_api_not_found,
ps3emu_api_internal_error,
ps3emu_api_not_initialized,
ps3emu_api_already_initialized
} ps3emu_api_error_code;
enum
{
ps3emu_api_version = 1,
ps3emu_api_max_name_length = 16,
ps3emu_api_max_version_length = 64
};
typedef enum
{
ps3emu_api_state_idle,
ps3emu_api_state_stoping,
ps3emu_api_state_stopped,
ps3emu_api_state_pausing,
ps3emu_api_state_paused,
ps3emu_api_state_starting,
ps3emu_api_state_started
} ps3emu_api_state;
typedef enum
{
ps3emu_api_window_null,
ps3emu_api_window_opengl,
ps3emu_api_window_vulkan
/* ps3emu_api_window_direct3d */
} ps3emu_api_window_type;
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _PS3EMU_API_ENUMS */

View File

@ -0,0 +1,23 @@
#ifndef _PS3EMU_API_STRUCTS
#define _PS3EMU_API_STRUCTS
#include "ps3emu_api_enums.h"
#ifdef __cplusplus
extern"C"
{
#endif /* __cplusplus */
typedef struct ps3emu_api_window_handle_s * ps3emu_api_window;
typedef struct
{
ps3emu_api_error_code(*create_window)(ps3emu_api_window *window, ps3emu_api_window_type type, unsigned int version);
ps3emu_api_error_code(*destroy_window)(ps3emu_api_window window);
ps3emu_api_error_code(*flip)(ps3emu_api_window window);
} ps3emu_api_initialize_callbacks;
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _PS3EMU_API_STRUCTS */

View File

@ -84,8 +84,10 @@
</PropertyGroup>
<ItemDefinitionGroup>
<PreBuildEvent>
<Command>%windir%\sysnative\cmd.exe /c "$(SolutionDir)\Utilities\git-version-gen.cmd"</Command>
<Message>Updating git-version.h</Message>
<Command>
</Command>
<Message>
</Message>
</PreBuildEvent>
<ClCompile>
<AdditionalIncludeDirectories>..\wxWidgets\include\msvc;..\wxWidgets\include;..\3rdparty\XAudio2_7;..\Vulkan\Vulkan-LoaderAndValidationLayers\include;..\Vulkan\glslang\glslang\Public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

219
rpcs3/rpcs3_api.cpp Normal file
View File

@ -0,0 +1,219 @@
#include "stdafx.h"
#include "ps3emu_api_enums.h"
#include "ps3emu_api_structs.h"
#include "rpcs3_version.h"
#include "Emu/System.h"
#ifdef _MSC_VER
#define UTILS_DLL_C_EXPORT extern "C" __declspec(dllexport)
#else
#define UTILS_DLL_C_EXPORT extern "C" __attribute__((visibility("default")))
#endif
static bool g_is_initialized = false;
UTILS_DLL_C_EXPORT unsigned int ps3emu_api_get_api_version()
{
return ps3emu_api_version;
}
UTILS_DLL_C_EXPORT ps3emu_api_error_code ps3emu_api_initialize(const ps3emu_api_initialize_callbacks *callbacks)
{
if (g_is_initialized)
{
return ps3emu_api_already_initialized;
}
if (!callbacks)
{
return ps3emu_api_bad_argument;
}
g_is_initialized = true;
//TODO
return ps3emu_api_ok;
}
UTILS_DLL_C_EXPORT ps3emu_api_error_code ps3emu_api_destroy()
{
if (!g_is_initialized)
{
return ps3emu_api_not_initialized;
}
g_is_initialized = false;
//TODO
return ps3emu_api_ok;
}
UTILS_DLL_C_EXPORT ps3emu_api_error_code ps3emu_api_get_version_string(char *dest_buffer, int dest_buffer_size)
{
if (!g_is_initialized)
{
return ps3emu_api_not_initialized;
}
if (!dest_buffer || dest_buffer_size <= 0)
{
return ps3emu_api_bad_argument;
}
if (dest_buffer_size > ps3emu_api_max_version_length)
{
dest_buffer_size = ps3emu_api_max_version_length;
}
const std::string version_string = rpcs3::version.to_string();
if (dest_buffer_size > version_string.length())
{
dest_buffer_size = version_string.length();
}
std::memcpy(dest_buffer, version_string.c_str(), dest_buffer_size - 1);
dest_buffer[dest_buffer_size - 1] = '\0';
return ps3emu_api_ok;
}
UTILS_DLL_C_EXPORT ps3emu_api_error_code ps3emu_api_get_version_number(int *version_number)
{
if (!g_is_initialized)
{
return ps3emu_api_not_initialized;
}
if (!version_number)
{
return ps3emu_api_bad_argument;
}
*version_number = rpcs3::version.to_hex();
return ps3emu_api_ok;
}
UTILS_DLL_C_EXPORT ps3emu_api_error_code ps3emu_api_get_name_string(char *dest_buffer, int dest_buffer_size)
{
if (!g_is_initialized)
{
return ps3emu_api_not_initialized;
}
if (!dest_buffer || dest_buffer_size <= 0)
{
return ps3emu_api_bad_argument;
}
if (dest_buffer_size > ps3emu_api_max_name_length)
{
dest_buffer_size = ps3emu_api_max_name_length;
}
const std::string name_string = "RPCS3";
if (dest_buffer_size > name_string.length())
{
dest_buffer_size = name_string.length();
}
std::memcpy(dest_buffer, name_string.c_str(), dest_buffer_size - 1);
dest_buffer[dest_buffer_size - 1] = '\0';
return ps3emu_api_ok;
}
UTILS_DLL_C_EXPORT ps3emu_api_error_code ps3emu_api_load_elf(const char *path)
{
if (!g_is_initialized)
{
return ps3emu_api_not_initialized;
}
if (!path)
{
return ps3emu_api_bad_argument;
}
if (!fs::is_file(path))
{
return ps3emu_api_not_found;
}
Emu.SetPath(path);
Emu.Load();
return ps3emu_api_ok;
}
UTILS_DLL_C_EXPORT ps3emu_api_error_code ps3emu_api_set_state(ps3emu_api_state state)
{
if (!g_is_initialized)
{
return ps3emu_api_not_initialized;
}
//TODO state machine
switch (state)
{
case ps3emu_api_state_stoping:
Emu.Stop();
break;
case ps3emu_api_state_pausing:
Emu.Pause();
break;
case ps3emu_api_state_starting:
if (Emu.IsPaused())
{
Emu.Resume();
}
else
{
Emu.Run();
}
break;
default:
return ps3emu_api_bad_argument;
}
return ps3emu_api_ok;
}
UTILS_DLL_C_EXPORT ps3emu_api_error_code ps3emu_api_get_state(ps3emu_api_state *state)
{
if (!g_is_initialized)
{
return ps3emu_api_not_initialized;
}
if (!state)
{
return ps3emu_api_bad_argument;
}
if (Emu.IsRunning())
{
*state = ps3emu_api_state_started;
}
else if (Emu.IsPaused())
{
*state = ps3emu_api_state_paused;
}
else if (Emu.IsStopped())
{
*state = ps3emu_api_state_stopped;
}
else if (Emu.IsReady())
{
*state = ps3emu_api_state_idle;
}
else
{
return ps3emu_api_internal_error;
}
return ps3emu_api_ok;
}

10
rpcs3/rpcs3_version.cpp Normal file
View File

@ -0,0 +1,10 @@
#include "stdafx.h"
#include "rpcs3_version.h"
#include "git-version.h"
namespace rpcs3
{
const utils::version version = utils::version{ 0, 0, 1 }
.type(utils::version_type::pre_alpha)
.postfix(RPCS3_GIT_VERSION);
}

9
rpcs3/rpcs3_version.h Normal file
View File

@ -0,0 +1,9 @@
#pragma once
#include <string>
#include <cstdint>
#include <Utilities/version.h>
namespace rpcs3
{
extern const utils::version version;
}

View File

@ -42,7 +42,6 @@ using namespace std::literals;
#define EXCEPTION(format_str, ...) fmt::exception("%s(): " format_str HERE, __FUNCTION__, ##__VA_ARGS__)
#define _PRGNAME_ "RPCS3"
#define _PRGVER_ "0.0.0.9"
#include "Utilities/types.h"
#include "Utilities/Macro.h"

@ -1 +1 @@
Subproject commit 139d8092b9daaa823f6398d4a273fdc0a1d20c09
Subproject commit b4d09867643df26e503ec09119c8048832676780