mirror of https://github.com/RPCS3/rpcs3.git
Use u64 for system_time_t, as s64 doesn't make much sense in a microsecond context.
This commit is contained in:
parent
ccb7528a59
commit
6b30cdac09
|
@ -147,7 +147,7 @@ void camera_context::save(utils::serial& ar)
|
||||||
|
|
||||||
GET_OR_USE_SERIALIZATION_VERSION(ar.is_writing(), cellCamera);
|
GET_OR_USE_SERIALIZATION_VERSION(ar.is_writing(), cellCamera);
|
||||||
|
|
||||||
ar(notify_data_map, start_timestamp, read_mode, is_streaming, is_attached, is_open, info, attr, frame_num);
|
ar(notify_data_map, start_timestamp_us, read_mode, is_streaming, is_attached, is_open, info, attr, frame_num);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool check_dev_num(s32 dev_num)
|
static bool check_dev_num(s32 dev_num)
|
||||||
|
@ -1268,7 +1268,7 @@ error_code cellCameraStart(s32 dev_num)
|
||||||
|
|
||||||
// TODO: Yet another CELL_CAMERA_ERROR_TIMEOUT
|
// TODO: Yet another CELL_CAMERA_ERROR_TIMEOUT
|
||||||
|
|
||||||
g_camera.start_timestamp = get_guest_system_time();
|
g_camera.start_timestamp_us = get_guest_system_time();
|
||||||
g_camera.is_streaming = true;
|
g_camera.is_streaming = true;
|
||||||
|
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
|
@ -1385,18 +1385,18 @@ error_code cellCameraReadEx(s32 dev_num, vm::ptr<CellCameraReadEx> read)
|
||||||
|
|
||||||
if (has_new_frame)
|
if (has_new_frame)
|
||||||
{
|
{
|
||||||
g_camera.frame_timestamp = ::narrow<u32>(get_guest_system_time() - g_camera.start_timestamp);
|
g_camera.frame_timestamp_us = get_guest_system_time() - g_camera.start_timestamp_us;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (read) // NULL returns CELL_OK
|
if (read) // NULL returns CELL_OK
|
||||||
{
|
{
|
||||||
read->timestamp = g_camera.frame_timestamp;
|
read->timestamp = g_camera.frame_timestamp_us;
|
||||||
read->frame = g_camera.frame_num;
|
read->frame = g_camera.frame_num;
|
||||||
read->bytesread = g_camera.bytes_read;
|
read->bytesread = g_camera.bytes_read;
|
||||||
|
|
||||||
auto& shared_data = g_fxo->get<gem_camera_shared>();
|
auto& shared_data = g_fxo->get<gem_camera_shared>();
|
||||||
|
|
||||||
shared_data.frame_timestamp.store(read->timestamp);
|
shared_data.frame_timestamp_us.store(read->timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
|
@ -1672,7 +1672,7 @@ void camera_context::operator()()
|
||||||
const u64 camera_id = 0;
|
const u64 camera_id = 0;
|
||||||
|
|
||||||
data2 = image_data_size << 32 | buffer_number << 16 | camera_id;
|
data2 = image_data_size << 32 | buffer_number << 16 | camera_id;
|
||||||
data3 = get_guest_system_time() - start_timestamp; // timestamp
|
data3 = get_guest_system_time() - start_timestamp_us; // timestamp
|
||||||
}
|
}
|
||||||
else // CELL_CAMERA_READ_FUNCCALL, also default
|
else // CELL_CAMERA_READ_FUNCCALL, also default
|
||||||
{
|
{
|
||||||
|
@ -1801,7 +1801,7 @@ void camera_context::reset_state()
|
||||||
pbuf_locked[0] = false;
|
pbuf_locked[0] = false;
|
||||||
pbuf_locked[1] = false;
|
pbuf_locked[1] = false;
|
||||||
has_new_frame = false;
|
has_new_frame = false;
|
||||||
frame_timestamp = 0;
|
frame_timestamp_us = 0;
|
||||||
bytes_read = 0;
|
bytes_read = 0;
|
||||||
|
|
||||||
if (info.buffer)
|
if (info.buffer)
|
||||||
|
|
|
@ -384,7 +384,7 @@ struct CellCameraReadEx
|
||||||
be_t<s32> version;
|
be_t<s32> version;
|
||||||
be_t<u32> frame;
|
be_t<u32> frame;
|
||||||
be_t<u32> bytesread;
|
be_t<u32> bytesread;
|
||||||
be_t<s64> timestamp;
|
be_t<u64> timestamp; // system_time_t (microseconds)
|
||||||
vm::bptr<u8> pbuf;
|
vm::bptr<u8> pbuf;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -422,7 +422,7 @@ public:
|
||||||
|
|
||||||
shared_mutex mutex;
|
shared_mutex mutex;
|
||||||
shared_mutex mutex_notify_data_map;
|
shared_mutex mutex_notify_data_map;
|
||||||
u64 start_timestamp = 0;
|
u64 start_timestamp_us = 0;
|
||||||
|
|
||||||
atomic_t<u8> read_mode{CELL_CAMERA_READ_FUNCCALL};
|
atomic_t<u8> read_mode{CELL_CAMERA_READ_FUNCCALL};
|
||||||
atomic_t<bool> is_streaming{false};
|
atomic_t<bool> is_streaming{false};
|
||||||
|
@ -444,7 +444,7 @@ public:
|
||||||
attr_t attr[500]{};
|
attr_t attr[500]{};
|
||||||
atomic_t<bool> has_new_frame = false;
|
atomic_t<bool> has_new_frame = false;
|
||||||
atomic_t<u32> frame_num = 0;
|
atomic_t<u32> frame_num = 0;
|
||||||
atomic_t<u32> frame_timestamp = 0;
|
atomic_t<u64> frame_timestamp_us = 0;
|
||||||
atomic_t<u32> bytes_read = 0;
|
atomic_t<u32> bytes_read = 0;
|
||||||
|
|
||||||
atomic_t<u8> init = 0;
|
atomic_t<u8> init = 0;
|
||||||
|
@ -471,7 +471,7 @@ using camera_thread = named_thread<camera_context>;
|
||||||
/// Shared data between cellGem and cellCamera
|
/// Shared data between cellGem and cellCamera
|
||||||
struct gem_camera_shared
|
struct gem_camera_shared
|
||||||
{
|
{
|
||||||
atomic_t<s64> frame_timestamp{}; // latest read timestamp from cellCamera (cellCameraRead(Ex))
|
atomic_t<u64> frame_timestamp_us{}; // latest read timestamp from cellCamera (cellCameraRead(Ex))
|
||||||
atomic_t<s32> width{640};
|
atomic_t<s32> width{640};
|
||||||
atomic_t<s32> height{480};
|
atomic_t<s32> height{480};
|
||||||
atomic_t<s32> size{0};
|
atomic_t<s32> size{0};
|
||||||
|
|
|
@ -215,7 +215,7 @@ public:
|
||||||
|
|
||||||
shared_mutex mtx;
|
shared_mutex mtx;
|
||||||
|
|
||||||
u64 start_timestamp = 0;
|
u64 start_timestamp_us = 0;
|
||||||
|
|
||||||
// helper functions
|
// helper functions
|
||||||
bool is_controller_ready(u32 gem_num) const
|
bool is_controller_ready(u32 gem_num) const
|
||||||
|
@ -299,10 +299,20 @@ public:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GET_OR_USE_SERIALIZATION_VERSION(ar.is_writing(), cellGem);
|
[[maybe_unused]] const s32 version = GET_OR_USE_SERIALIZATION_VERSION(ar.is_writing(), cellGem);
|
||||||
|
|
||||||
ar(attribute, vc_attribute, status_flags, enable_pitch_correction, inertial_counter, controllers
|
ar(attribute, vc_attribute, status_flags, enable_pitch_correction, inertial_counter, controllers
|
||||||
, connected_controllers, update_started, camera_frame, memory_ptr, start_timestamp);
|
, connected_controllers, update_started, camera_frame, memory_ptr);
|
||||||
|
|
||||||
|
if (version == 1 && !ar.is_writing())
|
||||||
|
{
|
||||||
|
u32 ts = ar;
|
||||||
|
start_timestamp_us = ts;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ar(start_timestamp_us);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gem_config_data(utils::serial& ar)
|
gem_config_data(utils::serial& ar)
|
||||||
|
@ -1328,7 +1338,7 @@ error_code cellGemGetImageState(u32 gem_num, vm::ptr<CellGemImageState> gem_imag
|
||||||
if (g_cfg.io.move != move_handler::null)
|
if (g_cfg.io.move != move_handler::null)
|
||||||
{
|
{
|
||||||
auto& shared_data = g_fxo->get<gem_camera_shared>();
|
auto& shared_data = g_fxo->get<gem_camera_shared>();
|
||||||
gem_image_state->frame_timestamp = shared_data.frame_timestamp.load();
|
gem_image_state->frame_timestamp = shared_data.frame_timestamp_us.load();
|
||||||
gem_image_state->timestamp = gem_image_state->frame_timestamp + 10;
|
gem_image_state->timestamp = gem_image_state->frame_timestamp + 10;
|
||||||
gem_image_state->r = gem.controllers[gem_num].radius; // Radius in camera pixels
|
gem_image_state->r = gem.controllers[gem_num].radius; // Radius in camera pixels
|
||||||
gem_image_state->distance = gem.controllers[gem_num].distance; // 1.5 meters away from camera
|
gem_image_state->distance = gem.controllers[gem_num].distance; // 1.5 meters away from camera
|
||||||
|
@ -1385,7 +1395,7 @@ error_code cellGemGetInertialState(u32 gem_num, u32 state_flag, u64 timestamp, v
|
||||||
{
|
{
|
||||||
ds3_input_to_ext(gem_num, gem.controllers[gem_num], inertial_state->ext);
|
ds3_input_to_ext(gem_num, gem.controllers[gem_num], inertial_state->ext);
|
||||||
|
|
||||||
inertial_state->timestamp = (get_guest_system_time() - gem.start_timestamp);
|
inertial_state->timestamp = (get_guest_system_time() - gem.start_timestamp_us);
|
||||||
inertial_state->counter = gem.inertial_counter++;
|
inertial_state->counter = gem.inertial_counter++;
|
||||||
inertial_state->accelerometer[0] = 10; // Current gravity in m/s²
|
inertial_state->accelerometer[0] = 10; // Current gravity in m/s²
|
||||||
|
|
||||||
|
@ -1561,7 +1571,7 @@ error_code cellGemGetState(u32 gem_num, u32 flag, u64 time_parameter, vm::ptr<Ce
|
||||||
tracking_flags |= CELL_GEM_TRACKING_FLAG_POSITION_TRACKED;
|
tracking_flags |= CELL_GEM_TRACKING_FLAG_POSITION_TRACKED;
|
||||||
|
|
||||||
gem_state->tracking_flags = tracking_flags;
|
gem_state->tracking_flags = tracking_flags;
|
||||||
gem_state->timestamp = (get_guest_system_time() - gem.start_timestamp);
|
gem_state->timestamp = (get_guest_system_time() - gem.start_timestamp_us);
|
||||||
gem_state->camera_pitch_angle = 0.f;
|
gem_state->camera_pitch_angle = 0.f;
|
||||||
gem_state->quat[3] = 1.f;
|
gem_state->quat[3] = 1.f;
|
||||||
|
|
||||||
|
@ -1763,7 +1773,7 @@ error_code cellGemInit(ppu_thread& ppu, vm::cptr<CellGemAttribute> attribute)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: is this correct?
|
// TODO: is this correct?
|
||||||
gem.start_timestamp = get_guest_system_time();
|
gem.start_timestamp_us = get_guest_system_time();
|
||||||
|
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
@ -1939,7 +1949,7 @@ error_code cellGemReset(u32 gem_num)
|
||||||
gem.reset_controller(gem_num);
|
gem.reset_controller(gem_num);
|
||||||
|
|
||||||
// TODO: is this correct?
|
// TODO: is this correct?
|
||||||
gem.start_timestamp = get_guest_system_time();
|
gem.start_timestamp_us = get_guest_system_time();
|
||||||
|
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,8 +200,8 @@ struct CellGemExtPortData
|
||||||
|
|
||||||
struct CellGemImageState
|
struct CellGemImageState
|
||||||
{
|
{
|
||||||
be_t<u64> frame_timestamp; // time the frame was captured by libCamera (usecs)
|
be_t<u64> frame_timestamp; // time the frame was captured by libCamera. system_time_t (usecs)
|
||||||
be_t<u64> timestamp; // time processing of the frame was finished (usecs)
|
be_t<u64> timestamp; // time processing of the frame was finished. system_time_t (usecs)
|
||||||
be_t<f32> u; // horizontal screen position in pixels
|
be_t<f32> u; // horizontal screen position in pixels
|
||||||
be_t<f32> v; // vertical screen position in pixels
|
be_t<f32> v; // vertical screen position in pixels
|
||||||
be_t<f32> r; // size of sphere on screen in pixels
|
be_t<f32> r; // size of sphere on screen in pixels
|
||||||
|
@ -226,7 +226,7 @@ struct CellGemInertialState
|
||||||
be_t<f32> gyro_bias[4]; // gyro bias (radians/s)
|
be_t<f32> gyro_bias[4]; // gyro bias (radians/s)
|
||||||
CellGemPadData pad;
|
CellGemPadData pad;
|
||||||
CellGemExtPortData ext;
|
CellGemExtPortData ext;
|
||||||
be_t<u64> timestamp;
|
be_t<u64> timestamp; // system_time_t (microseconds)
|
||||||
be_t<s32> counter;
|
be_t<s32> counter;
|
||||||
be_t<f32> temperature;
|
be_t<f32> temperature;
|
||||||
};
|
};
|
||||||
|
@ -256,7 +256,7 @@ struct CellGemState
|
||||||
be_t<f32> handle_accel[4]; // acceleration of controller handle (mm/s²)
|
be_t<f32> handle_accel[4]; // acceleration of controller handle (mm/s²)
|
||||||
CellGemPadData pad;
|
CellGemPadData pad;
|
||||||
CellGemExtPortData ext;
|
CellGemExtPortData ext;
|
||||||
be_t<u64> timestamp;
|
be_t<u64> timestamp; // system_time_t (microseconds)
|
||||||
be_t<f32> temperature;
|
be_t<f32> temperature;
|
||||||
be_t<f32> camera_pitch_angle;
|
be_t<f32> camera_pitch_angle;
|
||||||
be_t<u32> tracking_flags;
|
be_t<u32> tracking_flags;
|
||||||
|
|
|
@ -1351,7 +1351,7 @@ error_code cellRtcSetCurrentTick(vm::cptr<CellRtcTick> pTick)
|
||||||
|
|
||||||
// TODO syscall not implemented
|
// TODO syscall not implemented
|
||||||
/*
|
/*
|
||||||
u32 tmp2 = sys_time_get_system_time(tmp / cellRtcGetTickResolution(), (tmp % cellRtcGetTickResolution()) * 1000);
|
u64 tmp2 = sys_time_get_system_time(tmp / cellRtcGetTickResolution(), (tmp % cellRtcGetTickResolution()) * 1000);
|
||||||
|
|
||||||
return (tmp2 & (tmp2 | tmp2 - 1) >> 0x1f);
|
return (tmp2 & (tmp2 | tmp2 - 1) >> 0x1f);
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -20,7 +20,7 @@ struct np_in_addr
|
||||||
|
|
||||||
using sys_memory_container_t = u32;
|
using sys_memory_container_t = u32;
|
||||||
|
|
||||||
using system_time_t = s64;
|
using system_time_t = u64; // s64 in documentation. But since this is in microseconds, it doesn't seem to make much sense.
|
||||||
using second_t = u32;
|
using second_t = u32;
|
||||||
using usecond_t = u64;
|
using usecond_t = u64;
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ vm::gvar<vm::ptr<void()>> g_ppu_atexitspawn;
|
||||||
vm::gvar<vm::ptr<void()>> g_ppu_at_Exitspawn;
|
vm::gvar<vm::ptr<void()>> g_ppu_at_Exitspawn;
|
||||||
extern vm::gvar<u32> g_ppu_exit_mutex;
|
extern vm::gvar<u32> g_ppu_exit_mutex;
|
||||||
|
|
||||||
s64 sys_time_get_system_time()
|
u64 sys_time_get_system_time()
|
||||||
{
|
{
|
||||||
sysPrxForUser.trace("sys_time_get_system_time()");
|
sysPrxForUser.trace("sys_time_get_system_time()");
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ enum : u32
|
||||||
|
|
||||||
struct sys_timer_information_t
|
struct sys_timer_information_t
|
||||||
{
|
{
|
||||||
be_t<s64> next_expire;
|
be_t<u64> next_expire; // system_time_t
|
||||||
be_t<u64> period;
|
be_t<u64> period;
|
||||||
be_t<u32> timer_state;
|
be_t<u32> timer_state;
|
||||||
be_t<u32> pad;
|
be_t<u32> pad;
|
||||||
|
|
|
@ -65,7 +65,7 @@ SERIALIZATION_VER(sceNp, 11)
|
||||||
SERIALIZATION_VER(cellVdec, 12, 1)
|
SERIALIZATION_VER(cellVdec, 12, 1)
|
||||||
SERIALIZATION_VER(cellAudio, 13, 1)
|
SERIALIZATION_VER(cellAudio, 13, 1)
|
||||||
SERIALIZATION_VER(cellCamera, 14, 1)
|
SERIALIZATION_VER(cellCamera, 14, 1)
|
||||||
SERIALIZATION_VER(cellGem, 15, 1)
|
SERIALIZATION_VER(cellGem, 15, 1, 2/*frame_timestamp u32->u64*/)
|
||||||
SERIALIZATION_VER(sceNpTrophy, 16, 1)
|
SERIALIZATION_VER(sceNpTrophy, 16, 1)
|
||||||
SERIALIZATION_VER(cellMusic, 17, 1)
|
SERIALIZATION_VER(cellMusic, 17, 1)
|
||||||
SERIALIZATION_VER(cellVoice, 18, 1)
|
SERIALIZATION_VER(cellVoice, 18, 1)
|
||||||
|
|
Loading…
Reference in New Issue