ReactOS 0.4.15-dev-7918-g2a2556c
query.c File Reference
#include "config.h"
#include "wine/port.h"
#include "wined3d_private.h"
Include dependency graph for query.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3d)
 
static UINT64 get_query_result64 (GLuint id, const struct wined3d_gl_info *gl_info)
 
static void wined3d_query_init (struct wined3d_query *query, struct wined3d_device *device, enum wined3d_query_type type, const void *data, DWORD data_size, const struct wined3d_query_ops *query_ops, void *parent, const struct wined3d_parent_ops *parent_ops)
 
static struct wined3d_event_querywined3d_event_query_from_query (struct wined3d_query *query)
 
static struct wined3d_occlusion_querywined3d_occlusion_query_from_query (struct wined3d_query *query)
 
static struct wined3d_timestamp_querywined3d_timestamp_query_from_query (struct wined3d_query *query)
 
static struct wined3d_so_statistics_querywined3d_so_statistics_query_from_query (struct wined3d_query *query)
 
static struct wined3d_pipeline_statistics_querywined3d_pipeline_statistics_query_from_query (struct wined3d_query *query)
 
static BOOL wined3d_fence_supported (const struct wined3d_gl_info *gl_info)
 
static enum wined3d_fence_result wined3d_fence_test (const struct wined3d_fence *fence, const struct wined3d_device *device, DWORD flags)
 
enum wined3d_fence_result wined3d_fence_wait (const struct wined3d_fence *fence, const struct wined3d_device *device)
 
void wined3d_fence_issue (struct wined3d_fence *fence, const struct wined3d_device *device)
 
static void wined3d_fence_free (struct wined3d_fence *fence)
 
void wined3d_fence_destroy (struct wined3d_fence *fence)
 
static HRESULT wined3d_fence_init (struct wined3d_fence *fence, const struct wined3d_gl_info *gl_info)
 
HRESULT wined3d_fence_create (struct wined3d_device *device, struct wined3d_fence **fence)
 
ULONG CDECL wined3d_query_incref (struct wined3d_query *query)
 
static void wined3d_query_destroy_object (void *object)
 
ULONG CDECL wined3d_query_decref (struct wined3d_query *query)
 
HRESULT CDECL wined3d_query_get_data (struct wined3d_query *query, void *data, UINT data_size, DWORD flags)
 
UINT CDECL wined3d_query_get_data_size (const struct wined3d_query *query)
 
HRESULT CDECL wined3d_query_issue (struct wined3d_query *query, DWORD flags)
 
static BOOL wined3d_occlusion_query_ops_poll (struct wined3d_query *query, DWORD flags)
 
static BOOL wined3d_event_query_ops_poll (struct wined3d_query *query, DWORD flags)
 
void *CDECL wined3d_query_get_parent (const struct wined3d_query *query)
 
enum wined3d_query_type CDECL wined3d_query_get_type (const struct wined3d_query *query)
 
static BOOL wined3d_event_query_ops_issue (struct wined3d_query *query, DWORD flags)
 
static BOOL wined3d_occlusion_query_ops_issue (struct wined3d_query *query, DWORD flags)
 
static BOOL wined3d_timestamp_query_ops_poll (struct wined3d_query *query, DWORD flags)
 
static BOOL wined3d_timestamp_query_ops_issue (struct wined3d_query *query, DWORD flags)
 
static BOOL wined3d_timestamp_disjoint_query_ops_poll (struct wined3d_query *query, DWORD flags)
 
static BOOL wined3d_timestamp_disjoint_query_ops_issue (struct wined3d_query *query, DWORD flags)
 
static BOOL wined3d_so_statistics_query_ops_poll (struct wined3d_query *query, DWORD flags)
 
static BOOL wined3d_so_statistics_query_ops_issue (struct wined3d_query *query, DWORD flags)
 
static BOOL wined3d_pipeline_query_ops_poll (struct wined3d_query *query, DWORD flags)
 
static void wined3d_pipeline_statistics_query_end (struct wined3d_pipeline_statistics_query *query, struct wined3d_context *context)
 
static BOOL wined3d_pipeline_query_ops_issue (struct wined3d_query *query, DWORD flags)
 
static BOOL wined3d_statistics_query_ops_poll (struct wined3d_query *query, DWORD flags)
 
static BOOL wined3d_statistics_query_ops_issue (struct wined3d_query *query, DWORD flags)
 
static BOOL wined3d_overflow_query_ops_poll (struct wined3d_query *query, DWORD flags)
 
static BOOL wined3d_overflow_query_ops_issue (struct wined3d_query *query, DWORD flags)
 
static void wined3d_event_query_ops_destroy (struct wined3d_query *query)
 
static HRESULT wined3d_event_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 void wined3d_occlusion_query_ops_destroy (struct wined3d_query *query)
 
static HRESULT wined3d_occlusion_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 void wined3d_timestamp_query_ops_destroy (struct wined3d_query *query)
 
static HRESULT wined3d_timestamp_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 void wined3d_timestamp_disjoint_query_ops_destroy (struct wined3d_query *query)
 
static HRESULT wined3d_timestamp_disjoint_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 void wined3d_so_statistics_query_ops_destroy (struct wined3d_query *query)
 
static HRESULT wined3d_so_statistics_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 void wined3d_pipeline_query_ops_destroy (struct wined3d_query *query)
 
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 void wined3d_statistics_query_ops_destroy (struct wined3d_query *query)
 
static HRESULT wined3d_statistics_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 void wined3d_overflow_query_ops_destroy (struct wined3d_query *query)
 
static HRESULT wined3d_overflow_query_create (struct wined3d_device *device, enum wined3d_query_type type, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query)
 
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)
 

Variables

static const struct wined3d_query_ops event_query_ops
 
static const struct wined3d_query_ops occlusion_query_ops
 
static const struct wined3d_query_ops timestamp_query_ops
 
static const struct wined3d_query_ops timestamp_disjoint_query_ops
 
static const struct wined3d_query_ops so_statistics_query_ops
 
static const struct wined3d_query_ops pipeline_query_ops
 
static const struct wined3d_query_ops statistics_query_ops
 
static const struct wined3d_query_ops overflow_query_ops
 

Function Documentation

◆ get_query_result64()

static UINT64 get_query_result64 ( GLuint  id,
const struct wined3d_gl_info gl_info 
)
static

Definition at line 28 of file query.c.

29{
30 if (gl_info->supported[ARB_TIMER_QUERY])
31 {
33 GL_EXTCALL(glGetQueryObjectui64v(id, GL_QUERY_RESULT, &result));
34 return result;
35 }
36 else
37 {
39 GL_EXTCALL(glGetQueryObjectuiv(id, GL_QUERY_RESULT, &result));
40 return result;
41 }
42}
unsigned int GLuint
Definition: gl.h:159
uint64_t GLuint64
Definition: glext.h:5568
#define GL_QUERY_RESULT
Definition: glext.h:334
GLuint64EXT * result
Definition: glext.h:11304
BOOL supported[WINED3D_GL_EXT_COUNT]
@ ARB_TIMER_QUERY
Definition: wined3d_gl.h:132
#define GL_EXTCALL(f)

Referenced by wined3d_occlusion_query_ops_poll(), wined3d_pipeline_query_ops_poll(), and wined3d_so_statistics_query_ops_poll().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( d3d  )

◆ wined3d_event_query_create()

static HRESULT wined3d_event_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

Definition at line 959 of file query.c.

962{
963 const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
965 HRESULT hr;
966
967 TRACE("device %p, type %#x, parent %p, parent_ops %p, query %p.\n",
968 device, type, parent, parent_ops, query);
969
970 if (!(object = heap_alloc_zero(sizeof(*object))))
971 return E_OUTOFMEMORY;
972
973 if (FAILED(hr = wined3d_fence_init(&object->fence, gl_info)))
974 {
975 WARN("Event queries not supported.\n");
976 heap_free(object);
977 return hr;
978 }
979
980 wined3d_query_init(&object->query, device, type, &object->signalled,
981 sizeof(object->signalled), &event_query_ops, parent, parent_ops);
982
983 TRACE("Created query %p.\n", object);
984 *query = &object->query;
985
986 return WINED3D_OK;
987}
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
#define WARN(fmt,...)
Definition: debug.h:112
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static HRESULT wined3d_fence_init(struct wined3d_fence *fence, const struct wined3d_gl_info *gl_info)
Definition: query.c:292
static const struct wined3d_query_ops event_query_ops
Definition: query.c:952
static void wined3d_query_init(struct wined3d_query *query, struct wined3d_device *device, enum wined3d_query_type type, const void *data, DWORD data_size, const struct wined3d_query_ops *query_ops, void *parent, const struct wined3d_parent_ops *parent_ops)
Definition: query.c:44
r parent
Definition: btrfs.c:3010
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define FAILED(hr)
Definition: intsafe.h:51
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
Definition: devices.h:37
#define WINED3D_OK
Definition: wined3d.h:37

Referenced by wined3d_query_create().

◆ wined3d_event_query_from_query()

static struct wined3d_event_query * wined3d_event_query_from_query ( struct wined3d_query query)
static

Definition at line 60 of file query.c.

61{
63}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by wined3d_event_query_ops_destroy(), wined3d_event_query_ops_issue(), and wined3d_event_query_ops_poll().

◆ wined3d_event_query_ops_destroy()

static void wined3d_event_query_ops_destroy ( struct wined3d_query query)
static

Definition at line 944 of file query.c.

945{
947
948 wined3d_fence_free(&event_query->fence);
949 heap_free(event_query);
950}
static struct wined3d_event_query * wined3d_event_query_from_query(struct wined3d_query *query)
Definition: query.c:60
static void wined3d_fence_free(struct wined3d_fence *fence)
Definition: query.c:280
struct wined3d_fence fence

◆ wined3d_event_query_ops_issue()

static BOOL wined3d_event_query_ops_issue ( struct wined3d_query query,
DWORD  flags 
)
static

Definition at line 505 of file query.c.

506{
507 TRACE("query %p, flags %#x.\n", query, flags);
508
510 {
512
513 wined3d_fence_issue(&event_query->fence, query->device);
514 return TRUE;
515 }
516 else if (flags & WINED3DISSUE_BEGIN)
517 {
518 /* Started implicitly at query creation. */
519 ERR("Event query issued with START flag - what to do?\n");
520 }
521
522 return FALSE;
523}
#define ERR(fmt,...)
Definition: debug.h:110
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
void wined3d_fence_issue(struct wined3d_fence *fence, const struct wined3d_device *device)
Definition: query.c:244
GLbitfield flags
Definition: glext.h:7161
#define WINED3DISSUE_BEGIN
Definition: wined3d.h:761
#define WINED3DISSUE_END
Definition: wined3d.h:762

◆ wined3d_event_query_ops_poll()

static BOOL wined3d_event_query_ops_poll ( struct wined3d_query query,
DWORD  flags 
)
static

Definition at line 460 of file query.c.

461{
464
465 TRACE("query %p, flags %#x.\n", query, flags);
466
467 ret = wined3d_fence_test(&event_query->fence, query->device, flags);
468 switch (ret)
469 {
470 case WINED3D_FENCE_OK:
472 return event_query->signalled = TRUE;
473
475 return event_query->signalled = FALSE;
476
478 FIXME("(%p) Wrong thread, reporting GPU idle.\n", query);
479 return event_query->signalled = TRUE;
480
482 ERR("The GL event query failed.\n");
483 return event_query->signalled = TRUE;
484
485 default:
486 ERR("Unexpected wined3d_event_query_test result %#x.\n", ret);
487 return event_query->signalled = TRUE;
488 }
489}
#define FIXME(fmt,...)
Definition: debug.h:111
static enum wined3d_fence_result wined3d_fence_test(const struct wined3d_fence *fence, const struct wined3d_device *device, DWORD flags)
Definition: query.c:91
int ret
wined3d_fence_result
@ WINED3D_FENCE_WRONG_THREAD
@ WINED3D_FENCE_OK
@ WINED3D_FENCE_WAITING
@ WINED3D_FENCE_ERROR
@ WINED3D_FENCE_NOT_STARTED

◆ wined3d_fence_create()

HRESULT wined3d_fence_create ( struct wined3d_device device,
struct wined3d_fence **  fence 
)

Definition at line 303 of file query.c.

304{
305 const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
306 struct wined3d_fence *object;
307 HRESULT hr;
308
309 TRACE("device %p, fence %p.\n", device, fence);
310
311 if (!(object = heap_alloc_zero(sizeof(*object))))
312 return E_OUTOFMEMORY;
313
314 if (FAILED(hr = wined3d_fence_init(object, gl_info)))
315 {
316 heap_free(object);
317 return hr;
318 }
319
320 TRACE("Created fence %p.\n", object);
321 *fence = object;
322
323 return WINED3D_OK;
324}
union wined3d_gl_fence_object object

Referenced by buffer_sync_apple().

◆ wined3d_fence_destroy()

void wined3d_fence_destroy ( struct wined3d_fence fence)

Definition at line 286 of file query.c.

287{
288 wined3d_fence_free(fence);
289 heap_free(fence);
290}

Referenced by buffer_destroy_buffer_object(), and buffer_sync_apple().

◆ wined3d_fence_free()

static void wined3d_fence_free ( struct wined3d_fence fence)
static

Definition at line 280 of file query.c.

281{
282 if (fence->context)
283 context_free_fence(fence);
284}
void context_free_fence(struct wined3d_fence *fence)
Definition: context.c:904
struct wined3d_context * context

Referenced by wined3d_event_query_ops_destroy(), and wined3d_fence_destroy().

◆ wined3d_fence_init()

static HRESULT wined3d_fence_init ( struct wined3d_fence fence,
const struct wined3d_gl_info gl_info 
)
static

Definition at line 292 of file query.c.

293{
294 if (!wined3d_fence_supported(gl_info))
295 {
296 WARN("Fences not supported.\n");
298 }
299
300 return WINED3D_OK;
301}
static BOOL wined3d_fence_supported(const struct wined3d_gl_info *gl_info)
Definition: query.c:86
#define WINED3DERR_NOTAVAILABLE
Definition: wined3d.h:46

Referenced by wined3d_event_query_create(), and wined3d_fence_create().

◆ wined3d_fence_issue()

void wined3d_fence_issue ( struct wined3d_fence fence,
const struct wined3d_device device 
)

Definition at line 244 of file query.c.

245{
246 struct wined3d_context *context = NULL;
247 const struct wined3d_gl_info *gl_info;
248
249 if (fence->context && !(context = context_reacquire(device, fence->context))
250 && !fence->context->gl_info->supported[ARB_SYNC])
251 context_free_fence(fence);
252 if (!context)
254 gl_info = context->gl_info;
255 if (!fence->context)
257
258 if (gl_info->supported[ARB_SYNC])
259 {
260 if (fence->object.sync)
261 GL_EXTCALL(glDeleteSync(fence->object.sync));
262 checkGLcall("glDeleteSync");
263 fence->object.sync = GL_EXTCALL(glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0));
264 checkGLcall("glFenceSync");
265 }
266 else if (gl_info->supported[APPLE_FENCE])
267 {
268 GL_EXTCALL(glSetFenceAPPLE(fence->object.id));
269 checkGLcall("glSetFenceAPPLE");
270 }
271 else if (gl_info->supported[NV_FENCE])
272 {
273 GL_EXTCALL(glSetFenceNV(fence->object.id, GL_ALL_COMPLETED_NV));
274 checkGLcall("glSetFenceNV");
275 }
276
278}
#define NULL
Definition: types.h:112
struct wined3d_context * context_acquire(const struct wined3d_device *device, struct wined3d_texture *texture, unsigned int sub_resource_idx)
Definition: context.c:4242
void context_alloc_fence(struct wined3d_context *context, struct wined3d_fence *fence)
Definition: context.c:863
void context_release(struct wined3d_context *context)
Definition: context.c:1571
struct wined3d_context * context_reacquire(const struct wined3d_device *device, struct wined3d_context *context)
Definition: context.c:4305
#define GL_SYNC_GPU_COMMANDS_COMPLETE
Definition: glext.h:1923
#define GL_ALL_COMPLETED_NV
Definition: glext.h:3621
Definition: http.c:7252
@ APPLE_FENCE
Definition: wined3d_gl.h:40
@ ARB_SYNC
Definition: wined3d_gl.h:105
@ NV_FENCE
Definition: wined3d_gl.h:186
#define checkGLcall(A)

Referenced by draw_primitive(), and wined3d_event_query_ops_issue().

◆ wined3d_fence_supported()

static BOOL wined3d_fence_supported ( const struct wined3d_gl_info gl_info)
static

Definition at line 86 of file query.c.

87{
88 return gl_info->supported[ARB_SYNC] || gl_info->supported[NV_FENCE] || gl_info->supported[APPLE_FENCE];
89}

Referenced by wined3d_fence_init().

◆ wined3d_fence_test()

static enum wined3d_fence_result wined3d_fence_test ( const struct wined3d_fence fence,
const struct wined3d_device device,
DWORD  flags 
)
static

Definition at line 91 of file query.c.

93{
94 const struct wined3d_gl_info *gl_info;
97 BOOL fence_result;
98
99 TRACE("fence %p, device %p, flags %#x.\n", fence, device, flags);
100
101 if (!fence->context)
102 {
103 TRACE("Fence not issued.\n");
105 }
106
107 if (!(context = context_reacquire(device, fence->context)))
108 {
109 if (!fence->context->gl_info->supported[ARB_SYNC])
110 {
111 WARN("Fence tested from wrong thread.\n");
113 }
115 }
116 gl_info = context->gl_info;
117
118 if (gl_info->supported[ARB_SYNC])
119 {
120 GLenum gl_ret = GL_EXTCALL(glClientWaitSync(fence->object.sync,
122 checkGLcall("glClientWaitSync");
123
124 switch (gl_ret)
125 {
129 break;
130
133 break;
134
135 case GL_WAIT_FAILED:
136 default:
137 ERR("glClientWaitSync returned %#x.\n", gl_ret);
139 }
140 }
141 else if (gl_info->supported[APPLE_FENCE])
142 {
143 fence_result = GL_EXTCALL(glTestFenceAPPLE(fence->object.id));
144 checkGLcall("glTestFenceAPPLE");
145 if (fence_result)
147 else
149 }
150 else if (gl_info->supported[NV_FENCE])
151 {
152 fence_result = GL_EXTCALL(glTestFenceNV(fence->object.id));
153 checkGLcall("glTestFenceNV");
154 if (fence_result)
156 else
158 }
159 else
160 {
161 ERR("Fence created despite lack of GL support.\n");
163 }
164
166 return ret;
167}
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned int GLenum
Definition: gl.h:150
#define GL_ALREADY_SIGNALED
Definition: glext.h:1926
#define GL_CONDITION_SATISFIED
Definition: glext.h:1928
#define GL_TIMEOUT_EXPIRED
Definition: glext.h:1927
#define GL_WAIT_FAILED
Definition: glext.h:1929
#define GL_SYNC_FLUSH_COMMANDS_BIT
Definition: glext.h:1930
const struct wined3d_gl_info * gl_info
#define WINED3DGETDATA_FLUSH
Definition: wined3d.h:763

Referenced by wined3d_event_query_ops_poll().

◆ wined3d_fence_wait()

enum wined3d_fence_result wined3d_fence_wait ( const struct wined3d_fence fence,
const struct wined3d_device device 
)

Definition at line 169 of file query.c.

171{
172 const struct wined3d_gl_info *gl_info;
173 struct wined3d_context *context;
175
176 TRACE("fence %p, device %p.\n", fence, device);
177
178 if (!fence->context)
179 {
180 TRACE("Fence not issued.\n");
182 }
183 gl_info = fence->context->gl_info;
184
185 if (!(context = context_reacquire(device, fence->context)))
186 {
187 /* A glFinish does not reliably wait for draws in other contexts. The caller has
188 * to find its own way to cope with the thread switch
189 */
190 if (!gl_info->supported[ARB_SYNC])
191 {
192 WARN("Fence finished from wrong thread.\n");
194 }
196 }
197 gl_info = context->gl_info;
198
199 if (gl_info->supported[ARB_SYNC])
200 {
201 /* Timeouts near 0xffffffffffffffff may immediately return GL_TIMEOUT_EXPIRED,
202 * possibly because macOS internally adds some slop to the timer. To avoid this,
203 * we use a large number that isn't near the point of overflow (macOS 10.12.5).
204 */
205 GLenum gl_ret = GL_EXTCALL(glClientWaitSync(fence->object.sync,
207 checkGLcall("glClientWaitSync");
208
209 switch (gl_ret)
210 {
214 break;
215
216 /* We don't expect a timeout for a ~292 year wait */
217 default:
218 ERR("glClientWaitSync returned %#x.\n", gl_ret);
220 }
221 }
222 else if (context->gl_info->supported[APPLE_FENCE])
223 {
224 GL_EXTCALL(glFinishFenceAPPLE(fence->object.id));
225 checkGLcall("glFinishFenceAPPLE");
227 }
228 else if (context->gl_info->supported[NV_FENCE])
229 {
230 GL_EXTCALL(glFinishFenceNV(fence->object.id));
231 checkGLcall("glFinishFenceNV");
233 }
234 else
235 {
236 ERR("Fence created without GL support.\n");
238 }
239
241 return ret;
242}

Referenced by buffer_sync_apple().

◆ wined3d_occlusion_query_create()

static HRESULT wined3d_occlusion_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

Definition at line 1005 of file query.c.

1008{
1009 const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
1011
1012 TRACE("device %p, type %#x, parent %p, parent_ops %p, query %p.\n",
1013 device, type, parent, parent_ops, query);
1014
1015 if (!gl_info->supported[ARB_OCCLUSION_QUERY])
1016 {
1017 WARN("Unsupported in local OpenGL implementation: ARB_OCCLUSION_QUERY.\n");
1019 }
1020
1021 if (!(object = heap_alloc_zero(sizeof(*object))))
1022 return E_OUTOFMEMORY;
1023
1024 wined3d_query_init(&object->query, device, type, &object->samples,
1025 sizeof(object->samples), &occlusion_query_ops, parent, parent_ops);
1026
1027 TRACE("Created query %p.\n", object);
1028 *query = &object->query;
1029
1030 return WINED3D_OK;
1031}
static const struct wined3d_query_ops occlusion_query_ops
Definition: query.c:998
@ ARB_OCCLUSION_QUERY
Definition: wined3d_gl.h:86

Referenced by wined3d_query_create().

◆ wined3d_occlusion_query_from_query()

static struct wined3d_occlusion_query * wined3d_occlusion_query_from_query ( struct wined3d_query query)
static

◆ wined3d_occlusion_query_ops_destroy()

static void wined3d_occlusion_query_ops_destroy ( struct wined3d_query query)
static

Definition at line 989 of file query.c.

990{
992
993 if (oq->context)
995 heap_free(oq);
996}
void context_free_occlusion_query(struct wined3d_occlusion_query *query)
Definition: context.c:844
static struct wined3d_occlusion_query * wined3d_occlusion_query_from_query(struct wined3d_query *query)
Definition: query.c:65
struct wined3d_context * context

◆ wined3d_occlusion_query_ops_issue()

static BOOL wined3d_occlusion_query_ops_issue ( struct wined3d_query query,
DWORD  flags 
)
static

Definition at line 525 of file query.c.

526{
528 struct wined3d_device *device = query->device;
529 const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
530 struct wined3d_context *context;
531 BOOL poll = FALSE;
532
533 TRACE("query %p, flags %#x.\n", query, flags);
534
535 /* This is allowed according to MSDN and our tests. Reset the query and
536 * restart. */
538 {
539 if (oq->started)
540 {
542 {
543 GL_EXTCALL(glEndQuery(GL_SAMPLES_PASSED));
544 checkGLcall("glEndQuery()");
545 }
546 else
547 {
548 FIXME("Wrong thread, can't restart query.\n");
552 }
553 }
554 else
555 {
556 if (oq->context)
560 }
561
562 GL_EXTCALL(glBeginQuery(GL_SAMPLES_PASSED, oq->id));
563 checkGLcall("glBeginQuery()");
564
566 oq->started = TRUE;
567 }
569 {
570 /* MSDN says END on a non-building occlusion query returns an error,
571 * but our tests show that it returns OK. But OpenGL doesn't like it,
572 * so avoid generating an error. */
573 if (oq->started)
574 {
576 {
577 GL_EXTCALL(glEndQuery(GL_SAMPLES_PASSED));
578 checkGLcall("glEndQuery()");
579
581 poll = TRUE;
582 }
583 else
584 {
585 FIXME("Wrong thread, can't end query.\n");
586 }
587 }
588 oq->started = FALSE;
589 }
590
591 return poll;
592}
void context_alloc_occlusion_query(struct wined3d_context *context, struct wined3d_occlusion_query *query)
Definition: context.c:816
#define GL_SAMPLES_PASSED
Definition: glext.h:356
#define poll
Definition: wintirpc.h:59

◆ wined3d_occlusion_query_ops_poll()

static BOOL wined3d_occlusion_query_ops_poll ( struct wined3d_query query,
DWORD  flags 
)
static

Definition at line 427 of file query.c.

428{
430 struct wined3d_device *device = query->device;
431 const struct wined3d_gl_info *gl_info;
432 struct wined3d_context *context;
434
435 TRACE("query %p, flags %#x.\n", query, flags);
436
438 {
439 FIXME("%p Wrong thread, returning 1.\n", query);
440 oq->samples = 1;
441 return TRUE;
442 }
443 gl_info = context->gl_info;
444
445 GL_EXTCALL(glGetQueryObjectuiv(oq->id, GL_QUERY_RESULT_AVAILABLE, &available));
446 TRACE("Available %#x.\n", available);
447
448 if (available)
449 {
451 TRACE("Returning 0x%s samples.\n", wine_dbgstr_longlong(oq->samples));
452 }
453
454 checkGLcall("poll occlusion query");
456
457 return available;
458}
static UINT64 get_query_result64(GLuint id, const struct wined3d_gl_info *gl_info)
Definition: query.c:28
static WCHAR available[MAX_STRING_RESOURCE_LEN]
Definition: object.c:2336
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
#define GL_QUERY_RESULT_AVAILABLE
Definition: glext.h:335

◆ wined3d_overflow_query_create()

static HRESULT wined3d_overflow_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

Definition at line 1273 of file query.c.

1276{
1277 static const BOOL overflow = FALSE;
1278 struct wined3d_query *object;
1279
1280 FIXME("device %p, type %#x, parent %p, query %p.\n", device, type, parent, query);
1281
1282 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1283 return E_OUTOFMEMORY;
1284
1285 wined3d_query_init(object, device, type, &overflow,
1286 sizeof(overflow), &overflow_query_ops, parent, parent_ops);
1287
1288 TRACE("Created query %p.\n", object);
1289 *query = object;
1290
1291 return WINED3D_OK;
1292}
static const struct wined3d_query_ops overflow_query_ops
Definition: query.c:1266
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
const struct wined3d_parent_ops * parent_ops

Referenced by wined3d_query_create().

◆ wined3d_overflow_query_ops_destroy()

static void wined3d_overflow_query_ops_destroy ( struct wined3d_query query)
static

Definition at line 1261 of file query.c.

1262{
1264}
#define HeapFree(x, y, z)
Definition: compat.h:735

◆ wined3d_overflow_query_ops_issue()

static BOOL wined3d_overflow_query_ops_issue ( struct wined3d_query query,
DWORD  flags 
)
static

Definition at line 937 of file query.c.

938{
939 FIXME("query %p, flags %#x.\n", query, flags);
940
941 return FALSE;
942}

◆ wined3d_overflow_query_ops_poll()

static BOOL wined3d_overflow_query_ops_poll ( struct wined3d_query query,
DWORD  flags 
)
static

Definition at line 930 of file query.c.

931{
932 TRACE("query %p, flags %#x.\n", query, flags);
933
934 return TRUE;
935}

◆ wined3d_pipeline_query_create()

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

Definition at line 1200 of file query.c.

1203{
1204 const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
1206
1207 TRACE("device %p, type %#x, parent %p, parent_ops %p, query %p.\n",
1208 device, type, parent, parent_ops, query);
1209
1211 {
1212 WARN("OpenGL implementation does not support pipeline statistics queries.\n");
1214 }
1215
1216 if (!(object = heap_alloc_zero(sizeof(*object))))
1217 return E_OUTOFMEMORY;
1218
1219 wined3d_query_init(&object->query, device, type, &object->statistics,
1220 sizeof(object->statistics), &pipeline_query_ops, parent, parent_ops);
1221
1222 TRACE("Created query %p.\n", object);
1223 *query = &object->query;
1224
1225 return WINED3D_OK;
1226}
static const struct wined3d_query_ops pipeline_query_ops
Definition: query.c:1193
@ ARB_PIPELINE_STATISTICS_QUERY
Definition: wined3d_gl.h:87

Referenced by wined3d_query_create().

◆ wined3d_pipeline_query_ops_destroy()

static void wined3d_pipeline_query_ops_destroy ( struct wined3d_query query)
static

Definition at line 1185 of file query.c.

1186{
1188 if (pq->context)
1190 heap_free(pq);
1191}
void context_free_pipeline_statistics_query(struct wined3d_pipeline_statistics_query *query)
Definition: context.c:1021
static struct wined3d_pipeline_statistics_query * wined3d_pipeline_statistics_query_from_query(struct wined3d_query *query)
Definition: query.c:80
struct wined3d_context * context

◆ wined3d_pipeline_query_ops_issue()

static BOOL wined3d_pipeline_query_ops_issue ( struct wined3d_query query,
DWORD  flags 
)
static

Definition at line 845 of file query.c.

846{
848 struct wined3d_device *device = query->device;
849 const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
850 struct wined3d_context *context;
851 BOOL poll = FALSE;
852
853 TRACE("query %p, flags %#x.\n", query, flags);
854
856 {
857 if (pq->started)
858 {
860 {
862 }
863 else
864 {
865 FIXME("Wrong thread, can't restart query.\n");
869 }
870 }
871 else
872 {
873 if (pq->context)
877 }
878
879 GL_EXTCALL(glBeginQuery(GL_VERTICES_SUBMITTED_ARB, pq->u.query.vertices));
880 GL_EXTCALL(glBeginQuery(GL_PRIMITIVES_SUBMITTED_ARB, pq->u.query.primitives));
881 GL_EXTCALL(glBeginQuery(GL_VERTEX_SHADER_INVOCATIONS_ARB, pq->u.query.vertex_shader));
882 GL_EXTCALL(glBeginQuery(GL_TESS_CONTROL_SHADER_PATCHES_ARB, pq->u.query.tess_control_shader));
883 GL_EXTCALL(glBeginQuery(GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB, pq->u.query.tess_eval_shader));
884 GL_EXTCALL(glBeginQuery(GL_GEOMETRY_SHADER_INVOCATIONS, pq->u.query.geometry_shader));
885 GL_EXTCALL(glBeginQuery(GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB, pq->u.query.geometry_primitives));
886 GL_EXTCALL(glBeginQuery(GL_FRAGMENT_SHADER_INVOCATIONS_ARB, pq->u.query.fragment_shader));
887 GL_EXTCALL(glBeginQuery(GL_COMPUTE_SHADER_INVOCATIONS_ARB, pq->u.query.compute_shader));
888 GL_EXTCALL(glBeginQuery(GL_CLIPPING_INPUT_PRIMITIVES_ARB, pq->u.query.clipping_input));
889 GL_EXTCALL(glBeginQuery(GL_CLIPPING_OUTPUT_PRIMITIVES_ARB, pq->u.query.clipping_output));
890 checkGLcall("begin query");
891
893 pq->started = TRUE;
894 }
896 {
897 if (pq->started)
898 {
900 {
903 poll = TRUE;
904 }
905 else
906 {
907 FIXME("Wrong thread, can't end query.\n");
908 }
909 }
910 pq->started = FALSE;
911 }
912
913 return poll;
914}
void context_alloc_pipeline_statistics_query(struct wined3d_context *context, struct wined3d_pipeline_statistics_query *query)
Definition: context.c:1002
static void wined3d_pipeline_statistics_query_end(struct wined3d_pipeline_statistics_query *query, struct wined3d_context *context)
Definition: query.c:826
#define GL_GEOMETRY_SHADER_INVOCATIONS
Definition: glext.h:2051
union wined3d_gl_pipeline_statistics_query u
struct wined3d_gl_pipeline_statistics_query::@285 query
#define GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB
Definition: wgl.h:4077
#define GL_PRIMITIVES_SUBMITTED_ARB
Definition: wgl.h:3174
#define GL_CLIPPING_INPUT_PRIMITIVES_ARB
Definition: wgl.h:400
#define GL_VERTEX_SHADER_INVOCATIONS_ARB
Definition: wgl.h:4831
#define GL_CLIPPING_OUTPUT_PRIMITIVES_ARB
Definition: wgl.h:402
#define GL_COMPUTE_SHADER_INVOCATIONS_ARB
Definition: wgl.h:692
#define GL_VERTICES_SUBMITTED_ARB
Definition: wgl.h:4857
#define GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB
Definition: wgl.h:1562
#define GL_TESS_CONTROL_SHADER_PATCHES_ARB
Definition: wgl.h:4068
#define GL_FRAGMENT_SHADER_INVOCATIONS_ARB
Definition: wgl.h:1450

◆ wined3d_pipeline_query_ops_poll()

static BOOL wined3d_pipeline_query_ops_poll ( struct wined3d_query query,
DWORD  flags 
)
static

Definition at line 780 of file query.c.

781{
783 struct wined3d_device *device = query->device;
784 const struct wined3d_gl_info *gl_info;
785 struct wined3d_context *context;
787 int i;
788
789 TRACE("query %p, flags %#x.\n", query, flags);
790
792 {
793 FIXME("%p Wrong thread.\n", query);
794 memset(&pq->statistics, 0, sizeof(pq->statistics));
795 return TRUE;
796 }
797 gl_info = context->gl_info;
798
799 for (i = 0; i < ARRAY_SIZE(pq->u.id); ++i)
800 {
801 GL_EXTCALL(glGetQueryObjectuiv(pq->u.id[i], GL_QUERY_RESULT_AVAILABLE, &available));
802 if (!available)
803 break;
804 }
805
806 if (available)
807 {
808 pq->statistics.vertices_submitted = get_query_result64(pq->u.query.vertices, gl_info);
809 pq->statistics.primitives_submitted = get_query_result64(pq->u.query.primitives, gl_info);
810 pq->statistics.vs_invocations = get_query_result64(pq->u.query.vertex_shader, gl_info);
811 pq->statistics.hs_invocations = get_query_result64(pq->u.query.tess_control_shader, gl_info);
812 pq->statistics.ds_invocations = get_query_result64(pq->u.query.tess_eval_shader, gl_info);
813 pq->statistics.gs_invocations = get_query_result64(pq->u.query.geometry_shader, gl_info);
814 pq->statistics.gs_primitives = get_query_result64(pq->u.query.geometry_primitives, gl_info);
815 pq->statistics.ps_invocations = get_query_result64(pq->u.query.fragment_shader, gl_info);
816 pq->statistics.cs_invocations = get_query_result64(pq->u.query.compute_shader, gl_info);
817 pq->statistics.clipping_input_primitives = get_query_result64(pq->u.query.clipping_input, gl_info);
818 pq->statistics.clipping_output_primitives = get_query_result64(pq->u.query.clipping_output, gl_info);
819 }
820
821 checkGLcall("poll pipeline statistics query");
823 return available;
824}
#define ARRAY_SIZE(A)
Definition: main.h:33
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define memset(x, y, z)
Definition: compat.h:39
struct wined3d_query_data_pipeline_statistics statistics

◆ wined3d_pipeline_statistics_query_end()

static void wined3d_pipeline_statistics_query_end ( struct wined3d_pipeline_statistics_query query,
struct wined3d_context context 
)
static

◆ wined3d_pipeline_statistics_query_from_query()

static struct wined3d_pipeline_statistics_query * wined3d_pipeline_statistics_query_from_query ( struct wined3d_query query)
static

◆ wined3d_query_create()

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 
)

Definition at line 1294 of file query.c.

1296{
1297 TRACE("device %p, type %#x, parent %p, parent_ops %p, query %p.\n",
1298 device, type, parent, parent_ops, query);
1299
1300 switch (type)
1301 {
1303 return wined3d_event_query_create(device, type, parent, parent_ops, query);
1304
1306 return wined3d_occlusion_query_create(device, type, parent, parent_ops, query);
1307
1309 return wined3d_timestamp_query_create(device, type, parent, parent_ops, query);
1310
1314
1320
1322 return wined3d_pipeline_query_create(device, type, parent, parent_ops, query);
1323
1326
1328 return wined3d_overflow_query_create(device, type, parent, parent_ops, query);
1329
1330 default:
1331 FIXME("Unhandled query type %#x.\n", type);
1333 }
1334}
static HRESULT wined3d_timestamp_disjoint_query_create(struct wined3d_device *device, enum wined3d_query_type type, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query)
Definition: query.c:1089
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)
Definition: query.c:1200
static HRESULT wined3d_statistics_query_create(struct wined3d_device *device, enum wined3d_query_type type, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query)
Definition: query.c:1240
static HRESULT wined3d_timestamp_query_create(struct wined3d_device *device, enum wined3d_query_type type, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query)
Definition: query.c:1049
static HRESULT wined3d_overflow_query_create(struct wined3d_device *device, enum wined3d_query_type type, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query)
Definition: query.c:1273
static HRESULT wined3d_so_statistics_query_create(struct wined3d_device *device, enum wined3d_query_type type, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query)
Definition: query.c:1145
static HRESULT wined3d_event_query_create(struct wined3d_device *device, enum wined3d_query_type type, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query)
Definition: query.c:959
static HRESULT wined3d_occlusion_query_create(struct wined3d_device *device, enum wined3d_query_type type, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query)
Definition: query.c:1005
@ WINED3D_QUERY_TYPE_TIMESTAMP_FREQ
Definition: wined3d.h:713
@ WINED3D_QUERY_TYPE_SO_STATISTICS_STREAM2
Definition: wined3d.h:726
@ WINED3D_QUERY_TYPE_SO_STATISTICS
Definition: wined3d.h:722
@ WINED3D_QUERY_TYPE_PIPELINE_STATISTICS
Definition: wined3d.h:721
@ WINED3D_QUERY_TYPE_SO_STATISTICS_STREAM0
Definition: wined3d.h:724
@ WINED3D_QUERY_TYPE_SO_STATISTICS_STREAM1
Definition: wined3d.h:725
@ WINED3D_QUERY_TYPE_TIMESTAMP
Definition: wined3d.h:711
@ WINED3D_QUERY_TYPE_SO_OVERFLOW
Definition: wined3d.h:723
@ WINED3D_QUERY_TYPE_EVENT
Definition: wined3d.h:709
@ WINED3D_QUERY_TYPE_TIMESTAMP_DISJOINT
Definition: wined3d.h:712
@ WINED3D_QUERY_TYPE_OCCLUSION
Definition: wined3d.h:710
@ WINED3D_QUERY_TYPE_SO_STATISTICS_STREAM3
Definition: wined3d.h:727

Referenced by query_init().

◆ wined3d_query_decref()

ULONG CDECL wined3d_query_decref ( struct wined3d_query query)

Definition at line 349 of file query.c.

350{
351 ULONG refcount = InterlockedDecrement(&query->ref);
352
353 TRACE("%p decreasing refcount to %u.\n", query, refcount);
354
355 if (!refcount)
356 {
357 query->parent_ops->wined3d_object_destroyed(query->parent);
359 }
360
361 return refcount;
362}
#define InterlockedDecrement
Definition: armddk.h:52
void wined3d_cs_destroy_object(struct wined3d_cs *cs, void(*callback)(void *object), void *object)
Definition: cs.c:1885
static void wined3d_query_destroy_object(void *object)
Definition: query.c:335
uint32_t ULONG
Definition: typedefs.h:59

Referenced by d3d9_query_Release(), and wined3d_device_set_predication().

◆ wined3d_query_destroy_object()

static void wined3d_query_destroy_object ( void object)
static

Definition at line 335 of file query.c.

336{
337 struct wined3d_query *query = object;
338
339 if (!list_empty(&query->poll_list_entry))
340 list_remove(&query->poll_list_entry);
341
342 /* Queries are specific to the GL context that created them. Not
343 * deleting the query will obviously leak it, but that's still better
344 * than potentially deleting a different query with the same id in this
345 * context, and (still) leaking the actual query. */
346 query->query_ops->query_destroy(query);
347}
static void list_remove(struct list_entry *entry)
Definition: list.h:90
static int list_empty(struct list_entry *head)
Definition: list.h:58

Referenced by wined3d_query_decref().

◆ wined3d_query_get_data()

HRESULT CDECL wined3d_query_get_data ( struct wined3d_query query,
void data,
UINT  data_size,
DWORD  flags 
)

Definition at line 364 of file query.c.

366{
367 TRACE("query %p, data %p, data_size %u, flags %#x.\n",
368 query, data, data_size, flags);
369
370 if (flags)
371 WARN("Ignoring flags %#x.\n", flags);
372
373 if (query->state == QUERY_BUILDING)
374 {
375 WARN("Query is building, returning S_FALSE.\n");
376 return S_FALSE;
377 }
378
379 if (query->state == QUERY_CREATED)
380 {
381 WARN("Query wasn't started yet.\n");
383 }
384
385 if (!query->device->cs->thread)
386 {
387 if (!query->query_ops->query_poll(query, flags))
388 return S_FALSE;
389 }
390 else if (query->counter_main != query->counter_retrieved)
391 {
392 if (flags & WINED3DGETDATA_FLUSH && !query->device->cs->queries_flushed)
393 wined3d_cs_emit_flush(query->device->cs);
394 return S_FALSE;
395 }
396
397 if (data)
398 memcpy(data, query->data, min(data_size, query->data_size));
399
400 return S_OK;
401}
void wined3d_cs_emit_flush(struct wined3d_cs *cs)
Definition: cs.c:930
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define S_OK
Definition: intsafe.h:52
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define min(a, b)
Definition: monoChain.cc:55
HANDLE thread
Definition: pdh_main.c:145
#define WINED3DERR_INVALIDCALL
Definition: wined3d.h:48
@ QUERY_BUILDING
@ QUERY_CREATED
#define S_FALSE
Definition: winerror.h:2357

Referenced by d3d9_query_GetData().

◆ wined3d_query_get_data_size()

UINT CDECL wined3d_query_get_data_size ( const struct wined3d_query query)

Definition at line 403 of file query.c.

404{
405 TRACE("query %p.\n", query);
406
407 return query->data_size;
408}

Referenced by query_init().

◆ wined3d_query_get_parent()

void *CDECL wined3d_query_get_parent ( const struct wined3d_query query)

Definition at line 491 of file query.c.

492{
493 TRACE("query %p.\n", query);
494
495 return query->parent;
496}

◆ wined3d_query_get_type()

enum wined3d_query_type CDECL wined3d_query_get_type ( const struct wined3d_query query)

Definition at line 498 of file query.c.

499{
500 TRACE("query %p.\n", query);
501
502 return query->type;
503}

Referenced by d3d9_query_GetData(), and d3d9_query_GetType().

◆ wined3d_query_incref()

ULONG CDECL wined3d_query_incref ( struct wined3d_query query)

Definition at line 326 of file query.c.

327{
328 ULONG refcount = InterlockedIncrement(&query->ref);
329
330 TRACE("%p increasing refcount to %u.\n", query, refcount);
331
332 return refcount;
333}
#define InterlockedIncrement
Definition: armddk.h:53

Referenced by wined3d_device_set_predication().

◆ wined3d_query_init()

static void wined3d_query_init ( struct wined3d_query query,
struct wined3d_device device,
enum wined3d_query_type  type,
const void data,
DWORD  data_size,
const struct wined3d_query_ops query_ops,
void parent,
const struct wined3d_parent_ops parent_ops 
)
static

Definition at line 44 of file query.c.

47{
48 query->ref = 1;
49 query->parent = parent;
50 query->parent_ops = parent_ops;
51 query->device = device;
52 query->state = QUERY_CREATED;
53 query->type = type;
54 query->data = data;
55 query->data_size = data_size;
56 query->query_ops = query_ops;
57 list_init(&query->poll_list_entry);
58}
static void list_init(struct list_entry *head)
Definition: list.h:51

Referenced by wined3d_event_query_create(), wined3d_occlusion_query_create(), wined3d_overflow_query_create(), wined3d_pipeline_query_create(), wined3d_so_statistics_query_create(), wined3d_statistics_query_create(), wined3d_timestamp_disjoint_query_create(), and wined3d_timestamp_query_create().

◆ wined3d_query_issue()

HRESULT CDECL wined3d_query_issue ( struct wined3d_query query,
DWORD  flags 
)

Definition at line 410 of file query.c.

411{
412 TRACE("query %p, flags %#x.\n", query, flags);
413
415 ++query->counter_main;
416
418
420 query->state = QUERY_BUILDING;
421 else
422 query->state = QUERY_SIGNALLED;
423
424 return WINED3D_OK;
425}
void wined3d_cs_emit_query_issue(struct wined3d_cs *cs, struct wined3d_query *query, DWORD flags)
Definition: cs.c:1934
@ QUERY_SIGNALLED

Referenced by d3d9_query_Issue().

◆ wined3d_so_statistics_query_create()

static HRESULT wined3d_so_statistics_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

Definition at line 1145 of file query.c.

1148{
1149 const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
1151 unsigned int stream_idx;
1152
1155 else
1157
1158 TRACE("device %p, type %#x, parent %p, parent_ops %p, query %p.\n",
1159 device, type, parent, parent_ops, query);
1160
1162 {
1163 WARN("OpenGL implementation does not support primitive queries.\n");
1165 }
1166 if (!gl_info->supported[ARB_TRANSFORM_FEEDBACK3])
1167 {
1168 WARN("OpenGL implementation does not support indexed queries.\n");
1170 }
1171
1172 if (!(object = heap_alloc_zero(sizeof(*object))))
1173 return E_OUTOFMEMORY;
1174
1175 wined3d_query_init(&object->query, device, type, &object->statistics,
1176 sizeof(object->statistics), &so_statistics_query_ops, parent, parent_ops);
1177 object->stream_idx = stream_idx;
1178
1179 TRACE("Created query %p.\n", object);
1180 *query = &object->query;
1181
1182 return WINED3D_OK;
1183}
static const struct wined3d_query_ops so_statistics_query_ops
Definition: query.c:1138
@ WINED3D_GL_PRIMITIVE_QUERY
Definition: wined3d_gl.h:215
@ ARB_TRANSFORM_FEEDBACK3
Definition: wined3d_gl.h:134

Referenced by wined3d_query_create().

◆ wined3d_so_statistics_query_from_query()

static struct wined3d_so_statistics_query * wined3d_so_statistics_query_from_query ( struct wined3d_query query)
static

◆ wined3d_so_statistics_query_ops_destroy()

static void wined3d_so_statistics_query_ops_destroy ( struct wined3d_query query)
static

Definition at line 1129 of file query.c.

1130{
1132
1133 if (pq->context)
1135 heap_free(pq);
1136}
void context_free_so_statistics_query(struct wined3d_so_statistics_query *query)
Definition: context.c:983
static struct wined3d_so_statistics_query * wined3d_so_statistics_query_from_query(struct wined3d_query *query)
Definition: query.c:75
struct wined3d_context * context

◆ wined3d_so_statistics_query_ops_issue()

static BOOL wined3d_so_statistics_query_ops_issue ( struct wined3d_query query,
DWORD  flags 
)
static

Definition at line 712 of file query.c.

713{
715 struct wined3d_device *device = query->device;
716 const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
717 struct wined3d_context *context;
718 BOOL poll = FALSE;
719
720 TRACE("query %p, flags %#x.\n", query, flags);
721
723 {
724 if (pq->started)
725 {
727 {
729 GL_EXTCALL(glEndQueryIndexed(GL_PRIMITIVES_GENERATED, pq->stream_idx));
730 }
731 else
732 {
733 FIXME("Wrong thread, can't restart query.\n");
737 }
738 }
739 else
740 {
741 if (pq->context)
745 }
746
748 pq->stream_idx, pq->u.query.written));
749 GL_EXTCALL(glBeginQueryIndexed(GL_PRIMITIVES_GENERATED,
750 pq->stream_idx, pq->u.query.generated));
751 checkGLcall("begin query");
752
754 pq->started = TRUE;
755 }
757 {
758 if (pq->started)
759 {
761 {
763 GL_EXTCALL(glEndQueryIndexed(GL_PRIMITIVES_GENERATED, pq->stream_idx));
764 checkGLcall("end query");
765
767 poll = TRUE;
768 }
769 else
770 {
771 FIXME("Wrong thread, can't end query.\n");
772 }
773 }
774 pq->started = FALSE;
775 }
776
777 return poll;
778}
void context_alloc_so_statistics_query(struct wined3d_context *context, struct wined3d_so_statistics_query *query)
Definition: context.c:961
#define GL_PRIMITIVES_GENERATED
Definition: glext.h:550
#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN
Definition: glext.h:551
union wined3d_gl_so_statistics_query u
struct wined3d_gl_so_statistics_query::@284 query

◆ wined3d_so_statistics_query_ops_poll()

static BOOL wined3d_so_statistics_query_ops_poll ( struct wined3d_query query,
DWORD  flags 
)
static

Definition at line 673 of file query.c.

674{
676 struct wined3d_device *device = query->device;
677 GLuint written_available, generated_available;
678 const struct wined3d_gl_info *gl_info;
679 struct wined3d_context *context;
680
681 TRACE("query %p, flags %#x.\n", query, flags);
682
684 {
685 FIXME("%p Wrong thread, returning 0 primitives.\n", query);
686 memset(&pq->statistics, 0, sizeof(pq->statistics));
687 return TRUE;
688 }
689 gl_info = context->gl_info;
690
691 GL_EXTCALL(glGetQueryObjectuiv(pq->u.query.written,
692 GL_QUERY_RESULT_AVAILABLE, &written_available));
693 GL_EXTCALL(glGetQueryObjectuiv(pq->u.query.generated,
694 GL_QUERY_RESULT_AVAILABLE, &generated_available));
695 TRACE("Available %#x, %#x.\n", written_available, generated_available);
696
697 if (written_available && generated_available)
698 {
699 pq->statistics.primitives_written = get_query_result64(pq->u.query.written, gl_info);
700 pq->statistics.primitives_generated = get_query_result64(pq->u.query.generated, gl_info);
701 TRACE("Returning %s, %s primitives.\n",
702 wine_dbgstr_longlong(pq->statistics.primitives_written),
703 wine_dbgstr_longlong(pq->statistics.primitives_generated));
704 }
705
706 checkGLcall("poll SO statistics query");
708
709 return written_available && generated_available;
710}
struct wined3d_query_data_so_statistics statistics

◆ wined3d_statistics_query_create()

static HRESULT wined3d_statistics_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

Definition at line 1240 of file query.c.

1243{
1244 static const struct wined3d_query_data_so_statistics statistics = { 1, 1 };
1245 struct wined3d_query *object;
1246
1247 FIXME("device %p, type %#x, parent %p, query %p.\n", device, type, parent, query);
1248
1249 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1250 return E_OUTOFMEMORY;
1251
1252 wined3d_query_init(object, device, type, &statistics,
1253 sizeof(statistics), &statistics_query_ops, parent, parent_ops);
1254
1255 TRACE("Created query %p.\n", object);
1256 *query = object;
1257
1258 return WINED3D_OK;
1259}
static const struct wined3d_query_ops statistics_query_ops
Definition: query.c:1233

Referenced by wined3d_query_create().

◆ wined3d_statistics_query_ops_destroy()

static void wined3d_statistics_query_ops_destroy ( struct wined3d_query query)
static

Definition at line 1228 of file query.c.

1229{
1231}

◆ wined3d_statistics_query_ops_issue()

static BOOL wined3d_statistics_query_ops_issue ( struct wined3d_query query,
DWORD  flags 
)
static

Definition at line 923 of file query.c.

924{
925 FIXME("query %p, flags %#x.\n", query, flags);
926
927 return FALSE;
928}

◆ wined3d_statistics_query_ops_poll()

static BOOL wined3d_statistics_query_ops_poll ( struct wined3d_query query,
DWORD  flags 
)
static

Definition at line 916 of file query.c.

917{
918 TRACE("query %p, flags %#x.\n", query, flags);
919
920 return TRUE;
921}

◆ wined3d_timestamp_disjoint_query_create()

static HRESULT wined3d_timestamp_disjoint_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

Definition at line 1089 of file query.c.

1092{
1093 const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
1094 struct wined3d_query *object;
1095
1096 TRACE("device %p, type %#x, parent %p, parent_ops %p, query %p.\n",
1098
1099 if (!gl_info->supported[ARB_TIMER_QUERY])
1100 {
1101 WARN("Unsupported in local OpenGL implementation: ARB_TIMER_QUERY.\n");
1103 }
1104
1105 if (!(object = heap_alloc_zero(sizeof(*object))))
1106 return E_OUTOFMEMORY;
1107
1109 {
1110 static const struct wined3d_query_data_timestamp_disjoint disjoint_data = {1000 * 1000 * 1000, FALSE};
1111
1112 wined3d_query_init(object, device, type, &disjoint_data,
1113 sizeof(disjoint_data), &timestamp_disjoint_query_ops, parent, parent_ops);
1114 }
1115 else
1116 {
1117 static const UINT64 freq = 1000 * 1000 * 1000;
1118
1119 wined3d_query_init(object, device, type, &freq,
1120 sizeof(freq), &timestamp_disjoint_query_ops, parent, parent_ops);
1121 }
1122
1123 TRACE("Created query %p.\n", object);
1124 *query = object;
1125
1126 return WINED3D_OK;
1127}
unsigned long long UINT64
static const struct wined3d_query_ops timestamp_disjoint_query_ops
Definition: query.c:1082

Referenced by wined3d_query_create().

◆ wined3d_timestamp_disjoint_query_ops_destroy()

static void wined3d_timestamp_disjoint_query_ops_destroy ( struct wined3d_query query)
static

Definition at line 1077 of file query.c.

1078{
1080}

◆ wined3d_timestamp_disjoint_query_ops_issue()

static BOOL wined3d_timestamp_disjoint_query_ops_issue ( struct wined3d_query query,
DWORD  flags 
)
static

Definition at line 666 of file query.c.

667{
668 TRACE("query %p, flags %#x.\n", query, flags);
669
670 return FALSE;
671}

◆ wined3d_timestamp_disjoint_query_ops_poll()

static BOOL wined3d_timestamp_disjoint_query_ops_poll ( struct wined3d_query query,
DWORD  flags 
)
static

Definition at line 659 of file query.c.

660{
661 TRACE("query %p, flags %#x.\n", query, flags);
662
663 return TRUE;
664}

◆ wined3d_timestamp_query_create()

static HRESULT wined3d_timestamp_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

Definition at line 1049 of file query.c.

1052{
1053 const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
1055
1056 TRACE("device %p, type %#x, parent %p, parent_ops %p, query %p.\n",
1057 device, type, parent, parent_ops, query);
1058
1059 if (!gl_info->supported[ARB_TIMER_QUERY])
1060 {
1061 WARN("Unsupported in local OpenGL implementation: ARB_TIMER_QUERY.\n");
1063 }
1064
1065 if (!(object = heap_alloc_zero(sizeof(*object))))
1066 return E_OUTOFMEMORY;
1067
1068 wined3d_query_init(&object->query, device, type, &object->timestamp,
1069 sizeof(object->timestamp), &timestamp_query_ops, parent, parent_ops);
1070
1071 TRACE("Created query %p.\n", object);
1072 *query = &object->query;
1073
1074 return WINED3D_OK;
1075}
static const struct wined3d_query_ops timestamp_query_ops
Definition: query.c:1042

Referenced by wined3d_query_create().

◆ wined3d_timestamp_query_from_query()

static struct wined3d_timestamp_query * wined3d_timestamp_query_from_query ( struct wined3d_query query)
static

◆ wined3d_timestamp_query_ops_destroy()

static void wined3d_timestamp_query_ops_destroy ( struct wined3d_query query)
static

Definition at line 1033 of file query.c.

1034{
1036
1037 if (tq->context)
1039 heap_free(tq);
1040}
void context_free_timestamp_query(struct wined3d_timestamp_query *query)
Definition: context.c:943
static struct wined3d_timestamp_query * wined3d_timestamp_query_from_query(struct wined3d_query *query)
Definition: query.c:70
struct wined3d_context * context

◆ wined3d_timestamp_query_ops_issue()

static BOOL wined3d_timestamp_query_ops_issue ( struct wined3d_query query,
DWORD  flags 
)
static

Definition at line 630 of file query.c.

631{
633 const struct wined3d_gl_info *gl_info;
634 struct wined3d_context *context;
635
636 TRACE("query %p, flags %#x.\n", query, flags);
637
639 {
640 WARN("Ignoring WINED3DISSUE_BEGIN with a TIMESTAMP query.\n");
641 }
643 {
644 if (tq->context)
646 context = context_acquire(query->device, NULL, 0);
647 gl_info = context->gl_info;
649 GL_EXTCALL(glQueryCounter(tq->id, GL_TIMESTAMP));
650 checkGLcall("glQueryCounter()");
652
653 return TRUE;
654 }
655
656 return FALSE;
657}
void context_alloc_timestamp_query(struct wined3d_context *context, struct wined3d_timestamp_query *query)
Definition: context.c:923
#define GL_TIMESTAMP
Definition: glext.h:2037

◆ wined3d_timestamp_query_ops_poll()

static BOOL wined3d_timestamp_query_ops_poll ( struct wined3d_query query,
DWORD  flags 
)
static

Definition at line 594 of file query.c.

595{
597 struct wined3d_device *device = query->device;
598 const struct wined3d_gl_info *gl_info;
599 struct wined3d_context *context;
602
603 TRACE("query %p, flags %#x.\n", query, flags);
604
606 {
607 FIXME("%p Wrong thread, returning 1.\n", query);
608 tq->timestamp = 1;
609 return TRUE;
610 }
611 gl_info = context->gl_info;
612
613 GL_EXTCALL(glGetQueryObjectuiv(tq->id, GL_QUERY_RESULT_AVAILABLE, &available));
614 checkGLcall("glGetQueryObjectuiv(GL_QUERY_RESULT_AVAILABLE)");
615 TRACE("available %#x.\n", available);
616
617 if (available)
618 {
619 GL_EXTCALL(glGetQueryObjectui64v(tq->id, GL_QUERY_RESULT, &timestamp));
620 checkGLcall("glGetQueryObjectui64v(GL_QUERY_RESULT)");
621 TRACE("Returning timestamp %s.\n", wine_dbgstr_longlong(timestamp));
622 tq->timestamp = timestamp;
623 }
624
626
627 return available;
628}

Variable Documentation

◆ event_query_ops

const struct wined3d_query_ops event_query_ops
static
Initial value:
=
{
}
static BOOL wined3d_event_query_ops_poll(struct wined3d_query *query, DWORD flags)
Definition: query.c:460
static BOOL wined3d_event_query_ops_issue(struct wined3d_query *query, DWORD flags)
Definition: query.c:505
static void wined3d_event_query_ops_destroy(struct wined3d_query *query)
Definition: query.c:944

Definition at line 952 of file query.c.

Referenced by wined3d_event_query_create().

◆ occlusion_query_ops

const struct wined3d_query_ops occlusion_query_ops
static
Initial value:
=
{
}
static void wined3d_occlusion_query_ops_destroy(struct wined3d_query *query)
Definition: query.c:989
static BOOL wined3d_occlusion_query_ops_poll(struct wined3d_query *query, DWORD flags)
Definition: query.c:427
static BOOL wined3d_occlusion_query_ops_issue(struct wined3d_query *query, DWORD flags)
Definition: query.c:525

Definition at line 998 of file query.c.

Referenced by wined3d_occlusion_query_create().

◆ overflow_query_ops

const struct wined3d_query_ops overflow_query_ops
static
Initial value:
=
{
}
static BOOL wined3d_overflow_query_ops_poll(struct wined3d_query *query, DWORD flags)
Definition: query.c:930
static BOOL wined3d_overflow_query_ops_issue(struct wined3d_query *query, DWORD flags)
Definition: query.c:937
static void wined3d_overflow_query_ops_destroy(struct wined3d_query *query)
Definition: query.c:1261

Definition at line 1266 of file query.c.

Referenced by wined3d_overflow_query_create().

◆ pipeline_query_ops

const struct wined3d_query_ops pipeline_query_ops
static
Initial value:
=
{
}
static void wined3d_pipeline_query_ops_destroy(struct wined3d_query *query)
Definition: query.c:1185
static BOOL wined3d_pipeline_query_ops_issue(struct wined3d_query *query, DWORD flags)
Definition: query.c:845
static BOOL wined3d_pipeline_query_ops_poll(struct wined3d_query *query, DWORD flags)
Definition: query.c:780

Definition at line 1193 of file query.c.

Referenced by wined3d_pipeline_query_create().

◆ so_statistics_query_ops

const struct wined3d_query_ops so_statistics_query_ops
static
Initial value:
=
{
}
static void wined3d_so_statistics_query_ops_destroy(struct wined3d_query *query)
Definition: query.c:1129
static BOOL wined3d_so_statistics_query_ops_issue(struct wined3d_query *query, DWORD flags)
Definition: query.c:712
static BOOL wined3d_so_statistics_query_ops_poll(struct wined3d_query *query, DWORD flags)
Definition: query.c:673

Definition at line 1138 of file query.c.

Referenced by wined3d_so_statistics_query_create().

◆ statistics_query_ops

const struct wined3d_query_ops statistics_query_ops
static
Initial value:
=
{
}
static BOOL wined3d_statistics_query_ops_poll(struct wined3d_query *query, DWORD flags)
Definition: query.c:916
static void wined3d_statistics_query_ops_destroy(struct wined3d_query *query)
Definition: query.c:1228
static BOOL wined3d_statistics_query_ops_issue(struct wined3d_query *query, DWORD flags)
Definition: query.c:923

Definition at line 1233 of file query.c.

Referenced by wined3d_statistics_query_create().

◆ timestamp_disjoint_query_ops

const struct wined3d_query_ops timestamp_disjoint_query_ops
static
Initial value:
=
{
}
static BOOL wined3d_timestamp_disjoint_query_ops_poll(struct wined3d_query *query, DWORD flags)
Definition: query.c:659
static BOOL wined3d_timestamp_disjoint_query_ops_issue(struct wined3d_query *query, DWORD flags)
Definition: query.c:666
static void wined3d_timestamp_disjoint_query_ops_destroy(struct wined3d_query *query)
Definition: query.c:1077

Definition at line 1082 of file query.c.

Referenced by wined3d_timestamp_disjoint_query_create().

◆ timestamp_query_ops

const struct wined3d_query_ops timestamp_query_ops
static
Initial value:
=
{
}
static void wined3d_timestamp_query_ops_destroy(struct wined3d_query *query)
Definition: query.c:1033
static BOOL wined3d_timestamp_query_ops_issue(struct wined3d_query *query, DWORD flags)
Definition: query.c:630
static BOOL wined3d_timestamp_query_ops_poll(struct wined3d_query *query, DWORD flags)
Definition: query.c:594

Definition at line 1042 of file query.c.

Referenced by wined3d_timestamp_query_create().