libobs: Add GPU timestamp query support
This change only wraps the functionality. I have rough code to exercise the the query functionality, but that part is not really clean enough to submit.
This commit is contained in:
@@ -76,6 +76,8 @@ EXPORT gs_indexbuffer_t *device_indexbuffer_create(gs_device_t *device,
|
||||
enum gs_index_type type,
|
||||
void *indices, size_t num,
|
||||
uint32_t flags);
|
||||
EXPORT gs_timer_t *device_timer_create(gs_device_t *device);
|
||||
EXPORT gs_timer_range_t *device_timer_range_create(gs_device_t *device);
|
||||
EXPORT enum gs_texture_type
|
||||
device_get_texture_type(const gs_texture_t *texture);
|
||||
EXPORT void device_load_vertexbuffer(gs_device_t *device,
|
||||
|
@@ -65,6 +65,8 @@ bool load_graphics_imports(struct gs_exports *exports, void *module,
|
||||
GRAPHICS_IMPORT(device_pixelshader_create);
|
||||
GRAPHICS_IMPORT(device_vertexbuffer_create);
|
||||
GRAPHICS_IMPORT(device_indexbuffer_create);
|
||||
GRAPHICS_IMPORT(device_timer_create);
|
||||
GRAPHICS_IMPORT(device_timer_range_create);
|
||||
GRAPHICS_IMPORT(device_get_texture_type);
|
||||
GRAPHICS_IMPORT(device_load_vertexbuffer);
|
||||
GRAPHICS_IMPORT(device_load_indexbuffer);
|
||||
@@ -153,6 +155,15 @@ bool load_graphics_imports(struct gs_exports *exports, void *module,
|
||||
GRAPHICS_IMPORT(gs_indexbuffer_get_num_indices);
|
||||
GRAPHICS_IMPORT(gs_indexbuffer_get_type);
|
||||
|
||||
GRAPHICS_IMPORT(gs_timer_destroy);
|
||||
GRAPHICS_IMPORT(gs_timer_begin);
|
||||
GRAPHICS_IMPORT(gs_timer_end);
|
||||
GRAPHICS_IMPORT(gs_timer_get_data);
|
||||
GRAPHICS_IMPORT(gs_timer_range_destroy);
|
||||
GRAPHICS_IMPORT(gs_timer_range_begin);
|
||||
GRAPHICS_IMPORT(gs_timer_range_end);
|
||||
GRAPHICS_IMPORT(gs_timer_range_get_data);
|
||||
|
||||
GRAPHICS_IMPORT(gs_shader_destroy);
|
||||
GRAPHICS_IMPORT(gs_shader_get_num_params);
|
||||
GRAPHICS_IMPORT(gs_shader_get_param_by_idx);
|
||||
|
@@ -77,6 +77,8 @@ struct gs_exports {
|
||||
void *indices,
|
||||
size_t num,
|
||||
uint32_t flags);
|
||||
gs_timer_t *(*device_timer_create)(gs_device_t *device);
|
||||
gs_timer_range_t *(*device_timer_range_create)(gs_device_t *device);
|
||||
enum gs_texture_type (*device_get_texture_type)(
|
||||
const gs_texture_t *texture);
|
||||
void (*device_load_vertexbuffer)(gs_device_t *device,
|
||||
@@ -219,6 +221,16 @@ struct gs_exports {
|
||||
enum gs_index_type (*gs_indexbuffer_get_type)(
|
||||
const gs_indexbuffer_t *indexbuffer);
|
||||
|
||||
void (*gs_timer_destroy)(gs_timer_t *timer);
|
||||
void (*gs_timer_begin)(gs_timer_t *timer);
|
||||
void (*gs_timer_end)(gs_timer_t *timer);
|
||||
bool (*gs_timer_get_data)(gs_timer_t *timer, uint64_t *ticks);
|
||||
void (*gs_timer_range_destroy)(gs_timer_range_t *range);
|
||||
bool (*gs_timer_range_begin)(gs_timer_range_t *range);
|
||||
bool (*gs_timer_range_end)(gs_timer_range_t *range);
|
||||
bool (*gs_timer_range_get_data)(gs_timer_range_t *range, bool *disjoint,
|
||||
uint64_t *frequency);
|
||||
|
||||
void (*gs_shader_destroy)(gs_shader_t *shader);
|
||||
int (*gs_shader_get_num_params)(const gs_shader_t *shader);
|
||||
gs_sparam_t *(*gs_shader_get_param_by_idx)(gs_shader_t *shader,
|
||||
|
@@ -1525,6 +1525,26 @@ gs_indexbuffer_t *gs_indexbuffer_create(enum gs_index_type type, void *indices,
|
||||
graphics->device, type, indices, num, flags);
|
||||
}
|
||||
|
||||
gs_timer_t *gs_timer_create()
|
||||
{
|
||||
graphics_t *graphics = thread_graphics;
|
||||
|
||||
if (!gs_valid("gs_timer_create"))
|
||||
return NULL;
|
||||
|
||||
return graphics->exports.device_timer_create(graphics->device);
|
||||
}
|
||||
|
||||
gs_timer_range_t *gs_timer_range_create()
|
||||
{
|
||||
graphics_t *graphics = thread_graphics;
|
||||
|
||||
if (!gs_valid("gs_timer_range_create"))
|
||||
return NULL;
|
||||
|
||||
return graphics->exports.device_timer_range_create(graphics->device);
|
||||
}
|
||||
|
||||
enum gs_texture_type gs_get_texture_type(const gs_texture_t *texture)
|
||||
{
|
||||
graphics_t *graphics = thread_graphics;
|
||||
@@ -2543,6 +2563,96 @@ enum gs_index_type gs_indexbuffer_get_type(const gs_indexbuffer_t *indexbuffer)
|
||||
return thread_graphics->exports.gs_indexbuffer_get_type(indexbuffer);
|
||||
}
|
||||
|
||||
void gs_timer_destroy(gs_timer_t *timer)
|
||||
{
|
||||
graphics_t *graphics = thread_graphics;
|
||||
|
||||
if (!gs_valid("gs_timer_destroy"))
|
||||
return;
|
||||
if (!timer)
|
||||
return;
|
||||
|
||||
graphics->exports.gs_timer_destroy(timer);
|
||||
}
|
||||
|
||||
void gs_timer_begin(gs_timer_t *timer)
|
||||
{
|
||||
graphics_t *graphics = thread_graphics;
|
||||
|
||||
if (!gs_valid("gs_timer_begin"))
|
||||
return;
|
||||
if (!timer)
|
||||
return;
|
||||
|
||||
graphics->exports.gs_timer_begin(timer);
|
||||
}
|
||||
|
||||
void gs_timer_end(gs_timer_t *timer)
|
||||
{
|
||||
graphics_t *graphics = thread_graphics;
|
||||
|
||||
if (!gs_valid("gs_timer_end"))
|
||||
return;
|
||||
if (!timer)
|
||||
return;
|
||||
|
||||
graphics->exports.gs_timer_end(timer);
|
||||
}
|
||||
|
||||
bool gs_timer_get_data(gs_timer_t *timer, uint64_t *ticks)
|
||||
{
|
||||
if (!gs_valid_p2("gs_timer_get_data", timer, ticks))
|
||||
return false;
|
||||
|
||||
return thread_graphics->exports.gs_timer_get_data(timer, ticks);
|
||||
}
|
||||
|
||||
void gs_timer_range_destroy(gs_timer_range_t *range)
|
||||
{
|
||||
graphics_t *graphics = thread_graphics;
|
||||
|
||||
if (!gs_valid("gs_timer_range_destroy"))
|
||||
return;
|
||||
if (!range)
|
||||
return;
|
||||
|
||||
graphics->exports.gs_timer_range_destroy(range);
|
||||
}
|
||||
|
||||
void gs_timer_range_begin(gs_timer_range_t *range)
|
||||
{
|
||||
graphics_t *graphics = thread_graphics;
|
||||
|
||||
if (!gs_valid("gs_timer_range_begin"))
|
||||
return;
|
||||
if (!range)
|
||||
return;
|
||||
|
||||
graphics->exports.gs_timer_range_begin(range);
|
||||
}
|
||||
|
||||
void gs_timer_range_end(gs_timer_range_t *range)
|
||||
{
|
||||
graphics_t *graphics = thread_graphics;
|
||||
|
||||
if (!gs_valid("gs_timer_range_end"))
|
||||
return;
|
||||
if (!range)
|
||||
return;
|
||||
|
||||
graphics->exports.gs_timer_range_end(range);
|
||||
}
|
||||
|
||||
bool gs_timer_range_get_data(gs_timer_range_t *range, bool *disjoint,
|
||||
uint64_t *frequency)
|
||||
{
|
||||
if (!gs_valid_p2("gs_timer_range_get_data", disjoint, frequency))
|
||||
return false;
|
||||
|
||||
return thread_graphics->exports.gs_timer_range_get_data(range, disjoint,
|
||||
frequency);
|
||||
}
|
||||
|
||||
bool gs_nv12_available(void)
|
||||
{
|
||||
if (!gs_valid("gs_nv12_available"))
|
||||
|
@@ -247,6 +247,7 @@ struct gs_index_buffer;
|
||||
struct gs_sampler_state;
|
||||
struct gs_shader;
|
||||
struct gs_swap_chain;
|
||||
struct gs_timer;
|
||||
struct gs_texrender;
|
||||
struct gs_shader_param;
|
||||
struct gs_effect;
|
||||
@@ -263,6 +264,8 @@ typedef struct gs_vertex_buffer gs_vertbuffer_t;
|
||||
typedef struct gs_index_buffer gs_indexbuffer_t;
|
||||
typedef struct gs_sampler_state gs_samplerstate_t;
|
||||
typedef struct gs_swap_chain gs_swapchain_t;
|
||||
typedef struct gs_timer gs_timer_t;
|
||||
typedef struct gs_timer_range gs_timer_range_t;
|
||||
typedef struct gs_texture_render gs_texrender_t;
|
||||
typedef struct gs_shader gs_shader_t;
|
||||
typedef struct gs_shader_param gs_sparam_t;
|
||||
@@ -633,6 +636,9 @@ EXPORT gs_indexbuffer_t *gs_indexbuffer_create(enum gs_index_type type,
|
||||
void *indices, size_t num,
|
||||
uint32_t flags);
|
||||
|
||||
EXPORT gs_timer_t *gs_timer_create();
|
||||
EXPORT gs_timer_range_t *gs_timer_range_create();
|
||||
|
||||
EXPORT enum gs_texture_type gs_get_texture_type(const gs_texture_t *texture);
|
||||
|
||||
EXPORT void gs_load_vertexbuffer(gs_vertbuffer_t *vertbuffer);
|
||||
@@ -773,6 +779,16 @@ gs_indexbuffer_get_num_indices(const gs_indexbuffer_t *indexbuffer);
|
||||
EXPORT enum gs_index_type
|
||||
gs_indexbuffer_get_type(const gs_indexbuffer_t *indexbuffer);
|
||||
|
||||
EXPORT void gs_timer_destroy(gs_timer_t *timer);
|
||||
EXPORT void gs_timer_begin(gs_timer_t *timer);
|
||||
EXPORT void gs_timer_end(gs_timer_t *timer);
|
||||
EXPORT bool gs_timer_get_data(gs_timer_t *timer, uint64_t *ticks);
|
||||
EXPORT void gs_timer_range_destroy(gs_timer_range_t *timer);
|
||||
EXPORT void gs_timer_range_begin(gs_timer_range_t *range);
|
||||
EXPORT void gs_timer_range_end(gs_timer_range_t *range);
|
||||
EXPORT bool gs_timer_range_get_data(gs_timer_range_t *range, bool *disjoint,
|
||||
uint64_t *frequency);
|
||||
|
||||
EXPORT bool gs_nv12_available(void);
|
||||
|
||||
#define GS_USE_DEBUG_MARKERS 0
|
||||
|
Reference in New Issue
Block a user