Skip to content

Commit

Permalink
Merge branch 'master' of github.com:rajkosto/rpcs3 into mgs4
Browse files Browse the repository at this point in the history
  • Loading branch information
rajkosto committed Dec 18, 2019
2 parents 02dbdd5 + ee3b3f6 commit 2033cc9
Show file tree
Hide file tree
Showing 40 changed files with 1,677 additions and 932 deletions.
7 changes: 4 additions & 3 deletions Utilities/Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1323,8 +1323,8 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context)
{
const auto& spu = static_cast<spu_thread&>(*cpu);

const u64 type = spu.offset < RAW_SPU_BASE_ADDR ?
SYS_MEMORY_PAGE_FAULT_TYPE_SPU_THREAD :
const u64 type = spu.offset < RAW_SPU_BASE_ADDR ?
SYS_MEMORY_PAGE_FAULT_TYPE_SPU_THREAD :
SYS_MEMORY_PAGE_FAULT_TYPE_RAW_SPU;

data2 = (type << 32) | spu.lv2_id;
Expand Down Expand Up @@ -1807,7 +1807,8 @@ void thread_ctrl::_wait_for(u64 usec, bool alert /* true */)
timeout.it_interval.tv_sec = 0;
timeout.it_interval.tv_nsec = 0;
timerfd_settime(_this->m_timer, 0, &timeout, NULL);
read(_this->m_timer, &missed, sizeof(missed));
if (read(_this->m_timer, &missed, sizeof(missed)) != sizeof(missed))
LOG_ERROR(GENERAL, "timerfd: read() failed");
return;
}
#endif
Expand Down
1 change: 1 addition & 0 deletions rpcs3/Emu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ target_sources(rpcs3_emu PRIVATE

if(TARGET 3rdparty_vulkan)
target_sources(rpcs3_emu PRIVATE
RSX/VK/VKCommandStream.cpp
RSX/VK/VKCommonDecompiler.cpp
RSX/VK/VKDMA.cpp
RSX/VK/VKFormats.cpp
Expand Down
6 changes: 3 additions & 3 deletions rpcs3/Emu/Cell/Modules/cellNetCtl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ error_code cellGameUpdateCheckStartAsyncEx(vm::cptr<CellGameUpdateParam> param,
cellNetCtl.todo("cellGameUpdateCheckStartAsyncEx(param=*0x%x, cb_func=*0x%x, userdata=*0x%x)", param, cb_func, userdata);
sysutil_register_cb([=](ppu_thread& ppu) -> s32
{
cb_func(ppu, vm::make_var(CellGameUpdateResult{ CELL_GAMEUPDATE_RESULT_STATUS_NO_UPDATE, CELL_OK, 0x0, 0x0}), userdata);
cb_func(ppu, vm::make_var(CellGameUpdateResult{CELL_GAMEUPDATE_RESULT_STATUS_NO_UPDATE, CELL_OK}), userdata);
return CELL_OK;
});
return CELL_OK;
Expand All @@ -433,7 +433,7 @@ error_code cellGameUpdateCheckFinishAsyncEx(vm::ptr<CellGameUpdateCallbackEx> cb
const s32 PROCESSING_COMPLETE = 5;
sysutil_register_cb([=](ppu_thread& ppu) -> s32
{
cb_func(ppu, vm::make_var(CellGameUpdateResult{ CELL_GAMEUPDATE_RESULT_STATUS_FINISHED, CELL_OK, 0x0, 0x0}), userdata);
cb_func(ppu, vm::make_var(CellGameUpdateResult{CELL_GAMEUPDATE_RESULT_STATUS_FINISHED, CELL_OK}), userdata);
return CELL_OK;
});
return CELL_OK;
Expand All @@ -444,7 +444,7 @@ error_code cellGameUpdateCheckStartWithoutDialogAsyncEx(vm::ptr<CellGameUpdateCa
cellNetCtl.todo("cellGameUpdateCheckStartWithoutDialogAsyncEx(cb_func=*0x%x, userdata=*0x%x)", cb_func, userdata);
sysutil_register_cb([=](ppu_thread& ppu) -> s32
{
cb_func(ppu, vm::make_var(CellGameUpdateResult{ CELL_GAMEUPDATE_RESULT_STATUS_NO_UPDATE, CELL_OK, 0x0, 0x0}), userdata);
cb_func(ppu, vm::make_var(CellGameUpdateResult{CELL_GAMEUPDATE_RESULT_STATUS_NO_UPDATE, CELL_OK}), userdata);
return CELL_OK;
});
return CELL_OK;
Expand Down
8 changes: 4 additions & 4 deletions rpcs3/Emu/Cell/Modules/cellSpurs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ void _spurs::event_helper_entry(ppu_thread& ppu, vm::ptr<CellSpurs> spurs)

s32 _spurs::create_event_helper(ppu_thread& ppu, vm::ptr<CellSpurs> spurs, u32 ppuPriority)
{
if (s32 rc = _spurs::create_lv2_eq(ppu, spurs, spurs.ptr(&CellSpurs::eventQueue), spurs.ptr(&CellSpurs::spuPort), 0x2A, sys_event_queue_attribute_t{ SYS_SYNC_PRIORITY, SYS_PPU_QUEUE, "_spuPrv\0"_u64 }))
if (s32 rc = _spurs::create_lv2_eq(ppu, spurs, spurs.ptr(&CellSpurs::eventQueue), spurs.ptr(&CellSpurs::spuPort), 0x2A, sys_event_queue_attribute_t{SYS_SYNC_PRIORITY, SYS_PPU_QUEUE, {"_spuPrv\0"_u64}}))
{
return rc;
}
Expand Down Expand Up @@ -1142,14 +1142,14 @@ s32 _spurs::initialize(ppu_thread& ppu, vm::ptr<CellSpurs> spurs, u32 revision,
const auto lwCond = spurs.ptr(&CellSpurs::cond);

// Create a mutex to protect access to SPURS handler thread data
if (s32 rc = sys_lwmutex_create(ppu, lwMutex, vm::make_var(sys_lwmutex_attribute_t{ SYS_SYNC_PRIORITY, SYS_SYNC_NOT_RECURSIVE, "_spuPrv\0"_u64 })))
if (s32 rc = sys_lwmutex_create(ppu, lwMutex, vm::make_var(sys_lwmutex_attribute_t{SYS_SYNC_PRIORITY, SYS_SYNC_NOT_RECURSIVE, {"_spuPrv\0"_u64}})))
{
_spurs::finalize_spu(ppu, spurs);
return rollback(), rc;
}

// Create condition variable to signal the SPURS handler thread
if (s32 rc = sys_lwcond_create(ppu, lwCond, lwMutex, vm::make_var(sys_lwcond_attribute_t{ "_spuPrv\0"_u64 })))
if (s32 rc = sys_lwcond_create(ppu, lwCond, lwMutex, vm::make_var(sys_lwcond_attribute_t{"_spuPrv\0"_u64})))
{
sys_lwmutex_destroy(ppu, lwMutex);
_spurs::finalize_spu(ppu, spurs);
Expand Down Expand Up @@ -3046,7 +3046,7 @@ s32 cellSpursEventFlagAttachLv2EventQueue(ppu_thread& ppu, vm::ptr<CellSpursEven
return (rc & 0x0FFF0000) == 0x00410000 ? rc : (0x80410900 | (rc & 0xFF));
};

if (s32 rc = _spurs::create_lv2_eq(ppu, spurs, eventQueueId, port, 1, sys_event_queue_attribute_t{ SYS_SYNC_PRIORITY, SYS_PPU_QUEUE, "_spuEvF\0"_u64 }))
if (s32 rc = _spurs::create_lv2_eq(ppu, spurs, eventQueueId, port, 1, sys_event_queue_attribute_t{SYS_SYNC_PRIORITY, SYS_PPU_QUEUE, {"_spuEvF\0"_u64}}))
{
return failure(rc);
}
Expand Down
5 changes: 2 additions & 3 deletions rpcs3/Emu/Cell/Modules/cellSync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ error_code cellSyncQueueInitialize(vm::ptr<CellSyncQueue> queue, vm::ptr<u8> buf
}

// clear sync var, write size, depth, buffer addr and sync
queue->ctrl.store({ 0, 0 });
queue->ctrl.store({});
queue->size = size;
queue->depth = depth;
queue->buffer = buffer;
Expand Down Expand Up @@ -722,8 +722,7 @@ error_code cellSyncQueueClear(ppu_thread& ppu, vm::ptr<CellSyncQueue> queue)
}
}

queue->ctrl.exchange({ 0, 0 });

queue->ctrl.store({});
return CELL_OK;
}

Expand Down
8 changes: 6 additions & 2 deletions rpcs3/Emu/Cell/Modules/cellSysutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ void fmt_class_string<CellSysutilParamId>::format(std::string& out, u64 arg)
case CELL_SYSUTIL_SYSTEMPARAM_ID_MAGNETOMETER: return "ID_MAGNETOMETER";
case CELL_SYSUTIL_SYSTEMPARAM_ID_NICKNAME: return "ID_NICKNAME";
case CELL_SYSUTIL_SYSTEMPARAM_ID_CURRENT_USERNAME: return "ID_CURRENT_USERNAME";
case CELL_SYSUTIL_SYSTEMPARAM_ID_x1008: return "ID_x1008";
case CELL_SYSUTIL_SYSTEMPARAM_ID_x1011: return "ID_x1011";
case CELL_SYSUTIL_SYSTEMPARAM_ID_x1012: return "ID_x1012";
case CELL_SYSUTIL_SYSTEMPARAM_ID_x1024: return "ID_x1024";
}

return unknown;
Expand All @@ -143,7 +147,7 @@ s32 sysutil_check_name_string(const char* src, s32 minlen, s32 maxlen)
if (g_ps3_process_info.sdk_ver > 0x36FFFF)
{
// Limit null terminator boundary to before buffer max size
lastpos = std::max(maxlen - 1, 0);
lastpos = std::max(maxlen - 1, 0);
}
else
{
Expand Down Expand Up @@ -307,7 +311,7 @@ error_code cellSysutilGetSystemParamString(CellSysutilParamId id, vm::ptr<char>
case CELL_SYSUTIL_SYSTEMPARAM_ID_CURRENT_USERNAME:
{
const fs::file username(vfs::get(fmt::format("/dev_hdd0/home/%08u/localusername", Emu.GetUsrId())));

if (!username)
{
cellSysutil.error("cellSysutilGetSystemParamString(): Username for user %08u doesn't exist. Did you delete the username file?", Emu.GetUsrId());
Expand Down
21 changes: 11 additions & 10 deletions rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include "Emu/Cell/lv2/sys_event.h"
#include "Emu/Cell/lv2/sys_process.h"

#include <cmath>

LOG_CHANNEL(sceNpTrophy);

TrophyNotificationBase::~TrophyNotificationBase()
Expand Down Expand Up @@ -755,11 +757,14 @@ error_code sceNpTrophyGetTrophyUnlockState(u32 context, u32 handle, vm::ptr<SceN
return SCE_NP_TROPHY_ERROR_UNKNOWN_HANDLE;
}

u32 count_ = ctxt->tropusr->GetTrophiesCount();
const u32 count_ = ctxt->tropusr->GetTrophiesCount();
*count = count_;
if (count_ > 128)
sceNpTrophy.error("sceNpTrophyGetTrophyUnlockState: More than 128 trophies detected!");

// Needs hw testing
*flags = {};

// Pack up to 128 bools in u32 flag_bits[4]
for (u32 id = 0; id < count_; id++)
{
Expand Down Expand Up @@ -922,16 +927,12 @@ error_code sceNpTrophyGetGameProgress(u32 context, u32 handle, vm::ptr<s32> perc
return SCE_NP_TROPHY_ERROR_UNKNOWN_HANDLE;
}

double accuratePercentage = 0;
for (int i = ctxt->tropusr->GetTrophiesCount() - 1; i >= 0; i--)
{
if (ctxt->tropusr->GetTrophyUnlockState(i))
{
accuratePercentage++;
}
}
const u32 unlocked = ctxt->tropusr->GetUnlockedTrophiesCount();
const u32 trp_count = ctxt->tropusr->GetTrophiesCount();

*percentage = static_cast<s32>(accuratePercentage / ctxt->tropusr->GetTrophiesCount());
verify(HERE), trp_count > 0 && trp_count <= 128;

*percentage = static_cast<s32>(std::lround((unlocked * 100.) / trp_count));

return CELL_OK;
}
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/Modules/sceNpTrophy.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ struct SceNpTrophyData

struct SceNpTrophyFlagArray
{
u32 flag_bits[SCE_NP_TROPHY_FLAG_SETSIZE >> SCE_NP_TROPHY_FLAG_BITS_SHIFT];
be_t<u32> flag_bits[SCE_NP_TROPHY_FLAG_SETSIZE >> SCE_NP_TROPHY_FLAG_BITS_SHIFT];
};

enum
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/PPUDisAsm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,7 @@ void PPUDisAsm::SC(ppu_opcode_t op)

void PPUDisAsm::B(ppu_opcode_t op)
{
const u32 li = op.li;
const u32 li = op.bt24;
const u32 aa = op.aa;
const u32 lk = op.lk;

Expand Down
56 changes: 11 additions & 45 deletions rpcs3/Emu/RSX/GL/GLGSRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ void GLGSRender::begin()
{
rsx::thread::begin();

if (skip_current_frame ||
(conditional_render_enabled && conditional_render_test_failed))
if (skip_current_frame || cond_render_ctrl.disable_rendering())
return;

init_buffers(rsx::framebuffer_creation_context::context_draw);
Expand All @@ -187,8 +186,7 @@ void GLGSRender::end()
{
m_profiler.start();

if (skip_current_frame || !framebuffer_status_valid ||
(conditional_render_enabled && conditional_render_test_failed))
if (skip_current_frame || !framebuffer_status_valid || cond_render_ctrl.disable_rendering())
{
execute_nop_draw();
rsx::thread::end();
Expand Down Expand Up @@ -1100,14 +1098,22 @@ void GLGSRender::on_exit()

void GLGSRender::clear_surface(u32 arg)
{
if (skip_current_frame || !framebuffer_status_valid) return;
if (skip_current_frame) return;

// If stencil write mask is disabled, remove clear_stencil bit
if (!rsx::method_registers.stencil_mask()) arg &= ~0x2u;

// Ignore invalid clear flags
if ((arg & 0xf3) == 0) return;

u8 ctx = rsx::framebuffer_creation_context::context_draw;
if (arg & 0xF0) ctx |= rsx::framebuffer_creation_context::context_clear_color;
if (arg & 0x3) ctx |= rsx::framebuffer_creation_context::context_clear_depth;

init_buffers(static_cast<rsx::framebuffer_creation_context>(ctx), true);

if (!framebuffer_status_valid) return;

GLbitfield mask = 0;

gl::command_context cmd{ gl_state };
Expand Down Expand Up @@ -1223,46 +1229,6 @@ void GLGSRender::clear_surface(u32 arg)
glClear(mask);
}

bool GLGSRender::do_method(u32 cmd, u32 arg)
{
switch (cmd)
{
case NV4097_CLEAR_SURFACE:
{
if (arg & 0xF3)
{
//Only do all this if we have actual work to do
u8 ctx = rsx::framebuffer_creation_context::context_draw;
if (arg & 0xF0) ctx |= rsx::framebuffer_creation_context::context_clear_color;
if (arg & 0x3) ctx |= rsx::framebuffer_creation_context::context_clear_depth;

init_buffers(rsx::framebuffer_creation_context{ctx}, true);
clear_surface(arg);
}

return true;
}
case NV4097_CLEAR_ZCULL_SURFACE:
{
// NOP
// Clearing zcull memory does not modify depth/stencil buffers 'bound' to the zcull region
return true;
}
case NV4097_TEXTURE_READ_SEMAPHORE_RELEASE:
{
// Texture barrier, seemingly not very useful
return true;
}
case NV4097_BACK_END_WRITE_SEMAPHORE_RELEASE:
{
//flush_draw_buffers = true;
return true;
}
}

return false;
}

bool GLGSRender::load_program()
{
if (m_graphics_state & rsx::pipeline_state::invalidate_pipeline_bits)
Expand Down
3 changes: 1 addition & 2 deletions rpcs3/Emu/RSX/GL/GLGSRender.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ class GLGSRender : public GSRender, public ::rsx::reports::ZCULL_control
gl::vertex_upload_info set_vertex_buffer();
rsx::vertex_input_layout m_vertex_layout = {};

void clear_surface(u32 arg);
void init_buffers(rsx::framebuffer_creation_context context, bool skip_reading = false);

bool load_program();
Expand All @@ -162,12 +161,12 @@ class GLGSRender : public GSRender, public ::rsx::reports::ZCULL_control
void discard_occlusion_query(rsx::reports::occlusion_query_info* query) override;

protected:
void clear_surface(u32 arg) override;
void begin() override;
void end() override;

void on_init_thread() override;
void on_exit() override;
bool do_method(u32 cmd, u32 arg) override;
void flip(const rsx::display_flip_info_t& info) override;

void do_local_task(rsx::FIFO_state state) override;
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/RSX/GL/GLOverlays.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ namespace gl
glBindVertexArray(old_vao);
}

virtual void run(const areau& region, GLuint target_texture, bool depth_target, bool use_blending = false)
void run(const areau& region, GLuint target_texture, bool depth_target, bool use_blending = false)
{
if (!compiled)
{
Expand Down
5 changes: 0 additions & 5 deletions rpcs3/Emu/RSX/Null/NullGSRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ NullGSRender::NullGSRender() : GSRender()
{
}

bool NullGSRender::do_method(u32 cmd, u32 value)
{
return false;
}

void NullGSRender::end()
{
rsx::method_registers.current_draw_clause.end();
Expand Down
1 change: 0 additions & 1 deletion rpcs3/Emu/RSX/Null/NullGSRender.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ class NullGSRender : public GSRender
NullGSRender();

private:
bool do_method(u32 cmd, u32 value) final;
void end() override;
};
12 changes: 12 additions & 0 deletions rpcs3/Emu/RSX/RSXOffload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ namespace rsx
static_cast<rsx::primitive_type>(m_current_job->aux_param0),
m_current_job->length);
break;
case callback:
rsx::get_current_renderer()->renderctl(m_current_job->aux_param0, m_current_job->src);
break;
default:
ASSUME(0);
fmt::throw_exception("Unreachable" HERE);
Expand Down Expand Up @@ -119,6 +122,15 @@ namespace rsx
}
}

// Backend callback
void dma_manager::backend_ctrl(u32 request_code, void* args)
{
verify(HERE), g_cfg.video.multithreaded_rsx;

++m_enqueued_count;
m_work_queue.push(request_code, args);
}

// Synchronization
bool dma_manager::is_current_thread() const
{
Expand Down
Loading

0 comments on commit 2033cc9

Please sign in to comment.