Commit f52ead4b authored by Michael Müller's avatar Michael Müller Committed by Alexandre Julliard

wined3d: Implement WINED3D_QUERY_TYPE_PIPELINE_STATISTICS.

parent 1b4e6273
......@@ -3824,7 +3824,7 @@ static void test_create_query(void)
{D3D10_QUERY_OCCLUSION, FALSE, FALSE},
{D3D10_QUERY_TIMESTAMP, FALSE, FALSE},
{D3D10_QUERY_TIMESTAMP_DISJOINT, FALSE, FALSE},
{D3D10_QUERY_PIPELINE_STATISTICS, FALSE, TRUE},
{D3D10_QUERY_PIPELINE_STATISTICS, FALSE, FALSE},
{D3D10_QUERY_OCCLUSION_PREDICATE, TRUE, FALSE},
{D3D10_QUERY_SO_STATISTICS, FALSE, TRUE},
{D3D10_QUERY_SO_OVERFLOW_PREDICATE, TRUE, TRUE},
......
......@@ -4598,7 +4598,7 @@ static void test_create_query(void)
{D3D11_QUERY_OCCLUSION, D3D_FEATURE_LEVEL_10_0, FALSE, FALSE, FALSE},
{D3D11_QUERY_TIMESTAMP, D3D_FEATURE_LEVEL_10_0, FALSE, FALSE, FALSE},
{D3D11_QUERY_TIMESTAMP_DISJOINT, D3D_FEATURE_LEVEL_10_0, FALSE, FALSE, FALSE},
{D3D11_QUERY_PIPELINE_STATISTICS, D3D_FEATURE_LEVEL_10_0, FALSE, FALSE, TRUE},
{D3D11_QUERY_PIPELINE_STATISTICS, D3D_FEATURE_LEVEL_10_0, FALSE, FALSE, FALSE},
{D3D11_QUERY_OCCLUSION_PREDICATE, D3D_FEATURE_LEVEL_10_0, TRUE, TRUE, FALSE},
{D3D11_QUERY_SO_STATISTICS, D3D_FEATURE_LEVEL_10_0, FALSE, FALSE, TRUE},
{D3D11_QUERY_SO_OVERFLOW_PREDICATE, D3D_FEATURE_LEVEL_10_0, TRUE, TRUE, TRUE},
......
......@@ -933,6 +933,43 @@ void context_free_so_statistics_query(struct wined3d_so_statistics_query *query)
context->free_so_statistics_queries[context->free_so_statistics_query_count++] = query->u;
}
void context_alloc_pipeline_statistics_query(struct wined3d_context *context,
struct wined3d_pipeline_statistics_query *query)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
if (context->free_pipeline_statistics_query_count)
{
query->u = context->free_pipeline_statistics_queries[--context->free_pipeline_statistics_query_count];
}
else
{
GL_EXTCALL(glGenQueries(ARRAY_SIZE(query->u.id), query->u.id));
checkGLcall("glGenQueries");
}
query->context = context;
list_add_head(&context->pipeline_statistics_queries, &query->entry);
}
void context_free_pipeline_statistics_query(struct wined3d_pipeline_statistics_query *query)
{
struct wined3d_context *context = query->context;
list_remove(&query->entry);
query->context = NULL;
if (!wined3d_array_reserve((void **)&context->free_pipeline_statistics_queries,
&context->free_pipeline_statistics_query_size, context->free_pipeline_statistics_query_count + 1,
sizeof(*context->free_pipeline_statistics_queries)))
{
ERR("Failed to grow free list, leaking GL queries in context %p.\n", context);
return;
}
context->free_pipeline_statistics_queries[context->free_pipeline_statistics_query_count++] = query->u;
}
typedef void (context_fbo_entry_func_t)(struct wined3d_context *context, struct fbo_entry *entry);
static void context_enum_fbo_entries(const struct wined3d_device *device,
......@@ -1223,6 +1260,7 @@ static void context_update_window(struct wined3d_context *context)
static void context_destroy_gl_resources(struct wined3d_context *context)
{
struct wined3d_pipeline_statistics_query *pipeline_statistics_query;
const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_so_statistics_query *so_statistics_query;
struct wined3d_timestamp_query *timestamp_query;
......@@ -1249,6 +1287,14 @@ static void context_destroy_gl_resources(struct wined3d_context *context)
so_statistics_query->context = NULL;
}
LIST_FOR_EACH_ENTRY(pipeline_statistics_query, &context->pipeline_statistics_queries,
struct wined3d_pipeline_statistics_query, entry)
{
if (context->valid)
GL_EXTCALL(glDeleteQueries(ARRAY_SIZE(pipeline_statistics_query->u.id), pipeline_statistics_query->u.id));
pipeline_statistics_query->context = NULL;
}
LIST_FOR_EACH_ENTRY(timestamp_query, &context->timestamp_queries, struct wined3d_timestamp_query, entry)
{
if (context->valid)
......@@ -1305,6 +1351,15 @@ static void context_destroy_gl_resources(struct wined3d_context *context)
}
}
if (gl_info->supported[ARB_PIPELINE_STATISTICS_QUERY])
{
for (i = 0; i < context->free_pipeline_statistics_query_count; ++i)
{
union wined3d_gl_pipeline_statistics_query *q = &context->free_pipeline_statistics_queries[i];
GL_EXTCALL(glDeleteQueries(ARRAY_SIZE(q->id), q->id));
}
}
if (gl_info->supported[ARB_TIMER_QUERY])
GL_EXTCALL(glDeleteQueries(context->free_timestamp_query_count, context->free_timestamp_queries));
......@@ -1337,6 +1392,7 @@ static void context_destroy_gl_resources(struct wined3d_context *context)
}
HeapFree(GetProcessHeap(), 0, context->free_so_statistics_queries);
HeapFree(GetProcessHeap(), 0, context->free_pipeline_statistics_queries);
HeapFree(GetProcessHeap(), 0, context->free_timestamp_queries);
HeapFree(GetProcessHeap(), 0, context->free_occlusion_queries);
HeapFree(GetProcessHeap(), 0, context->free_event_queries);
......@@ -1801,6 +1857,8 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
list_init(&ret->so_statistics_queries);
list_init(&ret->pipeline_statistics_queries);
list_init(&ret->fbo_list);
list_init(&ret->fbo_destroy_list);
......
......@@ -144,6 +144,7 @@ static const struct wined3d_extension_map gl_extension_map[] =
{"GL_ARB_multisample", ARB_MULTISAMPLE },
{"GL_ARB_multitexture", ARB_MULTITEXTURE },
{"GL_ARB_occlusion_query", ARB_OCCLUSION_QUERY },
{"GL_ARB_pipeline_statistics_query", ARB_PIPELINE_STATISTICS_QUERY },
{"GL_ARB_pixel_buffer_object", ARB_PIXEL_BUFFER_OBJECT },
{"GL_ARB_point_parameters", ARB_POINT_PARAMETERS },
{"GL_ARB_point_sprite", ARB_POINT_SPRITE },
......
......@@ -78,6 +78,7 @@ enum wined3d_gl_extension
ARB_MULTISAMPLE,
ARB_MULTITEXTURE,
ARB_OCCLUSION_QUERY,
ARB_PIPELINE_STATISTICS_QUERY,
ARB_PIXEL_BUFFER_OBJECT,
ARB_POINT_PARAMETERS,
ARB_POINT_SPRITE,
......
......@@ -1721,6 +1721,40 @@ void context_alloc_so_statistics_query(struct wined3d_context *context,
struct wined3d_so_statistics_query *query) DECLSPEC_HIDDEN;
void context_free_so_statistics_query(struct wined3d_so_statistics_query *query) DECLSPEC_HIDDEN;
union wined3d_gl_pipeline_statistics_query
{
GLuint id[11];
struct
{
GLuint vertices;
GLuint primitives;
GLuint vertex_shader;
GLuint tess_control_shader;
GLuint tess_eval_shader;
GLuint geometry_shader;
GLuint geometry_primitives;
GLuint fragment_shader;
GLuint compute_shader;
GLuint clipping_input;
GLuint clipping_output;
} query;
};
struct wined3d_pipeline_statistics_query
{
struct wined3d_query query;
struct list entry;
union wined3d_gl_pipeline_statistics_query u;
struct wined3d_context *context;
struct wined3d_query_data_pipeline_statistics statistics;
BOOL started;
};
void context_alloc_pipeline_statistics_query(struct wined3d_context *context,
struct wined3d_pipeline_statistics_query *query) DECLSPEC_HIDDEN;
void context_free_pipeline_statistics_query(struct wined3d_pipeline_statistics_query *query) DECLSPEC_HIDDEN;
struct wined3d_gl_view
{
GLenum target;
......@@ -1857,6 +1891,11 @@ struct wined3d_context
unsigned int free_so_statistics_query_count;
struct list so_statistics_queries;
union wined3d_gl_pipeline_statistics_query *free_pipeline_statistics_queries;
SIZE_T free_pipeline_statistics_query_size;
unsigned int free_pipeline_statistics_query_count;
struct list pipeline_statistics_queries;
struct wined3d_stream_info stream_info;
/* Fences for GL_APPLE_flush_buffer_range */
......
......@@ -726,6 +726,21 @@ struct wined3d_query_data_so_statistics
UINT64 primitives_generated;
};
struct wined3d_query_data_pipeline_statistics
{
UINT64 vertices_submitted;
UINT64 primitives_submitted;
UINT64 vs_invocations;
UINT64 gs_invocations;
UINT64 gs_primitives;
UINT64 clipping_input_primitives;
UINT64 clipping_output_primitives;
UINT64 ps_invocations;
UINT64 hs_invocations;
UINT64 ds_invocations;
UINT64 cs_invocations;
};
#define WINED3DISSUE_BEGIN (1u << 1)
#define WINED3DISSUE_END (1u << 0)
#define WINED3DGETDATA_FLUSH (1u << 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment