Move vblank to 'custom' package_id, move fps limit sleep, fix dx12 0 size fb crash

This commit is contained in:
Jake 2017-07-10 01:00:10 -05:00 committed by Zangetsu38
parent cfb573694c
commit c5828faf0f
4 changed files with 40 additions and 29 deletions

View file

@ -54,7 +54,7 @@ struct RsxDriverInfo {
be_t<u32> unk14; // 0x12E0
be_t<u32> unk15; // 0x12E4
be_t<u32> unk16; // 0x12E8
be_t<u32> unk17; // 0x12F0
be_t<u32> unk17; // 0x12F0
be_t<u32> lastError; // 0x12F4 error param for cellGcmSetGraphicsHandler
// todo: theres more to this
};
@ -299,7 +299,7 @@ s32 sys_rsx_context_iounmap(u32 context_id, u32 io_addr, u32 a3, u32 size)
*/
s32 sys_rsx_context_attribute(s32 context_id, u32 package_id, u64 a3, u64 a4, u64 a5, u64 a6)
{
if (package_id != 0x101)
if (package_id != 0xFED)
sys_rsx.todo("sys_rsx_context_attribute(context_id=0x%x, package_id=0x%x, a3=0x%llx, a4=0x%llx, a5=0x%llx, a6=0x%llx)", context_id, package_id, a3, a4, a5, a6);
// hle/lle protection
@ -318,14 +318,8 @@ s32 sys_rsx_context_attribute(s32 context_id, u32 package_id, u64 a3, u64 a4, u6
case 0x100: // Display mode set
break;
case 0x101: // Display sync
// todo: this is wrong and should be 'second' vblank handler and freq
// although gcmSys seems just hardcoded at 1, so w/e
driverInfo.head[1].vBlankCount++;
driverInfo.head[1].lastSecondVTime = rsxTimeStamp();
sys_event_port_send(g_rsx_event_port, 0, (1 << 1), 0);
sys_event_port_send(g_rsx_event_port, 0, (1 << 11), 0); // second vhandler
break;
case 0x101: // Display sync set, cellGcmSetFlipMode
break;
case 0x102: // Display flip
driverInfo.head[a3].flipFlags |= 0x80000000;
@ -424,6 +418,14 @@ s32 sys_rsx_context_attribute(s32 context_id, u32 package_id, u64 a3, u64 a4, u6
case 0x603: // Framebuffer close
break;
case 0xFED: // hack: vblank command
// todo: this is wrong and should be 'second' vblank handler and freq
// although gcmSys seems just hardcoded at 1, so w/e
driverInfo.head[a3].vBlankCount++;
driverInfo.head[a3].lastSecondVTime = rsxTimeStamp();
sys_event_port_send(g_rsx_event_port, 0, (1 << 1), 0);
sys_event_port_send(g_rsx_event_port, 0, (1 << 11), 0); // second vhandler
break;
case 0xFEF: // hack: user command
// 'custom' invalid package id for now
// as i think we need custom lv1 interrupts to handle this accurately
@ -472,6 +474,9 @@ s32 sys_rsx_device_unmap(u32 dev_id)
return CELL_OK;
}
/*
* lv2 SysCall 677 (0x2A5): sys_rsx_attribute
*/
s32 sys_rsx_attribute(u32 packageId, u32 a2, u32 a3, u32 a4, u32 a5)
{
sys_rsx.todo("sys_rsx_attribute(packageId=0x%x, a2=0x%x, a3=0x%x, a4=0x%x, a5=0x%x)", packageId, a2, a3, a4, a5);

View file

@ -175,9 +175,16 @@ void D3D12GSRender::prepare_render_targets(ID3D12GraphicsCommandList *copycmdlis
rsx::method_registers.clear_color_b() / 255.f,
rsx::method_registers.clear_color_a() / 255.f,
};
u32 clip_width = rsx::method_registers.surface_clip_width();
u32 clip_height = rsx::method_registers.surface_clip_height();
if (clip_height == 0 || clip_width == 0)
return;
m_rtts.prepare_render_target(copycmdlist,
rsx::method_registers.surface_color(), rsx::method_registers.surface_depth_fmt(),
rsx::method_registers.surface_clip_width(), rsx::method_registers.surface_clip_height(),
clip_width, clip_height,
rsx::method_registers.surface_color_target(),
get_color_surface_addresses(), get_zeta_surface_address(),
m_device.Get(), clear_color, 1.f, 0);

View file

@ -403,7 +403,7 @@ namespace rsx
if (get_system_time() - start_time > vblank_count * 1000000 / 60)
{
vblank_count++;
sys_rsx_context_attribute(0x55555555, 0x101, 0, 0, 0, 0);
sys_rsx_context_attribute(0x55555555, 0xFED, 1, 0, 0, 0);
if (vblank_handler)
{
intr_thread->cmd_list

View file

@ -909,22 +909,6 @@ namespace rsx
}
Emu.Pause();
}
double limit = 0.;
switch (g_cfg.video.frame_limit)
{
case frame_limit_type::none: limit = 0.; break;
case frame_limit_type::_59_94: limit = 59.94; break;
case frame_limit_type::_50: limit = 50.; break;
case frame_limit_type::_60: limit = 60.; break;
case frame_limit_type::_30: limit = 30.; break;
case frame_limit_type::_auto: limit = rsx->fps_limit; break; // TODO
}
if (limit)
{
std::this_thread::sleep_for(std::chrono::milliseconds((s64)(1000.0 / limit - rsx->timer_sync.GetElapsedTimeInMilliSec())));
rsx->timer_sync.Start();
}
rsx->gcm_current_buffer = arg;
rsx->flip(arg);
@ -933,7 +917,6 @@ namespace rsx
//rsx->reset(); // moved to 'actual' rsx flip command
rsx->last_flip_time = get_system_time() - 1000000;
rsx->gcm_current_buffer = arg;
rsx->flip_status = CELL_GCM_DISPLAY_FLIP_STATUS_DONE;
if (rsx->flip_handler)
@ -974,6 +957,22 @@ namespace rsx
{
static void impl(thread* rsx, u32 _reg, u32 arg)
{
double limit = 0.;
switch (g_cfg.video.frame_limit)
{
case frame_limit_type::none: limit = 0.; break;
case frame_limit_type::_59_94: limit = 59.94; break;
case frame_limit_type::_50: limit = 50.; break;
case frame_limit_type::_60: limit = 60.; break;
case frame_limit_type::_30: limit = 30.; break;
case frame_limit_type::_auto: limit = rsx->fps_limit; break; // TODO
}
if (limit)
{
std::this_thread::sleep_for(std::chrono::milliseconds((s64)(1000.0 / limit - rsx->timer_sync.GetElapsedTimeInMilliSec())));
rsx->timer_sync.Start();
}
rsx->reset(); // fixes kh, so lets leave it here and see what happens
sys_rsx_context_attribute(0x55555555, 0x102, index, arg, 0, 0);
}