Rebase against e4c9a2ec81b8029876d588e09587db40ab65ee69.

This commit is contained in:
Sebastian Lackner
2017-06-06 10:12:28 +02:00
parent 6ca029a4f6
commit d0ac86031a
13 changed files with 26 additions and 1244 deletions

View File

@@ -1,4 +1,4 @@
From e673885709da5bb4d6e13bb9c005ef590768e198 Mon Sep 17 00:00:00 2001
From 80ad1268188358c71be2e7320e3169a7df6995d9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sat, 16 Apr 2016 18:18:54 +0200
Subject: wined3d: Add stubs for QUERY_TYPE_SO_STATISTICS and
@@ -11,12 +11,12 @@ Subject: wined3d: Add stubs for QUERY_TYPE_SO_STATISTICS and
3 files changed, 104 insertions(+), 4 deletions(-)
diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c
index 364a2abfe7f..c08004723cc 100644
index 311ffeb82ba..9958feb1c25 100644
--- a/dlls/d3d10core/tests/device.c
+++ b/dlls/d3d10core/tests/device.c
@@ -3826,8 +3826,8 @@ static void test_create_query(void)
{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},
@@ -26,12 +26,12 @@ index 364a2abfe7f..c08004723cc 100644
ULONG refcount, expected_refcount;
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index b160977caec..a56bcd91f70 100644
index a3f2c9879b4..28859f897bd 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -4600,8 +4600,8 @@ static void test_create_query(void)
{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},
@@ -41,10 +41,10 @@ index b160977caec..a56bcd91f70 100644
{D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM0, D3D_FEATURE_LEVEL_11_0, TRUE, FALSE, TRUE},
{D3D11_QUERY_SO_STATISTICS_STREAM1, D3D_FEATURE_LEVEL_11_0, FALSE, FALSE, FALSE},
diff --git a/dlls/wined3d/query.c b/dlls/wined3d/query.c
index 55871130ce0..3c7a3ae4f8a 100644
index 8445922423f..30b1d8d7a70 100644
--- a/dlls/wined3d/query.c
+++ b/dlls/wined3d/query.c
@@ -729,6 +729,34 @@ static BOOL wined3d_so_statistics_query_ops_issue(struct wined3d_query *query, D
@@ -860,6 +860,34 @@ static BOOL wined3d_pipeline_query_ops_issue(struct wined3d_query *query, DWORD
return poll;
}
@@ -79,7 +79,7 @@ index 55871130ce0..3c7a3ae4f8a 100644
static void wined3d_event_query_ops_destroy(struct wined3d_query *query)
{
struct wined3d_event_query *event_query = wined3d_event_query_from_query(query);
@@ -981,6 +1009,72 @@ static HRESULT wined3d_so_statistics_query_create(struct wined3d_device *device,
@@ -1143,6 +1171,72 @@ static HRESULT wined3d_pipeline_query_create(struct wined3d_device *device,
return WINED3D_OK;
}
@@ -152,9 +152,9 @@ index 55871130ce0..3c7a3ae4f8a 100644
HRESULT CDECL wined3d_query_create(struct wined3d_device *device, enum wined3d_query_type type,
void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query)
{
@@ -1008,6 +1102,12 @@ HRESULT CDECL wined3d_query_create(struct wined3d_device *device, enum wined3d_q
case WINED3D_QUERY_TYPE_SO_STATISTICS_STREAM3:
return wined3d_so_statistics_query_create(device, type, parent, parent_ops, query);
@@ -1173,6 +1267,12 @@ HRESULT CDECL wined3d_query_create(struct wined3d_device *device, enum wined3d_q
case WINED3D_QUERY_TYPE_PIPELINE_STATISTICS:
return wined3d_pipeline_query_create(device, type, parent, parent_ops, query);
+ case WINED3D_QUERY_TYPE_SO_STATISTICS:
+ return wined3d_statistics_query_create(device, type, parent, parent_ops, query);
@@ -166,5 +166,5 @@ index 55871130ce0..3c7a3ae4f8a 100644
FIXME("Unhandled query type %#x.\n", type);
return WINED3DERR_NOTAVAILABLE;
--
2.12.2
2.13.0

View File

@@ -1,142 +0,0 @@
From 6313efefb1d2dc0adaaae123cee74678e0709fee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sun, 22 Jan 2017 01:51:51 +0100
Subject: d3d11: Add dummy support for D3D11_QUERY_PIPELINE_STATISTICS query.
---
dlls/d3d10core/tests/device.c | 2 +-
dlls/d3d11/tests/d3d11.c | 2 +-
dlls/wined3d/query.c | 50 +++++++++++++++++++++++++++++++++++++++++++
include/wine/wined3d.h | 15 +++++++++++++
4 files changed, 67 insertions(+), 2 deletions(-)
diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c
index c08004723cc..9958feb1c25 100644
--- a/dlls/d3d10core/tests/device.c
+++ b/dlls/d3d10core/tests/device.c
@@ -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, FALSE},
{D3D10_QUERY_SO_OVERFLOW_PREDICATE, TRUE, FALSE},
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index a56bcd91f70..9c4b0392014 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -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, FALSE},
{D3D11_QUERY_SO_OVERFLOW_PREDICATE, D3D_FEATURE_LEVEL_10_0, TRUE, TRUE, FALSE},
diff --git a/dlls/wined3d/query.c b/dlls/wined3d/query.c
index 3c7a3ae4f8a..1da1b3ea7ae 100644
--- a/dlls/wined3d/query.c
+++ b/dlls/wined3d/query.c
@@ -757,6 +757,20 @@ static BOOL wined3d_overflow_query_ops_issue(struct wined3d_query *query, DWORD
return FALSE;
}
+static BOOL wined3d_pipeline_query_ops_poll(struct wined3d_query *query, DWORD flags)
+{
+ TRACE("query %p, flags %#x.\n", query, flags);
+
+ return TRUE;
+}
+
+static BOOL wined3d_pipeline_query_ops_issue(struct wined3d_query *query, DWORD flags)
+{
+ FIXME("query %p, flags %#x.\n", query, flags);
+
+ return FALSE;
+}
+
static void wined3d_event_query_ops_destroy(struct wined3d_query *query)
{
struct wined3d_event_query *event_query = wined3d_event_query_from_query(query);
@@ -1075,6 +1089,39 @@ static HRESULT wined3d_overflow_query_create(struct wined3d_device *device,
return WINED3D_OK;
}
+static void wined3d_pipeline_query_ops_destroy(struct wined3d_query *query)
+{
+ HeapFree(GetProcessHeap(), 0, query);
+}
+
+static const struct wined3d_query_ops pipeline_query_ops =
+{
+ wined3d_pipeline_query_ops_poll,
+ wined3d_pipeline_query_ops_issue,
+ wined3d_pipeline_query_ops_destroy,
+};
+
+static HRESULT wined3d_pipeline_query_create(struct wined3d_device *device,
+ enum wined3d_query_type type, void *parent, const struct wined3d_parent_ops *parent_ops,
+ struct wined3d_query **query)
+{
+ static const struct wined3d_query_data_pipeline_statistics data;
+ struct wined3d_query *object;
+
+ FIXME("device %p, type %#x, parent %p, query %p.\n", device, type, parent, query);
+
+ if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
+ return E_OUTOFMEMORY;
+
+ wined3d_query_init(object, device, type, &data,
+ sizeof(data), &pipeline_query_ops, parent, parent_ops);
+
+ TRACE("Created query %p.\n", object);
+ *query = object;
+
+ return WINED3D_OK;
+}
+
HRESULT CDECL wined3d_query_create(struct wined3d_device *device, enum wined3d_query_type type,
void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query)
{
@@ -1108,6 +1155,9 @@ HRESULT CDECL wined3d_query_create(struct wined3d_device *device, enum wined3d_q
case WINED3D_QUERY_TYPE_SO_OVERFLOW:
return wined3d_overflow_query_create(device, type, parent, parent_ops, query);
+ case WINED3D_QUERY_TYPE_PIPELINE_STATISTICS:
+ return wined3d_pipeline_query_create(device, type, parent, parent_ops, query);
+
default:
FIXME("Unhandled query type %#x.\n", type);
return WINED3DERR_NOTAVAILABLE;
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 8697fbfa935..b81bc437efe 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -725,6 +725,21 @@ struct wined3d_query_data_so_statistics
UINT64 primitives_generated;
};
+struct wined3d_query_data_pipeline_statistics
+{
+ UINT64 ia_vertices;
+ UINT64 ia_primitives;
+ UINT64 vs_invocations;
+ UINT64 gs_invocations;
+ UINT64 gs_primitives;
+ UINT64 c_invocations;
+ UINT64 c_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)
--
2.12.2

View File

@@ -1,444 +0,0 @@
From a36cd6cf41376b8dae38c289d353da26ecf53ee3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sun, 28 May 2017 04:49:57 +0200
Subject: wined3d: Implement WINED3D_QUERY_TYPE_PIPELINE_STATISTICS.
---
dlls/wined3d/context.c | 58 ++++++++++++
dlls/wined3d/directx.c | 1 +
dlls/wined3d/query.c | 197 +++++++++++++++++++++++++++++++++++++++--
dlls/wined3d/wined3d_gl.h | 1 +
dlls/wined3d/wined3d_private.h | 39 ++++++++
5 files changed, 287 insertions(+), 9 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 8ab0e10d815..b03287f5029 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -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,
@@ -1225,6 +1262,7 @@ static void context_destroy_gl_resources(struct wined3d_context *context)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_so_statistics_query *so_statistics_query;
+ struct wined3d_pipeline_statistics_query *pipeline_statistics_query;
struct wined3d_timestamp_query *timestamp_query;
struct wined3d_occlusion_query *occlusion_query;
struct wined3d_event_query *event_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);
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index e6cefbd2cf2..ec53192b76f 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -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 },
diff --git a/dlls/wined3d/query.c b/dlls/wined3d/query.c
index 1da1b3ea7ae..3bac4e1d28f 100644
--- a/dlls/wined3d/query.c
+++ b/dlls/wined3d/query.c
@@ -61,6 +61,11 @@ static struct wined3d_so_statistics_query *wined3d_so_statistics_query_from_quer
return CONTAINING_RECORD(query, struct wined3d_so_statistics_query, query);
}
+static struct wined3d_pipeline_statistics_query *wined3d_pipeline_statistics_query_from_query(struct wined3d_query *query)
+{
+ return CONTAINING_RECORD(query, struct wined3d_pipeline_statistics_query, query);
+}
+
BOOL wined3d_event_query_supported(const struct wined3d_gl_info *gl_info)
{
return gl_info->supported[ARB_SYNC] || gl_info->supported[NV_FENCE] || gl_info->supported[APPLE_FENCE];
@@ -759,16 +764,179 @@ static BOOL wined3d_overflow_query_ops_issue(struct wined3d_query *query, DWORD
static BOOL wined3d_pipeline_query_ops_poll(struct wined3d_query *query, DWORD flags)
{
+ struct wined3d_pipeline_statistics_query *pq = wined3d_pipeline_statistics_query_from_query(query);
+ struct wined3d_device *device = query->device;
+ const struct wined3d_gl_info *gl_info;
+ struct wined3d_context *context;
+ GLuint available;
+ int i;
+
TRACE("query %p, flags %#x.\n", query, flags);
- return TRUE;
+ if (!(context = context_reacquire(device, pq->context)))
+ {
+ FIXME("%p Wrong thread, returning 0 primitives.\n", query);
+ memset(&pq->statistics, 0, sizeof(pq->statistics));
+ return TRUE;
+ }
+ gl_info = context->gl_info;
+
+ for (i = 0; i < ARRAY_SIZE(pq->u.id); i++)
+ {
+ GL_EXTCALL(glGetQueryObjectuiv(pq->u.id[i], GL_QUERY_RESULT_AVAILABLE, &available));
+ if (!available) goto done;
+ }
+
+ if (gl_info->supported[ARB_TIMER_QUERY])
+ {
+ GLuint64 result;
+ GL_EXTCALL(glGetQueryObjectui64v(pq->u.query.vertices, GL_QUERY_RESULT, &result));
+ pq->statistics.ia_vertices = result;
+ GL_EXTCALL(glGetQueryObjectui64v(pq->u.query.primitives, GL_QUERY_RESULT, &result));
+ pq->statistics.ia_primitives = result;
+ GL_EXTCALL(glGetQueryObjectui64v(pq->u.query.vertex_shader, GL_QUERY_RESULT, &result));
+ pq->statistics.vs_invocations = result;
+ GL_EXTCALL(glGetQueryObjectui64v(pq->u.query.tess_control_shader, GL_QUERY_RESULT, &result));
+ pq->statistics.hs_invocations = result;
+ GL_EXTCALL(glGetQueryObjectui64v(pq->u.query.tess_eval_shader, GL_QUERY_RESULT, &result));
+ pq->statistics.ds_invocations = result;
+ GL_EXTCALL(glGetQueryObjectui64v(pq->u.query.geometry_shader, GL_QUERY_RESULT, &result));
+ pq->statistics.gs_invocations = result;
+ GL_EXTCALL(glGetQueryObjectui64v(pq->u.query.geometry_primitives, GL_QUERY_RESULT, &result));
+ pq->statistics.gs_primitives = result;
+ GL_EXTCALL(glGetQueryObjectui64v(pq->u.query.fragment_shader, GL_QUERY_RESULT, &result));
+ pq->statistics.ps_invocations = result;
+ GL_EXTCALL(glGetQueryObjectui64v(pq->u.query.compute_shader, GL_QUERY_RESULT, &result));
+ pq->statistics.cs_invocations = result;
+ GL_EXTCALL(glGetQueryObjectui64v(pq->u.query.clipping_input, GL_QUERY_RESULT, &result));
+ pq->statistics.c_invocations = result;
+ GL_EXTCALL(glGetQueryObjectui64v(pq->u.query.clipping_output, GL_QUERY_RESULT, &result));
+ pq->statistics.c_primitives = result;
+ }
+ else
+ {
+ GLuint result;
+ GL_EXTCALL(glGetQueryObjectuiv(pq->u.query.vertices, GL_QUERY_RESULT, &result));
+ pq->statistics.ia_vertices = result;
+ GL_EXTCALL(glGetQueryObjectuiv(pq->u.query.primitives, GL_QUERY_RESULT, &result));
+ pq->statistics.ia_primitives = result;
+ GL_EXTCALL(glGetQueryObjectuiv(pq->u.query.vertex_shader, GL_QUERY_RESULT, &result));
+ pq->statistics.vs_invocations = result;
+ GL_EXTCALL(glGetQueryObjectuiv(pq->u.query.tess_control_shader, GL_QUERY_RESULT, &result));
+ pq->statistics.hs_invocations = result;
+ GL_EXTCALL(glGetQueryObjectuiv(pq->u.query.tess_eval_shader, GL_QUERY_RESULT, &result));
+ pq->statistics.ds_invocations = result;
+ GL_EXTCALL(glGetQueryObjectuiv(pq->u.query.geometry_shader, GL_QUERY_RESULT, &result));
+ pq->statistics.gs_invocations = result;
+ GL_EXTCALL(glGetQueryObjectuiv(pq->u.query.geometry_primitives, GL_QUERY_RESULT, &result));
+ pq->statistics.gs_primitives = result;
+ GL_EXTCALL(glGetQueryObjectuiv(pq->u.query.fragment_shader, GL_QUERY_RESULT, &result));
+ pq->statistics.ps_invocations = result;
+ GL_EXTCALL(glGetQueryObjectuiv(pq->u.query.compute_shader, GL_QUERY_RESULT, &result));
+ pq->statistics.cs_invocations = result;
+ GL_EXTCALL(glGetQueryObjectuiv(pq->u.query.clipping_input, GL_QUERY_RESULT, &result));
+ pq->statistics.c_invocations = result;
+ GL_EXTCALL(glGetQueryObjectuiv(pq->u.query.clipping_output, GL_QUERY_RESULT, &result));
+ pq->statistics.c_primitives = result;
+ }
+
+done:
+ checkGLcall("poll pipeline statistics query");
+ context_release(context);
+ return available;
}
static BOOL wined3d_pipeline_query_ops_issue(struct wined3d_query *query, DWORD flags)
{
- FIXME("query %p, flags %#x.\n", query, flags);
+ struct wined3d_pipeline_statistics_query *pq = wined3d_pipeline_statistics_query_from_query(query);
+ struct wined3d_device *device = query->device;
+ const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
+ struct wined3d_context *context;
+ BOOL poll = FALSE;
- return FALSE;
+ TRACE("query %p, flags %#x.\n", query, flags);
+
+ if (flags & WINED3DISSUE_BEGIN)
+ {
+ if (pq->started)
+ {
+ if ((context = context_reacquire(device, pq->context)))
+ {
+ GL_EXTCALL(glEndQuery(GL_VERTICES_SUBMITTED_ARB));
+ GL_EXTCALL(glEndQuery(GL_PRIMITIVES_SUBMITTED_ARB));
+ GL_EXTCALL(glEndQuery(GL_VERTEX_SHADER_INVOCATIONS_ARB));
+ GL_EXTCALL(glEndQuery(GL_TESS_CONTROL_SHADER_PATCHES_ARB));
+ GL_EXTCALL(glEndQuery(GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB));
+ GL_EXTCALL(glEndQuery(GL_GEOMETRY_SHADER_INVOCATIONS));
+ GL_EXTCALL(glEndQuery(GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB));
+ GL_EXTCALL(glEndQuery(GL_FRAGMENT_SHADER_INVOCATIONS_ARB));
+ GL_EXTCALL(glEndQuery(GL_COMPUTE_SHADER_INVOCATIONS_ARB));
+ GL_EXTCALL(glEndQuery(GL_CLIPPING_INPUT_PRIMITIVES_ARB));
+ GL_EXTCALL(glEndQuery(GL_CLIPPING_OUTPUT_PRIMITIVES_ARB));
+ }
+ else
+ {
+ FIXME("Wrong thread, can't restart query.\n");
+ context_free_pipeline_statistics_query(pq);
+ context = context_acquire(device, NULL, 0);
+ context_alloc_pipeline_statistics_query(context, pq);
+ }
+ }
+ else
+ {
+ if (pq->context)
+ context_free_pipeline_statistics_query(pq);
+ context = context_acquire(device, NULL, 0);
+ context_alloc_pipeline_statistics_query(context, pq);
+ }
+
+ GL_EXTCALL(glBeginQuery(GL_VERTICES_SUBMITTED_ARB, pq->u.query.vertices));
+ GL_EXTCALL(glBeginQuery(GL_PRIMITIVES_SUBMITTED_ARB, pq->u.query.primitives));
+ GL_EXTCALL(glBeginQuery(GL_VERTEX_SHADER_INVOCATIONS_ARB, pq->u.query.vertex_shader));
+ GL_EXTCALL(glBeginQuery(GL_TESS_CONTROL_SHADER_PATCHES_ARB, pq->u.query.tess_control_shader));
+ GL_EXTCALL(glBeginQuery(GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB, pq->u.query.tess_eval_shader));
+ GL_EXTCALL(glBeginQuery(GL_GEOMETRY_SHADER_INVOCATIONS, pq->u.query.geometry_shader));
+ GL_EXTCALL(glBeginQuery(GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB, pq->u.query.geometry_primitives));
+ GL_EXTCALL(glBeginQuery(GL_FRAGMENT_SHADER_INVOCATIONS_ARB, pq->u.query.fragment_shader));
+ GL_EXTCALL(glBeginQuery(GL_COMPUTE_SHADER_INVOCATIONS_ARB, pq->u.query.compute_shader));
+ GL_EXTCALL(glBeginQuery(GL_CLIPPING_INPUT_PRIMITIVES_ARB, pq->u.query.clipping_input));
+ GL_EXTCALL(glBeginQuery(GL_CLIPPING_OUTPUT_PRIMITIVES_ARB, pq->u.query.clipping_output));
+ checkGLcall("begin query");
+
+ context_release(context);
+ pq->started = TRUE;
+ }
+ if (flags & WINED3DISSUE_END)
+ {
+ if (pq->started)
+ {
+ if ((context = context_reacquire(device, pq->context)))
+ {
+ GL_EXTCALL(glEndQuery(GL_VERTICES_SUBMITTED_ARB));
+ GL_EXTCALL(glEndQuery(GL_PRIMITIVES_SUBMITTED_ARB));
+ GL_EXTCALL(glEndQuery(GL_VERTEX_SHADER_INVOCATIONS_ARB));
+ GL_EXTCALL(glEndQuery(GL_TESS_CONTROL_SHADER_PATCHES_ARB));
+ GL_EXTCALL(glEndQuery(GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB));
+ GL_EXTCALL(glEndQuery(GL_GEOMETRY_SHADER_INVOCATIONS));
+ GL_EXTCALL(glEndQuery(GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB));
+ GL_EXTCALL(glEndQuery(GL_FRAGMENT_SHADER_INVOCATIONS_ARB));
+ GL_EXTCALL(glEndQuery(GL_COMPUTE_SHADER_INVOCATIONS_ARB));
+ GL_EXTCALL(glEndQuery(GL_CLIPPING_INPUT_PRIMITIVES_ARB));
+ GL_EXTCALL(glEndQuery(GL_CLIPPING_OUTPUT_PRIMITIVES_ARB));
+ checkGLcall("end query");
+
+ context_release(context);
+ poll = TRUE;
+ }
+ else
+ {
+ FIXME("Wrong thread, can't end query.\n");
+ }
+ }
+ pq->started = FALSE;
+ }
+
+ return poll;
}
static void wined3d_event_query_ops_destroy(struct wined3d_query *query)
@@ -1091,6 +1259,10 @@ static HRESULT wined3d_overflow_query_create(struct wined3d_device *device,
static void wined3d_pipeline_query_ops_destroy(struct wined3d_query *query)
{
+ struct wined3d_pipeline_statistics_query *pq = wined3d_pipeline_statistics_query_from_query(query);
+
+ if (pq->context)
+ context_free_pipeline_statistics_query(pq);
HeapFree(GetProcessHeap(), 0, query);
}
@@ -1105,19 +1277,26 @@ static HRESULT wined3d_pipeline_query_create(struct wined3d_device *device,
enum wined3d_query_type type, void *parent, const struct wined3d_parent_ops *parent_ops,
struct wined3d_query **query)
{
- static const struct wined3d_query_data_pipeline_statistics data;
- struct wined3d_query *object;
+ const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
+ struct wined3d_pipeline_statistics_query *object;
- FIXME("device %p, type %#x, parent %p, query %p.\n", device, type, parent, query);
+ TRACE("device %p, type %#x, parent %p, parent_ops %p, query %p.\n",
+ device, type, parent, parent_ops, query);
+
+ if (!gl_info->supported[ARB_PIPELINE_STATISTICS_QUERY])
+ {
+ WARN("OpenGL implementation does not support pipeline statistic queries.\n");
+ return WINED3DERR_NOTAVAILABLE;
+ }
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
return E_OUTOFMEMORY;
- wined3d_query_init(object, device, type, &data,
- sizeof(data), &pipeline_query_ops, parent, parent_ops);
+ wined3d_query_init(&object->query, device, type, &object->statistics,
+ sizeof(object->statistics), &pipeline_query_ops, parent, parent_ops);
TRACE("Created query %p.\n", object);
- *query = object;
+ *query = &object->query;
return WINED3D_OK;
}
diff --git a/dlls/wined3d/wined3d_gl.h b/dlls/wined3d/wined3d_gl.h
index 3806869fd42..8b25220cd4b 100644
--- a/dlls/wined3d/wined3d_gl.h
+++ b/dlls/wined3d/wined3d_gl.h
@@ -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,
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 18109850157..1025c98f180 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -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 */
--
2.12.2

View File

@@ -1,107 +0,0 @@
From 4aefdfaa464c49aeece5e1803478a63bcdb55562 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sun, 28 May 2017 04:52:59 +0200
Subject: d3d11/tests: Add basic test for D3D11_QUERY_PIPELINE_STATISTICS.
---
dlls/d3d11/tests/d3d11.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 77 insertions(+)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index 5a14dd4d55c..8fe6835c831 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -5380,6 +5380,82 @@ if (0)
release_test_context(&test_context);
}
+static void test_pipeline_query(void)
+{
+ static const struct vec4 red = {1.0f, 0.0f, 0.0f, 1.0f};
+ static const float white[] = {1.0f, 1.0f, 1.0f, 1.0f};
+
+ D3D11_QUERY_DATA_PIPELINE_STATISTICS data;
+ struct d3d11_test_context test_context;
+ ID3D11DeviceContext *context;
+ D3D11_QUERY_DESC query_desc;
+ ID3D11Asynchronous *query;
+ unsigned int data_size, i;
+ ID3D11Device *device;
+ HRESULT hr;
+
+ if (!init_test_context(&test_context, NULL))
+ return;
+
+ device = test_context.device;
+ context = test_context.immediate_context;
+
+ ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white);
+
+ query_desc.Query = D3D11_QUERY_PIPELINE_STATISTICS;
+ query_desc.MiscFlags = 0;
+ hr = ID3D11Device_CreateQuery(device, &query_desc, (ID3D11Query **)&query);
+ ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ data_size = ID3D11Asynchronous_GetDataSize(query);
+ ok(data_size == sizeof(data), "Got unexpected data size %u.\n", data_size);
+
+ memset(&data, 0xff, sizeof(data));
+ hr = ID3D11DeviceContext_GetData(context, query, NULL, 0, 0);
+ ok(hr == DXGI_ERROR_INVALID_CALL, "Got unexpected hr %#x.\n", hr);
+ hr = ID3D11DeviceContext_GetData(context, query, &data, sizeof(data), 0);
+ ok(hr == DXGI_ERROR_INVALID_CALL, "Got unexpected hr %#x.\n", hr);
+
+ ID3D11DeviceContext_End(context, query);
+ ID3D11DeviceContext_Begin(context, query);
+ ID3D11DeviceContext_Begin(context, query);
+
+ memset(&data, 0xff, sizeof(data));
+ hr = ID3D11DeviceContext_GetData(context, query, NULL, 0, 0);
+ todo_wine ok(hr == DXGI_ERROR_INVALID_CALL, "Got unexpected hr %#x.\n", hr);
+ hr = ID3D11DeviceContext_GetData(context, query, &data, sizeof(data), 0);
+ todo_wine ok(hr == DXGI_ERROR_INVALID_CALL, "Got unexpected hr %#x.\n", hr);
+ ok(data.IAVertices == 0xffffffffffffffff, "Data was modified.\n");
+
+ draw_color_quad(&test_context, &red);
+
+ ID3D11DeviceContext_End(context, query);
+ for (i = 0; i < 500; ++i)
+ {
+ if ((hr = ID3D11DeviceContext_GetData(context, query, NULL, 0, 0)) != S_FALSE)
+ break;
+ Sleep(10);
+ }
+ ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+
+ memset(&data, 0xff, sizeof(data));
+ hr = ID3D11DeviceContext_GetData(context, query, &data, sizeof(data), 0);
+ ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ ok(data.IAVertices == 4, "Got unexpected IAVertices count: %u\n", (unsigned int)data.IAVertices);
+ ok(data.IAPrimitives == 2, "Got unexpected IAPrimitives count: %u\n", (unsigned int)data.IAPrimitives);
+ ok(data.VSInvocations == 4, "Got unexpected VSInvocations count: %u\n", (unsigned int)data.VSInvocations);
+ ok(data.GSInvocations == 0, "Got unexpected GSInvocations count: %u\n", (unsigned int)data.GSInvocations);
+ ok(data.GSPrimitives == 0, "Got unexpected GSPrimitives count: %u\n", (unsigned int)data.GSPrimitives);
+ ok(data.CInvocations == 2, "Got unexpected CInvocations count: %u\n", (unsigned int)data.CInvocations);
+ ok(data.CPrimitives == 2, "Got unexpected CPrimitives count: %u\n", (unsigned int)data.CPrimitives);
+ ok(data.PSInvocations >= 640*480, "Got unexpected PSInvocations count: %u\n", (unsigned int)data.PSInvocations);
+ ok(data.HSInvocations == 0, "Got unexpected HSInvocations count: %u\n", (unsigned int)data.HSInvocations);
+ ok(data.DSInvocations == 0, "Got unexpected DSInvocations count: %u\n", (unsigned int)data.DSInvocations);
+ ok(data.CSInvocations == 0, "Got unexpected CSInvocations count: %u\n", (unsigned int)data.CSInvocations);
+
+ ID3D11Asynchronous_Release(query);
+ release_test_context(&test_context);
+}
+
static void test_timestamp_query(void)
{
static const struct vec4 red = {1.0f, 0.0f, 0.0f, 1.0f};
@@ -21008,6 +21084,7 @@ START_TEST(d3d11)
test_create_rasterizer_state();
test_create_query();
test_occlusion_query();
+ test_pipeline_query();
test_timestamp_query();
test_device_removed_reason();
test_private_data();
--
2.12.2

View File

@@ -1,2 +1 @@
Fixes: [20776] Add stubs for QUERY_TYPE_SO_STATISTICS and QUERY_TYPE_SO_OVERFLOW
Fixes: Add implementation for QUERY_TYPE_PIPELINE_STATISTICS