mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-03-11 09:10:32 +01:00
gallium: Switch TIMESTAMP_RAW back to callback
The original MR switched to use a float raw_timestamp_period to scale the raw timestamp outside of the gallium driver. This better matched how vulkan works. But unlike vulkan, gallium has timestamp related queries/APIs that return already scaled time, resulting in small errors if the way the scaling is done differs between driver scaling and frontend scaling. The important thing is that any error introduced by scaling must be the same error across APIs. (In particular, a f64 value cannot preciesly represent an arbitrary u64 value. OTOH the driver's scaling could be simply multiply be an integer. But differing precision errors of the two approachs causes problems when comparing between timestamps that are converted in different ways.) In some, but not all, cases this could be addressed by changing the driver to use the same scaling function, but this is not always possible (if, for ex, the scaling is done on the GPU CP). So switch back to the original approach from !39995, using a pscreen->convert_timestamp() callback, to put the control back in the hands of the driver. Signed-off-by: Rob Clark <rob.clark@oss.qualcomm.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40051>
This commit is contained in:
parent
c768797ab3
commit
7dc6fbd5c5
4 changed files with 20 additions and 15 deletions
|
|
@ -468,10 +468,9 @@ The result is an unsigned 64-bit integer.
|
|||
``PIPE_QUERY_TIMESTAMP_RAW`` returns a device/driver timestamp, recorded
|
||||
after all commands issued prior to ``end_query`` have been processed.
|
||||
This query does not require a call to ``begin_query``.
|
||||
The result is an unsigned 64-bit integer. ``pipe_caps.raw_timestamp_period``
|
||||
should be set by the driver to provide the scaling factor the raw timestamp
|
||||
is multiplied by to get nanoseconds.
|
||||
|
||||
The result is an unsigned 64-bit integer. ``pipe_screen::convert_timestamp()``
|
||||
should be implemented, to covert the raw timestamp to nanoseconds, if
|
||||
this query type is supported.
|
||||
``PIPE_QUERY_TIMESTAMP_DISJOINT`` can be used to check the
|
||||
internal timer resolution and whether the timestamp counter has become
|
||||
unreliable due to things like throttling etc. - only if this is FALSE
|
||||
|
|
|
|||
|
|
@ -132,6 +132,12 @@ fd_screen_get_timestamp(struct pipe_screen *pscreen)
|
|||
}
|
||||
}
|
||||
|
||||
static uint64_t
|
||||
fd_screen_convert_timestamp(struct pipe_screen *pscreen, uint64_t raw_timestamp)
|
||||
{
|
||||
return ticks_to_ns(raw_timestamp);
|
||||
}
|
||||
|
||||
static void
|
||||
fd_screen_destroy(struct pipe_screen *pscreen)
|
||||
{
|
||||
|
|
@ -682,8 +688,6 @@ fd_init_screen_caps(struct fd_screen *screen)
|
|||
|
||||
if (is_a6xx(screen)) {
|
||||
caps->shader_clock = true;
|
||||
/* PIPE_QUERY_TIMESTAMP_RAW: 19.2MHz RBBM always-on timer */
|
||||
caps->raw_timestamp_period = 1000000000.0 / 19200000.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1074,6 +1078,9 @@ fd_screen_create(int fd,
|
|||
|
||||
pscreen->get_timestamp = fd_screen_get_timestamp;
|
||||
|
||||
if (is_a6xx(screen))
|
||||
pscreen->convert_timestamp = fd_screen_convert_timestamp;
|
||||
|
||||
pscreen->fence_reference = _fd_fence_ref;
|
||||
pscreen->fence_finish = fd_pipe_fence_finish;
|
||||
pscreen->fence_get_fd = fd_pipe_fence_get_fd;
|
||||
|
|
|
|||
|
|
@ -1169,15 +1169,6 @@ struct pipe_caps {
|
|||
float max_conservative_raster_dilate;
|
||||
float conservative_raster_dilate_granularity;
|
||||
|
||||
/**
|
||||
* If the driver supports PIPE_QUERY_TIMESTAMP_RAW this should
|
||||
* be set to the scaling factor to multiply the raw timestamp
|
||||
* by to get nanoseconds.
|
||||
*
|
||||
* Should be zero if the driver does not implement the query.
|
||||
*/
|
||||
float raw_timestamp_period;
|
||||
|
||||
struct pipe_mesh_caps mesh;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -164,6 +164,14 @@ struct pipe_screen {
|
|||
*/
|
||||
uint64_t (*get_timestamp)(struct pipe_screen *);
|
||||
|
||||
/**
|
||||
* If the driver supports PIPE_QUERY_TIMESTAMP_RAW, this function
|
||||
* must be implemented to convert the drivers raw timestamp to ns.
|
||||
* If the driver does not support PIPE_QUERY_TIMESTAMP_RAW, it should
|
||||
* not implement this function.
|
||||
*/
|
||||
uint64_t (*convert_timestamp)(struct pipe_screen *, uint64_t raw_timestamp);
|
||||
|
||||
/**
|
||||
* Return an equivalent canonical format which has the same component sizes
|
||||
* and swizzles as the original, and it is supported by the driver. Gallium
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue