2005-03-03 14:57:15 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2005 Oliver Stieber
|
2008-10-18 19:21:20 +02:00
|
|
|
* Copyright 2007-2008 Stefan Dösinger for CodeWeavers
|
2010-11-18 20:50:40 +01:00
|
|
|
* Copyright 2009-2010 Henri Verbeet for CodeWeavers.
|
2005-03-03 14:57:15 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-03-03 14:57:15 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
2012-06-01 16:56:21 +02:00
|
|
|
#include "wine/port.h"
|
2005-03-03 14:57:15 +01:00
|
|
|
#include "wined3d_private.h"
|
|
|
|
|
2010-03-03 22:45:34 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
|
|
|
|
|
2017-06-05 00:47:37 +02:00
|
|
|
static UINT64 get_query_result64(GLuint id, const struct wined3d_gl_info *gl_info)
|
|
|
|
{
|
|
|
|
if (gl_info->supported[ARB_TIMER_QUERY])
|
|
|
|
{
|
|
|
|
GLuint64 result;
|
|
|
|
GL_EXTCALL(glGetQueryObjectui64v(id, GL_QUERY_RESULT, &result));
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GLuint result;
|
|
|
|
GL_EXTCALL(glGetQueryObjectuiv(id, GL_QUERY_RESULT, &result));
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-22 00:43:48 +02:00
|
|
|
static void wined3d_query_init(struct wined3d_query *query, struct wined3d_device *device,
|
2016-07-28 13:29:41 +02:00
|
|
|
enum wined3d_query_type type, const void *data, DWORD data_size,
|
2017-05-10 15:54:07 +02:00
|
|
|
const struct wined3d_query_ops *query_ops, void *parent, const struct wined3d_parent_ops *parent_ops)
|
2016-07-22 00:43:48 +02:00
|
|
|
{
|
|
|
|
query->ref = 1;
|
|
|
|
query->parent = parent;
|
2017-05-10 15:54:07 +02:00
|
|
|
query->parent_ops = parent_ops;
|
2016-07-22 00:43:48 +02:00
|
|
|
query->device = device;
|
|
|
|
query->state = QUERY_CREATED;
|
|
|
|
query->type = type;
|
2016-07-28 13:29:41 +02:00
|
|
|
query->data = data;
|
2016-07-22 00:43:48 +02:00
|
|
|
query->data_size = data_size;
|
|
|
|
query->query_ops = query_ops;
|
2017-04-13 00:11:01 +02:00
|
|
|
list_init(&query->poll_list_entry);
|
2016-07-22 00:43:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct wined3d_event_query *wined3d_event_query_from_query(struct wined3d_query *query)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(query, struct wined3d_event_query, query);
|
|
|
|
}
|
|
|
|
|
2016-07-22 00:43:49 +02:00
|
|
|
static struct wined3d_occlusion_query *wined3d_occlusion_query_from_query(struct wined3d_query *query)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(query, struct wined3d_occlusion_query, query);
|
|
|
|
}
|
|
|
|
|
2016-07-22 00:43:50 +02:00
|
|
|
static struct wined3d_timestamp_query *wined3d_timestamp_query_from_query(struct wined3d_query *query)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(query, struct wined3d_timestamp_query, query);
|
|
|
|
}
|
|
|
|
|
2017-05-24 17:09:59 +02:00
|
|
|
static struct wined3d_so_statistics_query *wined3d_so_statistics_query_from_query(struct wined3d_query *query)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(query, struct wined3d_so_statistics_query, query);
|
|
|
|
}
|
|
|
|
|
2017-06-05 00:47:34 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2017-07-09 13:25:49 +02:00
|
|
|
static BOOL wined3d_fence_supported(const struct wined3d_gl_info *gl_info)
|
2010-03-03 23:48:50 +01:00
|
|
|
{
|
2010-03-30 11:24:43 +02:00
|
|
|
return gl_info->supported[ARB_SYNC] || gl_info->supported[NV_FENCE] || gl_info->supported[APPLE_FENCE];
|
2010-03-03 23:48:50 +01:00
|
|
|
}
|
|
|
|
|
2017-07-09 13:25:49 +02:00
|
|
|
static enum wined3d_fence_result wined3d_fence_test(const struct wined3d_fence *fence,
|
2017-01-04 00:04:49 +01:00
|
|
|
const struct wined3d_device *device, DWORD flags)
|
2010-03-03 22:45:34 +01:00
|
|
|
{
|
|
|
|
const struct wined3d_gl_info *gl_info;
|
2017-04-05 15:38:05 +02:00
|
|
|
struct wined3d_context *context;
|
2017-07-09 13:25:49 +02:00
|
|
|
enum wined3d_fence_result ret;
|
2010-03-03 22:45:34 +01:00
|
|
|
BOOL fence_result;
|
|
|
|
|
2017-07-09 13:25:49 +02:00
|
|
|
TRACE("fence %p, device %p, flags %#x.\n", fence, device, flags);
|
2010-03-03 22:45:34 +01:00
|
|
|
|
2017-07-09 13:25:49 +02:00
|
|
|
if (!fence->context)
|
2010-03-03 22:45:34 +01:00
|
|
|
{
|
2017-07-09 13:25:49 +02:00
|
|
|
TRACE("Fence not issued.\n");
|
|
|
|
return WINED3D_FENCE_NOT_STARTED;
|
2010-03-03 22:45:34 +01:00
|
|
|
}
|
|
|
|
|
2017-07-09 13:25:49 +02:00
|
|
|
if (!(context = context_reacquire(device, fence->context)))
|
2010-03-03 22:45:34 +01:00
|
|
|
{
|
2017-07-09 13:25:49 +02:00
|
|
|
if (!fence->context->gl_info->supported[ARB_SYNC])
|
2017-04-05 15:38:05 +02:00
|
|
|
{
|
2017-07-09 13:25:49 +02:00
|
|
|
WARN("Fence tested from wrong thread.\n");
|
|
|
|
return WINED3D_FENCE_WRONG_THREAD;
|
2017-04-05 15:38:05 +02:00
|
|
|
}
|
|
|
|
context = context_acquire(device, NULL, 0);
|
2010-03-03 22:45:34 +01:00
|
|
|
}
|
|
|
|
gl_info = context->gl_info;
|
|
|
|
|
|
|
|
if (gl_info->supported[ARB_SYNC])
|
|
|
|
{
|
2017-07-09 13:25:49 +02:00
|
|
|
GLenum gl_ret = GL_EXTCALL(glClientWaitSync(fence->object.sync,
|
2017-01-04 00:04:49 +01:00
|
|
|
(flags & WINED3DGETDATA_FLUSH) ? GL_SYNC_FLUSH_COMMANDS_BIT : 0, 0));
|
2010-03-03 22:45:34 +01:00
|
|
|
checkGLcall("glClientWaitSync");
|
|
|
|
|
|
|
|
switch (gl_ret)
|
|
|
|
{
|
|
|
|
case GL_ALREADY_SIGNALED:
|
|
|
|
case GL_CONDITION_SATISFIED:
|
2017-07-09 13:25:49 +02:00
|
|
|
ret = WINED3D_FENCE_OK;
|
2010-03-03 22:45:34 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GL_TIMEOUT_EXPIRED:
|
2017-07-09 13:25:49 +02:00
|
|
|
ret = WINED3D_FENCE_WAITING;
|
2010-03-03 22:45:34 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GL_WAIT_FAILED:
|
|
|
|
default:
|
|
|
|
ERR("glClientWaitSync returned %#x.\n", gl_ret);
|
2017-07-09 13:25:49 +02:00
|
|
|
ret = WINED3D_FENCE_ERROR;
|
2010-03-03 22:45:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (gl_info->supported[APPLE_FENCE])
|
|
|
|
{
|
2017-07-09 13:25:49 +02:00
|
|
|
fence_result = GL_EXTCALL(glTestFenceAPPLE(fence->object.id));
|
2010-03-03 22:45:34 +01:00
|
|
|
checkGLcall("glTestFenceAPPLE");
|
2017-07-09 13:25:49 +02:00
|
|
|
if (fence_result)
|
|
|
|
ret = WINED3D_FENCE_OK;
|
|
|
|
else
|
|
|
|
ret = WINED3D_FENCE_WAITING;
|
2010-03-03 22:45:34 +01:00
|
|
|
}
|
|
|
|
else if (gl_info->supported[NV_FENCE])
|
|
|
|
{
|
2017-07-09 13:25:49 +02:00
|
|
|
fence_result = GL_EXTCALL(glTestFenceNV(fence->object.id));
|
2010-03-03 22:45:34 +01:00
|
|
|
checkGLcall("glTestFenceNV");
|
2017-07-09 13:25:49 +02:00
|
|
|
if (fence_result)
|
|
|
|
ret = WINED3D_FENCE_OK;
|
|
|
|
else
|
|
|
|
ret = WINED3D_FENCE_WAITING;
|
2010-03-03 22:45:34 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-07-09 13:25:49 +02:00
|
|
|
ERR("Fence created despite lack of GL support.\n");
|
|
|
|
ret = WINED3D_FENCE_ERROR;
|
2010-03-03 22:45:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
context_release(context);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-07-09 13:25:49 +02:00
|
|
|
enum wined3d_fence_result wined3d_fence_wait(const struct wined3d_fence *fence,
|
2011-10-30 18:06:35 +01:00
|
|
|
const struct wined3d_device *device)
|
2010-03-21 13:26:36 +01:00
|
|
|
{
|
|
|
|
const struct wined3d_gl_info *gl_info;
|
2017-04-05 15:38:05 +02:00
|
|
|
struct wined3d_context *context;
|
2017-07-09 13:25:49 +02:00
|
|
|
enum wined3d_fence_result ret;
|
2010-03-21 13:26:36 +01:00
|
|
|
|
2017-07-09 13:25:49 +02:00
|
|
|
TRACE("fence %p, device %p.\n", fence, device);
|
2010-03-21 13:26:36 +01:00
|
|
|
|
2017-07-09 13:25:49 +02:00
|
|
|
if (!fence->context)
|
2010-03-21 13:26:36 +01:00
|
|
|
{
|
2017-07-09 13:25:49 +02:00
|
|
|
TRACE("Fence not issued.\n");
|
|
|
|
return WINED3D_FENCE_NOT_STARTED;
|
2010-03-21 13:26:36 +01:00
|
|
|
}
|
2017-07-09 13:25:49 +02:00
|
|
|
gl_info = fence->context->gl_info;
|
2010-03-21 13:26:36 +01:00
|
|
|
|
2017-07-09 13:25:49 +02:00
|
|
|
if (!(context = context_reacquire(device, fence->context)))
|
2010-03-21 13:26:36 +01:00
|
|
|
{
|
|
|
|
/* A glFinish does not reliably wait for draws in other contexts. The caller has
|
|
|
|
* to find its own way to cope with the thread switch
|
|
|
|
*/
|
2017-04-05 15:38:05 +02:00
|
|
|
if (!gl_info->supported[ARB_SYNC])
|
|
|
|
{
|
2017-07-09 13:25:49 +02:00
|
|
|
WARN("Fence finished from wrong thread.\n");
|
|
|
|
return WINED3D_FENCE_WRONG_THREAD;
|
2017-04-05 15:38:05 +02:00
|
|
|
}
|
|
|
|
context = context_acquire(device, NULL, 0);
|
2010-03-21 13:26:36 +01:00
|
|
|
}
|
2017-04-05 15:38:05 +02:00
|
|
|
gl_info = context->gl_info;
|
2010-03-21 13:26:36 +01:00
|
|
|
|
|
|
|
if (gl_info->supported[ARB_SYNC])
|
|
|
|
{
|
2017-08-12 18:09:06 +02:00
|
|
|
/* Timeouts near 0xffffffffffffffff may immediately return GL_TIMEOUT_EXPIRED,
|
|
|
|
* possibly because macOS internally adds some slop to the timer. To avoid this,
|
|
|
|
* we use a large number that isn't near the point of overflow (macOS 10.12.5).
|
|
|
|
*/
|
2017-07-09 13:25:49 +02:00
|
|
|
GLenum gl_ret = GL_EXTCALL(glClientWaitSync(fence->object.sync,
|
2017-08-12 18:09:06 +02:00
|
|
|
GL_SYNC_FLUSH_COMMANDS_BIT, ~(GLuint64)0 >> 1));
|
2010-03-21 13:26:36 +01:00
|
|
|
checkGLcall("glClientWaitSync");
|
|
|
|
|
|
|
|
switch (gl_ret)
|
|
|
|
{
|
|
|
|
case GL_ALREADY_SIGNALED:
|
|
|
|
case GL_CONDITION_SATISFIED:
|
2017-07-09 13:25:49 +02:00
|
|
|
ret = WINED3D_FENCE_OK;
|
2010-03-21 13:26:36 +01:00
|
|
|
break;
|
|
|
|
|
2017-08-12 18:09:06 +02:00
|
|
|
/* We don't expect a timeout for a ~292 year wait */
|
2010-03-21 13:26:36 +01:00
|
|
|
default:
|
|
|
|
ERR("glClientWaitSync returned %#x.\n", gl_ret);
|
2017-07-09 13:25:49 +02:00
|
|
|
ret = WINED3D_FENCE_ERROR;
|
2010-03-21 13:26:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (context->gl_info->supported[APPLE_FENCE])
|
|
|
|
{
|
2017-07-09 13:25:49 +02:00
|
|
|
GL_EXTCALL(glFinishFenceAPPLE(fence->object.id));
|
2010-03-21 13:26:36 +01:00
|
|
|
checkGLcall("glFinishFenceAPPLE");
|
2017-07-09 13:25:49 +02:00
|
|
|
ret = WINED3D_FENCE_OK;
|
2010-03-21 13:26:36 +01:00
|
|
|
}
|
|
|
|
else if (context->gl_info->supported[NV_FENCE])
|
|
|
|
{
|
2017-07-09 13:25:49 +02:00
|
|
|
GL_EXTCALL(glFinishFenceNV(fence->object.id));
|
2010-03-21 13:26:36 +01:00
|
|
|
checkGLcall("glFinishFenceNV");
|
2017-07-09 13:25:49 +02:00
|
|
|
ret = WINED3D_FENCE_OK;
|
2010-03-21 13:26:36 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-07-09 13:25:49 +02:00
|
|
|
ERR("Fence created without GL support.\n");
|
|
|
|
ret = WINED3D_FENCE_ERROR;
|
2010-03-21 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
context_release(context);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-07-09 13:25:49 +02:00
|
|
|
void wined3d_fence_issue(struct wined3d_fence *fence, const struct wined3d_device *device)
|
2010-03-03 23:18:37 +01:00
|
|
|
{
|
2017-04-05 15:38:06 +02:00
|
|
|
struct wined3d_context *context = NULL;
|
2010-03-03 23:18:37 +01:00
|
|
|
const struct wined3d_gl_info *gl_info;
|
|
|
|
|
2017-07-09 13:25:49 +02:00
|
|
|
if (fence->context && !(context = context_reacquire(device, fence->context))
|
|
|
|
&& !fence->context->gl_info->supported[ARB_SYNC])
|
|
|
|
context_free_fence(fence);
|
2017-04-05 15:38:06 +02:00
|
|
|
if (!context)
|
2017-02-15 14:17:15 +01:00
|
|
|
context = context_acquire(device, NULL, 0);
|
2010-03-03 23:18:37 +01:00
|
|
|
gl_info = context->gl_info;
|
2017-07-09 13:25:49 +02:00
|
|
|
if (!fence->context)
|
|
|
|
context_alloc_fence(context, fence);
|
2010-03-03 23:18:37 +01:00
|
|
|
|
|
|
|
if (gl_info->supported[ARB_SYNC])
|
|
|
|
{
|
2017-07-09 13:25:49 +02:00
|
|
|
if (fence->object.sync)
|
|
|
|
GL_EXTCALL(glDeleteSync(fence->object.sync));
|
2010-03-03 23:18:37 +01:00
|
|
|
checkGLcall("glDeleteSync");
|
2017-07-09 13:25:49 +02:00
|
|
|
fence->object.sync = GL_EXTCALL(glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0));
|
2010-03-03 23:18:37 +01:00
|
|
|
checkGLcall("glFenceSync");
|
|
|
|
}
|
|
|
|
else if (gl_info->supported[APPLE_FENCE])
|
|
|
|
{
|
2017-07-09 13:25:49 +02:00
|
|
|
GL_EXTCALL(glSetFenceAPPLE(fence->object.id));
|
2010-03-03 23:18:37 +01:00
|
|
|
checkGLcall("glSetFenceAPPLE");
|
|
|
|
}
|
|
|
|
else if (gl_info->supported[NV_FENCE])
|
|
|
|
{
|
2017-07-09 13:25:49 +02:00
|
|
|
GL_EXTCALL(glSetFenceNV(fence->object.id, GL_ALL_COMPLETED_NV));
|
2010-03-03 23:18:37 +01:00
|
|
|
checkGLcall("glSetFenceNV");
|
|
|
|
}
|
|
|
|
|
|
|
|
context_release(context);
|
|
|
|
}
|
|
|
|
|
2017-07-09 13:25:49 +02:00
|
|
|
static void wined3d_fence_free(struct wined3d_fence *fence)
|
|
|
|
{
|
|
|
|
if (fence->context)
|
|
|
|
context_free_fence(fence);
|
|
|
|
}
|
|
|
|
|
|
|
|
void wined3d_fence_destroy(struct wined3d_fence *fence)
|
|
|
|
{
|
|
|
|
wined3d_fence_free(fence);
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(fence);
|
2017-07-09 13:25:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT wined3d_fence_init(struct wined3d_fence *fence, const struct wined3d_gl_info *gl_info)
|
|
|
|
{
|
|
|
|
if (!wined3d_fence_supported(gl_info))
|
|
|
|
{
|
|
|
|
WARN("Fences not supported.\n");
|
|
|
|
return WINED3DERR_NOTAVAILABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return WINED3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT wined3d_fence_create(struct wined3d_device *device, struct wined3d_fence **fence)
|
|
|
|
{
|
|
|
|
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
|
|
|
|
struct wined3d_fence *object;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("device %p, fence %p.\n", device, fence);
|
|
|
|
|
2018-02-14 07:39:59 +01:00
|
|
|
if (!(object = heap_alloc_zero(sizeof(*object))))
|
2017-07-09 13:25:49 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (FAILED(hr = wined3d_fence_init(object, gl_info)))
|
|
|
|
{
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(object);
|
2017-07-09 13:25:49 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Created fence %p.\n", object);
|
|
|
|
*fence = object;
|
|
|
|
|
|
|
|
return WINED3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-02-03 20:14:06 +01:00
|
|
|
ULONG CDECL wined3d_query_incref(struct wined3d_query *query)
|
2005-03-03 14:57:15 +01:00
|
|
|
{
|
2011-02-03 20:14:06 +01:00
|
|
|
ULONG refcount = InterlockedIncrement(&query->ref);
|
2010-08-31 18:41:38 +02:00
|
|
|
|
2011-02-03 20:14:06 +01:00
|
|
|
TRACE("%p increasing refcount to %u.\n", query, refcount);
|
2010-08-31 18:41:38 +02:00
|
|
|
|
2011-02-03 20:14:06 +01:00
|
|
|
return refcount;
|
2005-03-03 14:57:15 +01:00
|
|
|
}
|
|
|
|
|
2016-06-22 10:39:03 +02:00
|
|
|
static void wined3d_query_destroy_object(void *object)
|
2011-02-03 20:14:06 +01:00
|
|
|
{
|
2016-06-22 10:39:03 +02:00
|
|
|
struct wined3d_query *query = object;
|
2005-03-03 14:57:15 +01:00
|
|
|
|
2017-04-13 00:11:01 +02:00
|
|
|
if (!list_empty(&query->poll_list_entry))
|
|
|
|
list_remove(&query->poll_list_entry);
|
|
|
|
|
2016-06-22 10:39:03 +02:00
|
|
|
/* Queries are specific to the GL context that created them. Not
|
|
|
|
* deleting the query will obviously leak it, but that's still better
|
|
|
|
* than potentially deleting a different query with the same id in this
|
|
|
|
* context, and (still) leaking the actual query. */
|
2017-05-26 10:48:03 +02:00
|
|
|
query->query_ops->query_destroy(query);
|
2016-06-22 10:39:03 +02:00
|
|
|
}
|
2007-03-01 00:34:33 +01:00
|
|
|
|
2016-06-22 10:39:03 +02:00
|
|
|
ULONG CDECL wined3d_query_decref(struct wined3d_query *query)
|
|
|
|
{
|
|
|
|
ULONG refcount = InterlockedDecrement(&query->ref);
|
|
|
|
|
|
|
|
TRACE("%p decreasing refcount to %u.\n", query, refcount);
|
|
|
|
|
|
|
|
if (!refcount)
|
2017-05-10 15:54:07 +02:00
|
|
|
{
|
|
|
|
query->parent_ops->wined3d_object_destroyed(query->parent);
|
2017-02-16 00:58:53 +01:00
|
|
|
wined3d_cs_destroy_object(query->device->cs, wined3d_query_destroy_object, query);
|
2017-05-10 15:54:07 +02:00
|
|
|
}
|
2011-02-03 20:14:06 +01:00
|
|
|
|
|
|
|
return refcount;
|
2005-03-03 14:57:15 +01:00
|
|
|
}
|
|
|
|
|
2011-02-03 20:14:06 +01:00
|
|
|
HRESULT CDECL wined3d_query_get_data(struct wined3d_query *query,
|
|
|
|
void *data, UINT data_size, DWORD flags)
|
2011-02-03 20:14:05 +01:00
|
|
|
{
|
2011-02-03 20:14:06 +01:00
|
|
|
TRACE("query %p, data %p, data_size %u, flags %#x.\n",
|
|
|
|
query, data, data_size, flags);
|
2011-02-03 20:14:05 +01:00
|
|
|
|
2016-07-28 13:29:41 +02:00
|
|
|
if (flags)
|
|
|
|
WARN("Ignoring flags %#x.\n", flags);
|
|
|
|
|
|
|
|
if (query->state == QUERY_BUILDING)
|
|
|
|
{
|
|
|
|
WARN("Query is building, returning S_FALSE.\n");
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (query->state == QUERY_CREATED)
|
2017-02-03 14:08:46 +01:00
|
|
|
{
|
2016-07-28 13:29:41 +02:00
|
|
|
WARN("Query wasn't started yet.\n");
|
2017-02-03 14:08:46 +01:00
|
|
|
return WINED3DERR_INVALIDCALL;
|
|
|
|
}
|
|
|
|
|
2017-04-13 00:11:01 +02:00
|
|
|
if (!query->device->cs->thread)
|
|
|
|
{
|
|
|
|
if (!query->query_ops->query_poll(query, flags))
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
else if (query->counter_main != query->counter_retrieved)
|
|
|
|
{
|
2017-09-08 18:44:08 +02:00
|
|
|
if (flags & WINED3DGETDATA_FLUSH && !query->device->cs->queries_flushed)
|
2017-04-13 00:11:01 +02:00
|
|
|
wined3d_cs_emit_flush(query->device->cs);
|
2016-07-28 13:29:41 +02:00
|
|
|
return S_FALSE;
|
2017-04-13 00:11:01 +02:00
|
|
|
}
|
2016-07-28 13:29:41 +02:00
|
|
|
|
|
|
|
if (data)
|
|
|
|
memcpy(data, query->data, min(data_size, query->data_size));
|
|
|
|
|
|
|
|
return S_OK;
|
2011-02-03 20:14:05 +01:00
|
|
|
}
|
|
|
|
|
2011-02-03 20:14:06 +01:00
|
|
|
UINT CDECL wined3d_query_get_data_size(const struct wined3d_query *query)
|
2011-02-03 20:14:05 +01:00
|
|
|
{
|
2011-02-03 20:14:06 +01:00
|
|
|
TRACE("query %p.\n", query);
|
2011-02-03 20:14:05 +01:00
|
|
|
|
|
|
|
return query->data_size;
|
|
|
|
}
|
|
|
|
|
2011-02-03 20:14:06 +01:00
|
|
|
HRESULT CDECL wined3d_query_issue(struct wined3d_query *query, DWORD flags)
|
2011-02-03 20:14:05 +01:00
|
|
|
{
|
2011-02-03 20:14:06 +01:00
|
|
|
TRACE("query %p, flags %#x.\n", query, flags);
|
2011-02-03 20:14:05 +01:00
|
|
|
|
2017-04-13 00:11:01 +02:00
|
|
|
if (flags & WINED3DISSUE_END)
|
|
|
|
++query->counter_main;
|
|
|
|
|
2016-07-29 12:34:34 +02:00
|
|
|
wined3d_cs_emit_query_issue(query->device->cs, query, flags);
|
2016-07-28 13:29:42 +02:00
|
|
|
|
|
|
|
if (flags & WINED3DISSUE_BEGIN)
|
|
|
|
query->state = QUERY_BUILDING;
|
|
|
|
else
|
|
|
|
query->state = QUERY_SIGNALLED;
|
|
|
|
|
|
|
|
return WINED3D_OK;
|
2011-02-03 20:14:05 +01:00
|
|
|
}
|
|
|
|
|
2017-01-04 00:04:49 +01:00
|
|
|
static BOOL wined3d_occlusion_query_ops_poll(struct wined3d_query *query, DWORD flags)
|
2010-11-18 20:50:40 +01:00
|
|
|
{
|
2016-07-22 00:43:49 +02:00
|
|
|
struct wined3d_occlusion_query *oq = wined3d_occlusion_query_from_query(query);
|
2011-05-16 23:01:23 +02:00
|
|
|
struct wined3d_device *device = query->device;
|
2016-07-28 13:29:41 +02:00
|
|
|
const struct wined3d_gl_info *gl_info;
|
2009-10-28 11:00:11 +01:00
|
|
|
struct wined3d_context *context;
|
2009-01-07 09:00:55 +01:00
|
|
|
GLuint available;
|
2009-07-24 10:44:13 +02:00
|
|
|
|
2017-01-04 00:04:49 +01:00
|
|
|
TRACE("query %p, flags %#x.\n", query, flags);
|
2009-01-07 09:00:55 +01:00
|
|
|
|
2017-04-05 15:38:05 +02:00
|
|
|
if (!(context = context_reacquire(device, oq->context)))
|
2009-01-07 09:00:55 +01:00
|
|
|
{
|
2011-02-03 20:14:05 +01:00
|
|
|
FIXME("%p Wrong thread, returning 1.\n", query);
|
2016-07-28 13:29:41 +02:00
|
|
|
oq->samples = 1;
|
|
|
|
return TRUE;
|
2009-01-07 09:00:55 +01:00
|
|
|
}
|
2016-07-28 13:29:41 +02:00
|
|
|
gl_info = context->gl_info;
|
2009-07-01 09:46:17 +02:00
|
|
|
|
2015-01-29 18:45:04 +01:00
|
|
|
GL_EXTCALL(glGetQueryObjectuiv(oq->id, GL_QUERY_RESULT_AVAILABLE, &available));
|
2017-06-05 00:47:37 +02:00
|
|
|
TRACE("Available %#x.\n", available);
|
2009-01-07 09:00:55 +01:00
|
|
|
|
|
|
|
if (available)
|
|
|
|
{
|
2017-06-05 00:47:37 +02:00
|
|
|
oq->samples = get_query_result64(oq->id, gl_info);
|
2016-11-21 15:15:53 +01:00
|
|
|
TRACE("Returning 0x%s samples.\n", wine_dbgstr_longlong(oq->samples));
|
2009-01-07 09:00:55 +01:00
|
|
|
}
|
|
|
|
|
2017-06-05 00:47:37 +02:00
|
|
|
checkGLcall("poll occlusion query");
|
2009-10-28 11:00:11 +01:00
|
|
|
context_release(context);
|
|
|
|
|
2016-07-28 13:29:41 +02:00
|
|
|
return available;
|
2008-02-28 21:03:41 +01:00
|
|
|
}
|
|
|
|
|
2017-01-04 00:04:49 +01:00
|
|
|
static BOOL wined3d_event_query_ops_poll(struct wined3d_query *query, DWORD flags)
|
2010-11-18 20:50:40 +01:00
|
|
|
{
|
2016-07-22 00:43:48 +02:00
|
|
|
struct wined3d_event_query *event_query = wined3d_event_query_from_query(query);
|
2017-07-09 13:25:49 +02:00
|
|
|
enum wined3d_fence_result ret;
|
2009-07-01 09:46:17 +02:00
|
|
|
|
2017-01-04 00:04:49 +01:00
|
|
|
TRACE("query %p, flags %#x.\n", query, flags);
|
2009-06-26 10:07:08 +02:00
|
|
|
|
2017-07-09 13:25:49 +02:00
|
|
|
ret = wined3d_fence_test(&event_query->fence, query->device, flags);
|
2016-07-28 13:29:41 +02:00
|
|
|
switch (ret)
|
2009-08-11 09:42:12 +02:00
|
|
|
{
|
2017-07-09 13:25:49 +02:00
|
|
|
case WINED3D_FENCE_OK:
|
|
|
|
case WINED3D_FENCE_NOT_STARTED:
|
2016-07-28 13:29:41 +02:00
|
|
|
return event_query->signalled = TRUE;
|
2010-03-03 22:45:34 +01:00
|
|
|
|
2017-07-09 13:25:49 +02:00
|
|
|
case WINED3D_FENCE_WAITING:
|
2016-07-28 13:29:41 +02:00
|
|
|
return event_query->signalled = FALSE;
|
2010-03-03 22:45:34 +01:00
|
|
|
|
2017-07-09 13:25:49 +02:00
|
|
|
case WINED3D_FENCE_WRONG_THREAD:
|
2011-02-03 20:14:05 +01:00
|
|
|
FIXME("(%p) Wrong thread, reporting GPU idle.\n", query);
|
2016-07-28 13:29:41 +02:00
|
|
|
return event_query->signalled = TRUE;
|
2010-03-03 22:45:34 +01:00
|
|
|
|
2017-07-09 13:25:49 +02:00
|
|
|
case WINED3D_FENCE_ERROR:
|
2016-07-28 13:29:41 +02:00
|
|
|
ERR("The GL event query failed.\n");
|
|
|
|
return event_query->signalled = TRUE;
|
2009-07-01 09:46:17 +02:00
|
|
|
|
2016-07-28 13:29:41 +02:00
|
|
|
default:
|
|
|
|
ERR("Unexpected wined3d_event_query_test result %#x.\n", ret);
|
|
|
|
return event_query->signalled = TRUE;
|
|
|
|
}
|
2008-02-28 21:02:58 +01:00
|
|
|
}
|
2005-03-03 14:57:15 +01:00
|
|
|
|
2014-09-19 10:41:47 +02:00
|
|
|
void * CDECL wined3d_query_get_parent(const struct wined3d_query *query)
|
|
|
|
{
|
|
|
|
TRACE("query %p.\n", query);
|
|
|
|
|
|
|
|
return query->parent;
|
|
|
|
}
|
|
|
|
|
2012-01-17 21:13:38 +01:00
|
|
|
enum wined3d_query_type CDECL wined3d_query_get_type(const struct wined3d_query *query)
|
2011-02-03 20:14:06 +01:00
|
|
|
{
|
|
|
|
TRACE("query %p.\n", query);
|
|
|
|
|
|
|
|
return query->type;
|
2005-03-03 14:57:15 +01:00
|
|
|
}
|
|
|
|
|
2017-04-13 00:11:01 +02:00
|
|
|
static BOOL wined3d_event_query_ops_issue(struct wined3d_query *query, DWORD flags)
|
2010-11-18 20:50:40 +01:00
|
|
|
{
|
2011-02-03 20:14:05 +01:00
|
|
|
TRACE("query %p, flags %#x.\n", query, flags);
|
2008-02-28 21:02:58 +01:00
|
|
|
|
2010-11-18 20:50:40 +01:00
|
|
|
if (flags & WINED3DISSUE_END)
|
2009-07-01 09:46:17 +02:00
|
|
|
{
|
2016-07-22 00:43:48 +02:00
|
|
|
struct wined3d_event_query *event_query = wined3d_event_query_from_query(query);
|
2010-03-03 23:48:50 +01:00
|
|
|
|
2017-07-09 13:25:49 +02:00
|
|
|
wined3d_fence_issue(&event_query->fence, query->device);
|
2017-04-13 00:11:01 +02:00
|
|
|
return TRUE;
|
2009-07-24 10:44:14 +02:00
|
|
|
}
|
2010-11-18 20:50:40 +01:00
|
|
|
else if (flags & WINED3DISSUE_BEGIN)
|
2009-07-24 10:44:14 +02:00
|
|
|
{
|
2016-07-22 00:43:48 +02:00
|
|
|
/* Started implicitly at query creation. */
|
2008-02-28 21:02:58 +01:00
|
|
|
ERR("Event query issued with START flag - what to do?\n");
|
|
|
|
}
|
2017-04-13 00:11:01 +02:00
|
|
|
|
|
|
|
return FALSE;
|
2008-02-28 21:02:58 +01:00
|
|
|
}
|
|
|
|
|
2017-04-13 00:11:01 +02:00
|
|
|
static BOOL wined3d_occlusion_query_ops_issue(struct wined3d_query *query, DWORD flags)
|
2010-11-18 20:50:40 +01:00
|
|
|
{
|
2016-07-22 00:43:49 +02:00
|
|
|
struct wined3d_occlusion_query *oq = wined3d_occlusion_query_from_query(query);
|
2011-05-16 23:01:23 +02:00
|
|
|
struct wined3d_device *device = query->device;
|
2009-10-29 10:37:11 +01:00
|
|
|
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
|
2016-07-21 15:58:00 +02:00
|
|
|
struct wined3d_context *context;
|
2017-04-13 00:11:01 +02:00
|
|
|
BOOL poll = FALSE;
|
2006-07-25 00:51:33 +02:00
|
|
|
|
2011-02-03 20:14:05 +01:00
|
|
|
TRACE("query %p, flags %#x.\n", query, flags);
|
|
|
|
|
2016-07-21 15:58:00 +02:00
|
|
|
/* This is allowed according to MSDN and our tests. Reset the query and
|
|
|
|
* restart. */
|
|
|
|
if (flags & WINED3DISSUE_BEGIN)
|
2009-07-01 09:46:17 +02:00
|
|
|
{
|
2017-04-13 00:11:01 +02:00
|
|
|
if (oq->started)
|
2009-07-01 09:46:17 +02:00
|
|
|
{
|
2017-04-05 15:38:05 +02:00
|
|
|
if ((context = context_reacquire(device, oq->context)))
|
2009-07-24 10:44:13 +02:00
|
|
|
{
|
2017-04-05 15:38:05 +02:00
|
|
|
GL_EXTCALL(glEndQuery(GL_SAMPLES_PASSED));
|
|
|
|
checkGLcall("glEndQuery()");
|
2008-02-28 21:03:41 +01:00
|
|
|
}
|
2009-07-24 10:44:13 +02:00
|
|
|
else
|
|
|
|
{
|
2017-04-05 15:38:05 +02:00
|
|
|
FIXME("Wrong thread, can't restart query.\n");
|
|
|
|
context_free_occlusion_query(oq);
|
|
|
|
context = context_acquire(device, NULL, 0);
|
|
|
|
context_alloc_occlusion_query(context, oq);
|
2009-07-24 10:44:13 +02:00
|
|
|
}
|
2016-07-21 15:58:00 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (oq->context)
|
|
|
|
context_free_occlusion_query(oq);
|
2017-04-05 15:38:05 +02:00
|
|
|
context = context_acquire(device, NULL, 0);
|
2016-07-21 15:58:00 +02:00
|
|
|
context_alloc_occlusion_query(context, oq);
|
|
|
|
}
|
2009-07-24 10:44:13 +02:00
|
|
|
|
2016-07-21 15:58:00 +02:00
|
|
|
GL_EXTCALL(glBeginQuery(GL_SAMPLES_PASSED, oq->id));
|
|
|
|
checkGLcall("glBeginQuery()");
|
2009-10-28 11:00:11 +01:00
|
|
|
|
2016-07-21 15:58:00 +02:00
|
|
|
context_release(context);
|
2017-04-13 00:11:01 +02:00
|
|
|
oq->started = TRUE;
|
2016-07-21 15:58:00 +02:00
|
|
|
}
|
|
|
|
if (flags & WINED3DISSUE_END)
|
|
|
|
{
|
|
|
|
/* MSDN says END on a non-building occlusion query returns an error,
|
|
|
|
* but our tests show that it returns OK. But OpenGL doesn't like it,
|
|
|
|
* so avoid generating an error. */
|
2017-04-13 00:11:01 +02:00
|
|
|
if (oq->started)
|
2010-11-18 20:50:40 +01:00
|
|
|
{
|
2017-04-05 15:38:05 +02:00
|
|
|
if ((context = context_reacquire(device, oq->context)))
|
2009-07-24 10:44:13 +02:00
|
|
|
{
|
2016-07-21 15:58:00 +02:00
|
|
|
GL_EXTCALL(glEndQuery(GL_SAMPLES_PASSED));
|
|
|
|
checkGLcall("glEndQuery()");
|
|
|
|
|
|
|
|
context_release(context);
|
2017-04-13 00:11:01 +02:00
|
|
|
poll = TRUE;
|
2006-07-25 00:51:33 +02:00
|
|
|
}
|
2017-04-05 15:38:05 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("Wrong thread, can't end query.\n");
|
|
|
|
}
|
2008-02-28 21:03:41 +01:00
|
|
|
}
|
2017-04-13 00:11:01 +02:00
|
|
|
oq->started = FALSE;
|
2011-02-03 20:14:05 +01:00
|
|
|
}
|
2017-04-13 00:11:01 +02:00
|
|
|
|
|
|
|
return poll;
|
2008-02-28 21:03:41 +01:00
|
|
|
}
|
|
|
|
|
2017-01-04 00:04:49 +01:00
|
|
|
static BOOL wined3d_timestamp_query_ops_poll(struct wined3d_query *query, DWORD flags)
|
2014-04-16 18:14:48 +02:00
|
|
|
{
|
2016-07-22 00:43:50 +02:00
|
|
|
struct wined3d_timestamp_query *tq = wined3d_timestamp_query_from_query(query);
|
2014-04-16 18:14:48 +02:00
|
|
|
struct wined3d_device *device = query->device;
|
2016-07-28 13:29:41 +02:00
|
|
|
const struct wined3d_gl_info *gl_info;
|
2014-04-16 18:14:48 +02:00
|
|
|
struct wined3d_context *context;
|
|
|
|
GLuint64 timestamp;
|
2016-07-28 13:29:41 +02:00
|
|
|
GLuint available;
|
2014-04-16 18:14:48 +02:00
|
|
|
|
2017-01-04 00:04:49 +01:00
|
|
|
TRACE("query %p, flags %#x.\n", query, flags);
|
2014-04-16 18:14:48 +02:00
|
|
|
|
2017-04-05 15:38:05 +02:00
|
|
|
if (!(context = context_reacquire(device, tq->context)))
|
2014-04-16 18:14:48 +02:00
|
|
|
{
|
|
|
|
FIXME("%p Wrong thread, returning 1.\n", query);
|
2016-07-28 13:29:41 +02:00
|
|
|
tq->timestamp = 1;
|
|
|
|
return TRUE;
|
2014-04-16 18:14:48 +02:00
|
|
|
}
|
2016-07-28 13:29:41 +02:00
|
|
|
gl_info = context->gl_info;
|
2014-04-16 18:14:48 +02:00
|
|
|
|
2015-01-29 18:45:04 +01:00
|
|
|
GL_EXTCALL(glGetQueryObjectuiv(tq->id, GL_QUERY_RESULT_AVAILABLE, &available));
|
|
|
|
checkGLcall("glGetQueryObjectuiv(GL_QUERY_RESULT_AVAILABLE)");
|
2014-04-16 18:14:48 +02:00
|
|
|
TRACE("available %#x.\n", available);
|
|
|
|
|
|
|
|
if (available)
|
|
|
|
{
|
2016-07-28 13:29:41 +02:00
|
|
|
GL_EXTCALL(glGetQueryObjectui64v(tq->id, GL_QUERY_RESULT, ×tamp));
|
|
|
|
checkGLcall("glGetQueryObjectui64v(GL_QUERY_RESULT)");
|
|
|
|
TRACE("Returning timestamp %s.\n", wine_dbgstr_longlong(timestamp));
|
|
|
|
tq->timestamp = timestamp;
|
2014-04-16 18:14:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
context_release(context);
|
|
|
|
|
2016-07-28 13:29:41 +02:00
|
|
|
return available;
|
2014-04-16 18:14:48 +02:00
|
|
|
}
|
|
|
|
|
2017-04-13 00:11:01 +02:00
|
|
|
static BOOL wined3d_timestamp_query_ops_issue(struct wined3d_query *query, DWORD flags)
|
2014-04-16 18:14:48 +02:00
|
|
|
{
|
2016-07-22 00:43:50 +02:00
|
|
|
struct wined3d_timestamp_query *tq = wined3d_timestamp_query_from_query(query);
|
2016-07-29 12:34:33 +02:00
|
|
|
const struct wined3d_gl_info *gl_info;
|
2016-07-22 00:43:47 +02:00
|
|
|
struct wined3d_context *context;
|
2014-04-16 18:14:48 +02:00
|
|
|
|
|
|
|
TRACE("query %p, flags %#x.\n", query, flags);
|
|
|
|
|
2016-07-22 00:43:47 +02:00
|
|
|
if (flags & WINED3DISSUE_BEGIN)
|
2014-04-16 18:14:48 +02:00
|
|
|
{
|
2016-07-22 00:43:47 +02:00
|
|
|
WARN("Ignoring WINED3DISSUE_BEGIN with a TIMESTAMP query.\n");
|
2014-04-16 18:14:48 +02:00
|
|
|
}
|
2016-07-22 00:43:47 +02:00
|
|
|
if (flags & WINED3DISSUE_END)
|
2014-04-16 18:14:48 +02:00
|
|
|
{
|
2016-07-22 00:43:47 +02:00
|
|
|
if (tq->context)
|
|
|
|
context_free_timestamp_query(tq);
|
2017-02-15 14:17:15 +01:00
|
|
|
context = context_acquire(query->device, NULL, 0);
|
2016-07-29 12:34:33 +02:00
|
|
|
gl_info = context->gl_info;
|
2016-07-22 00:43:47 +02:00
|
|
|
context_alloc_timestamp_query(context, tq);
|
|
|
|
GL_EXTCALL(glQueryCounter(tq->id, GL_TIMESTAMP));
|
|
|
|
checkGLcall("glQueryCounter()");
|
|
|
|
context_release(context);
|
2017-04-13 00:11:01 +02:00
|
|
|
|
|
|
|
return TRUE;
|
2016-07-22 00:43:47 +02:00
|
|
|
}
|
2017-04-13 00:11:01 +02:00
|
|
|
|
|
|
|
return FALSE;
|
2014-04-16 18:14:48 +02:00
|
|
|
}
|
|
|
|
|
2017-01-04 00:04:49 +01:00
|
|
|
static BOOL wined3d_timestamp_disjoint_query_ops_poll(struct wined3d_query *query, DWORD flags)
|
2014-04-16 18:14:48 +02:00
|
|
|
{
|
2017-01-04 00:04:49 +01:00
|
|
|
TRACE("query %p, flags %#x.\n", query, flags);
|
2014-04-16 18:14:48 +02:00
|
|
|
|
2016-07-28 13:29:41 +02:00
|
|
|
return TRUE;
|
2014-04-16 18:14:48 +02:00
|
|
|
}
|
|
|
|
|
2017-04-13 00:11:01 +02:00
|
|
|
static BOOL wined3d_timestamp_disjoint_query_ops_issue(struct wined3d_query *query, DWORD flags)
|
2014-04-16 18:14:48 +02:00
|
|
|
{
|
|
|
|
TRACE("query %p, flags %#x.\n", query, flags);
|
2017-04-13 00:11:01 +02:00
|
|
|
|
|
|
|
return FALSE;
|
2014-04-16 18:14:48 +02:00
|
|
|
}
|
|
|
|
|
2017-05-24 17:09:59 +02:00
|
|
|
static BOOL wined3d_so_statistics_query_ops_poll(struct wined3d_query *query, DWORD flags)
|
|
|
|
{
|
|
|
|
struct wined3d_so_statistics_query *pq = wined3d_so_statistics_query_from_query(query);
|
|
|
|
struct wined3d_device *device = query->device;
|
|
|
|
GLuint written_available, generated_available;
|
|
|
|
const struct wined3d_gl_info *gl_info;
|
|
|
|
struct wined3d_context *context;
|
|
|
|
|
|
|
|
TRACE("query %p, flags %#x.\n", query, flags);
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
GL_EXTCALL(glGetQueryObjectuiv(pq->u.query.written,
|
|
|
|
GL_QUERY_RESULT_AVAILABLE, &written_available));
|
|
|
|
GL_EXTCALL(glGetQueryObjectuiv(pq->u.query.generated,
|
|
|
|
GL_QUERY_RESULT_AVAILABLE, &generated_available));
|
|
|
|
TRACE("Available %#x, %#x.\n", written_available, generated_available);
|
|
|
|
|
|
|
|
if (written_available && generated_available)
|
|
|
|
{
|
2017-06-05 00:47:37 +02:00
|
|
|
pq->statistics.primitives_written = get_query_result64(pq->u.query.written, gl_info);
|
|
|
|
pq->statistics.primitives_generated = get_query_result64(pq->u.query.generated, gl_info);
|
2017-05-24 17:09:59 +02:00
|
|
|
TRACE("Returning %s, %s primitives.\n",
|
|
|
|
wine_dbgstr_longlong(pq->statistics.primitives_written),
|
|
|
|
wine_dbgstr_longlong(pq->statistics.primitives_generated));
|
|
|
|
}
|
|
|
|
|
|
|
|
checkGLcall("poll SO statistics query");
|
|
|
|
context_release(context);
|
|
|
|
|
|
|
|
return written_available && generated_available;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL wined3d_so_statistics_query_ops_issue(struct wined3d_query *query, DWORD flags)
|
|
|
|
{
|
|
|
|
struct wined3d_so_statistics_query *pq = wined3d_so_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;
|
|
|
|
|
|
|
|
TRACE("query %p, flags %#x.\n", query, flags);
|
|
|
|
|
|
|
|
if (flags & WINED3DISSUE_BEGIN)
|
|
|
|
{
|
|
|
|
if (pq->started)
|
|
|
|
{
|
|
|
|
if ((context = context_reacquire(device, pq->context)))
|
|
|
|
{
|
|
|
|
GL_EXTCALL(glEndQueryIndexed(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, pq->stream_idx));
|
|
|
|
GL_EXTCALL(glEndQueryIndexed(GL_PRIMITIVES_GENERATED, pq->stream_idx));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("Wrong thread, can't restart query.\n");
|
|
|
|
context_free_so_statistics_query(pq);
|
|
|
|
context = context_acquire(device, NULL, 0);
|
|
|
|
context_alloc_so_statistics_query(context, pq);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (pq->context)
|
|
|
|
context_free_so_statistics_query(pq);
|
|
|
|
context = context_acquire(device, NULL, 0);
|
|
|
|
context_alloc_so_statistics_query(context, pq);
|
|
|
|
}
|
|
|
|
|
|
|
|
GL_EXTCALL(glBeginQueryIndexed(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN,
|
|
|
|
pq->stream_idx, pq->u.query.written));
|
|
|
|
GL_EXTCALL(glBeginQueryIndexed(GL_PRIMITIVES_GENERATED,
|
|
|
|
pq->stream_idx, pq->u.query.generated));
|
|
|
|
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(glEndQueryIndexed(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, pq->stream_idx));
|
|
|
|
GL_EXTCALL(glEndQueryIndexed(GL_PRIMITIVES_GENERATED, pq->stream_idx));
|
|
|
|
checkGLcall("end query");
|
|
|
|
|
|
|
|
context_release(context);
|
|
|
|
poll = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("Wrong thread, can't end query.\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pq->started = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return poll;
|
|
|
|
}
|
|
|
|
|
2017-06-05 00:47:34 +02:00
|
|
|
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);
|
|
|
|
|
|
|
|
if (!(context = context_reacquire(device, pq->context)))
|
|
|
|
{
|
|
|
|
FIXME("%p Wrong thread.\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)
|
2017-06-05 00:47:37 +02:00
|
|
|
break;
|
2017-06-05 00:47:34 +02:00
|
|
|
}
|
|
|
|
|
2017-06-05 00:47:37 +02:00
|
|
|
if (available)
|
2017-06-05 00:47:34 +02:00
|
|
|
{
|
2017-06-05 00:47:37 +02:00
|
|
|
pq->statistics.vertices_submitted = get_query_result64(pq->u.query.vertices, gl_info);
|
|
|
|
pq->statistics.primitives_submitted = get_query_result64(pq->u.query.primitives, gl_info);
|
|
|
|
pq->statistics.vs_invocations = get_query_result64(pq->u.query.vertex_shader, gl_info);
|
|
|
|
pq->statistics.hs_invocations = get_query_result64(pq->u.query.tess_control_shader, gl_info);
|
|
|
|
pq->statistics.ds_invocations = get_query_result64(pq->u.query.tess_eval_shader, gl_info);
|
|
|
|
pq->statistics.gs_invocations = get_query_result64(pq->u.query.geometry_shader, gl_info);
|
|
|
|
pq->statistics.gs_primitives = get_query_result64(pq->u.query.geometry_primitives, gl_info);
|
|
|
|
pq->statistics.ps_invocations = get_query_result64(pq->u.query.fragment_shader, gl_info);
|
|
|
|
pq->statistics.cs_invocations = get_query_result64(pq->u.query.compute_shader, gl_info);
|
|
|
|
pq->statistics.clipping_input_primitives = get_query_result64(pq->u.query.clipping_input, gl_info);
|
|
|
|
pq->statistics.clipping_output_primitives = get_query_result64(pq->u.query.clipping_output, gl_info);
|
2017-06-05 00:47:34 +02:00
|
|
|
}
|
2017-06-05 00:47:37 +02:00
|
|
|
|
2017-06-05 00:47:34 +02:00
|
|
|
checkGLcall("poll pipeline statistics query");
|
|
|
|
context_release(context);
|
|
|
|
return available;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wined3d_pipeline_statistics_query_end(struct wined3d_pipeline_statistics_query *query,
|
|
|
|
struct wined3d_context *context)
|
|
|
|
{
|
|
|
|
const struct wined3d_gl_info *gl_info = context->gl_info;
|
|
|
|
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL wined3d_pipeline_query_ops_issue(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 = &device->adapter->gl_info;
|
|
|
|
struct wined3d_context *context;
|
|
|
|
BOOL poll = FALSE;
|
|
|
|
|
|
|
|
TRACE("query %p, flags %#x.\n", query, flags);
|
|
|
|
|
|
|
|
if (flags & WINED3DISSUE_BEGIN)
|
|
|
|
{
|
|
|
|
if (pq->started)
|
|
|
|
{
|
|
|
|
if ((context = context_reacquire(device, pq->context)))
|
|
|
|
{
|
|
|
|
wined3d_pipeline_statistics_query_end(pq, context);
|
|
|
|
}
|
|
|
|
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)))
|
|
|
|
{
|
|
|
|
wined3d_pipeline_statistics_query_end(pq, context);
|
|
|
|
context_release(context);
|
|
|
|
poll = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("Wrong thread, can't end query.\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pq->started = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return poll;
|
|
|
|
}
|
|
|
|
|
2017-05-26 10:48:03 +02:00
|
|
|
static void wined3d_event_query_ops_destroy(struct wined3d_query *query)
|
|
|
|
{
|
|
|
|
struct wined3d_event_query *event_query = wined3d_event_query_from_query(query);
|
|
|
|
|
2017-07-09 13:25:49 +02:00
|
|
|
wined3d_fence_free(&event_query->fence);
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(event_query);
|
2017-05-26 10:48:03 +02:00
|
|
|
}
|
|
|
|
|
2011-02-03 20:14:05 +01:00
|
|
|
static const struct wined3d_query_ops event_query_ops =
|
2008-02-28 21:02:58 +01:00
|
|
|
{
|
2016-07-28 13:29:41 +02:00
|
|
|
wined3d_event_query_ops_poll,
|
2011-02-03 20:14:05 +01:00
|
|
|
wined3d_event_query_ops_issue,
|
2017-05-26 10:48:03 +02:00
|
|
|
wined3d_event_query_ops_destroy,
|
2011-02-03 20:14:05 +01:00
|
|
|
};
|
|
|
|
|
2016-07-22 00:43:48 +02:00
|
|
|
static HRESULT wined3d_event_query_create(struct wined3d_device *device,
|
2017-05-10 15:54:07 +02:00
|
|
|
enum wined3d_query_type type, void *parent, const struct wined3d_parent_ops *parent_ops,
|
|
|
|
struct wined3d_query **query)
|
2016-07-22 00:43:48 +02:00
|
|
|
{
|
|
|
|
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
|
|
|
|
struct wined3d_event_query *object;
|
2017-07-09 13:25:49 +02:00
|
|
|
HRESULT hr;
|
2016-07-22 00:43:48 +02:00
|
|
|
|
2017-05-10 15:54:07 +02:00
|
|
|
TRACE("device %p, type %#x, parent %p, parent_ops %p, query %p.\n",
|
|
|
|
device, type, parent, parent_ops, query);
|
2016-07-22 00:43:48 +02:00
|
|
|
|
2018-02-14 07:39:59 +01:00
|
|
|
if (!(object = heap_alloc_zero(sizeof(*object))))
|
2017-07-09 13:25:49 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (FAILED(hr = wined3d_fence_init(&object->fence, gl_info)))
|
2016-07-22 00:43:48 +02:00
|
|
|
{
|
|
|
|
WARN("Event queries not supported.\n");
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(object);
|
2017-07-12 15:03:02 +02:00
|
|
|
return hr;
|
2016-07-22 00:43:48 +02:00
|
|
|
}
|
|
|
|
|
2016-07-28 13:29:41 +02:00
|
|
|
wined3d_query_init(&object->query, device, type, &object->signalled,
|
2017-05-10 15:54:07 +02:00
|
|
|
sizeof(object->signalled), &event_query_ops, parent, parent_ops);
|
2016-07-22 00:43:48 +02:00
|
|
|
|
|
|
|
TRACE("Created query %p.\n", object);
|
|
|
|
*query = &object->query;
|
|
|
|
|
|
|
|
return WINED3D_OK;
|
|
|
|
}
|
|
|
|
|
2017-05-26 10:48:03 +02:00
|
|
|
static void wined3d_occlusion_query_ops_destroy(struct wined3d_query *query)
|
|
|
|
{
|
|
|
|
struct wined3d_occlusion_query *oq = wined3d_occlusion_query_from_query(query);
|
|
|
|
|
|
|
|
if (oq->context)
|
|
|
|
context_free_occlusion_query(oq);
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(oq);
|
2017-05-26 10:48:03 +02:00
|
|
|
}
|
|
|
|
|
2011-02-03 20:14:05 +01:00
|
|
|
static const struct wined3d_query_ops occlusion_query_ops =
|
|
|
|
{
|
2016-07-28 13:29:41 +02:00
|
|
|
wined3d_occlusion_query_ops_poll,
|
2011-02-03 20:14:05 +01:00
|
|
|
wined3d_occlusion_query_ops_issue,
|
2017-05-26 10:48:03 +02:00
|
|
|
wined3d_occlusion_query_ops_destroy,
|
2008-02-28 21:02:58 +01:00
|
|
|
};
|
2008-02-28 21:03:41 +01:00
|
|
|
|
2016-07-22 00:43:49 +02:00
|
|
|
static HRESULT wined3d_occlusion_query_create(struct wined3d_device *device,
|
2017-05-10 15:54:07 +02:00
|
|
|
enum wined3d_query_type type, void *parent, const struct wined3d_parent_ops *parent_ops,
|
|
|
|
struct wined3d_query **query)
|
2016-07-22 00:43:49 +02:00
|
|
|
{
|
|
|
|
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
|
|
|
|
struct wined3d_occlusion_query *object;
|
|
|
|
|
2017-05-10 15:54:07 +02:00
|
|
|
TRACE("device %p, type %#x, parent %p, parent_ops %p, query %p.\n",
|
|
|
|
device, type, parent, parent_ops, query);
|
2016-07-22 00:43:49 +02:00
|
|
|
|
|
|
|
if (!gl_info->supported[ARB_OCCLUSION_QUERY])
|
|
|
|
{
|
|
|
|
WARN("Unsupported in local OpenGL implementation: ARB_OCCLUSION_QUERY.\n");
|
|
|
|
return WINED3DERR_NOTAVAILABLE;
|
|
|
|
}
|
|
|
|
|
2018-02-14 07:39:59 +01:00
|
|
|
if (!(object = heap_alloc_zero(sizeof(*object))))
|
2016-07-22 00:43:49 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2016-07-28 13:29:41 +02:00
|
|
|
wined3d_query_init(&object->query, device, type, &object->samples,
|
2017-05-10 15:54:07 +02:00
|
|
|
sizeof(object->samples), &occlusion_query_ops, parent, parent_ops);
|
2016-07-22 00:43:49 +02:00
|
|
|
|
|
|
|
TRACE("Created query %p.\n", object);
|
|
|
|
*query = &object->query;
|
|
|
|
|
|
|
|
return WINED3D_OK;
|
|
|
|
}
|
|
|
|
|
2017-05-26 10:48:03 +02:00
|
|
|
static void wined3d_timestamp_query_ops_destroy(struct wined3d_query *query)
|
|
|
|
{
|
|
|
|
struct wined3d_timestamp_query *tq = wined3d_timestamp_query_from_query(query);
|
|
|
|
|
|
|
|
if (tq->context)
|
|
|
|
context_free_timestamp_query(tq);
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(tq);
|
2017-05-26 10:48:03 +02:00
|
|
|
}
|
|
|
|
|
2014-04-16 18:14:48 +02:00
|
|
|
static const struct wined3d_query_ops timestamp_query_ops =
|
|
|
|
{
|
2016-07-28 13:29:41 +02:00
|
|
|
wined3d_timestamp_query_ops_poll,
|
2014-04-16 18:14:48 +02:00
|
|
|
wined3d_timestamp_query_ops_issue,
|
2017-05-26 10:48:03 +02:00
|
|
|
wined3d_timestamp_query_ops_destroy,
|
2014-04-16 18:14:48 +02:00
|
|
|
};
|
|
|
|
|
2016-07-22 00:43:50 +02:00
|
|
|
static HRESULT wined3d_timestamp_query_create(struct wined3d_device *device,
|
2017-05-10 15:54:07 +02:00
|
|
|
enum wined3d_query_type type, void *parent, const struct wined3d_parent_ops *parent_ops,
|
|
|
|
struct wined3d_query **query)
|
2016-07-22 00:43:50 +02:00
|
|
|
{
|
|
|
|
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
|
|
|
|
struct wined3d_timestamp_query *object;
|
|
|
|
|
2017-05-10 15:54:07 +02:00
|
|
|
TRACE("device %p, type %#x, parent %p, parent_ops %p, query %p.\n",
|
|
|
|
device, type, parent, parent_ops, query);
|
2016-07-22 00:43:50 +02:00
|
|
|
|
|
|
|
if (!gl_info->supported[ARB_TIMER_QUERY])
|
|
|
|
{
|
|
|
|
WARN("Unsupported in local OpenGL implementation: ARB_TIMER_QUERY.\n");
|
|
|
|
return WINED3DERR_NOTAVAILABLE;
|
|
|
|
}
|
|
|
|
|
2018-02-14 07:39:59 +01:00
|
|
|
if (!(object = heap_alloc_zero(sizeof(*object))))
|
2016-07-22 00:43:50 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2016-07-28 13:29:41 +02:00
|
|
|
wined3d_query_init(&object->query, device, type, &object->timestamp,
|
2017-05-10 15:54:07 +02:00
|
|
|
sizeof(object->timestamp), ×tamp_query_ops, parent, parent_ops);
|
2016-07-22 00:43:50 +02:00
|
|
|
|
|
|
|
TRACE("Created query %p.\n", object);
|
|
|
|
*query = &object->query;
|
|
|
|
|
|
|
|
return WINED3D_OK;
|
|
|
|
}
|
|
|
|
|
2017-05-26 10:48:03 +02:00
|
|
|
static void wined3d_timestamp_disjoint_query_ops_destroy(struct wined3d_query *query)
|
|
|
|
{
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(query);
|
2017-05-26 10:48:03 +02:00
|
|
|
}
|
|
|
|
|
2014-04-16 18:14:48 +02:00
|
|
|
static const struct wined3d_query_ops timestamp_disjoint_query_ops =
|
|
|
|
{
|
2016-07-28 13:29:41 +02:00
|
|
|
wined3d_timestamp_disjoint_query_ops_poll,
|
2014-04-16 18:14:48 +02:00
|
|
|
wined3d_timestamp_disjoint_query_ops_issue,
|
2017-05-26 10:48:03 +02:00
|
|
|
wined3d_timestamp_disjoint_query_ops_destroy,
|
2014-04-16 18:14:48 +02:00
|
|
|
};
|
|
|
|
|
2016-07-22 00:43:51 +02:00
|
|
|
static HRESULT wined3d_timestamp_disjoint_query_create(struct wined3d_device *device,
|
2017-05-10 15:54:07 +02:00
|
|
|
enum wined3d_query_type type, void *parent, const struct wined3d_parent_ops *parent_ops,
|
|
|
|
struct wined3d_query **query)
|
2010-01-17 21:31:30 +01:00
|
|
|
{
|
|
|
|
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
|
2016-07-22 00:43:51 +02:00
|
|
|
struct wined3d_query *object;
|
2010-01-17 21:31:30 +01:00
|
|
|
|
2017-05-10 15:54:07 +02:00
|
|
|
TRACE("device %p, type %#x, parent %p, parent_ops %p, query %p.\n",
|
|
|
|
device, type, parent, parent_ops, query);
|
2014-09-19 10:41:47 +02:00
|
|
|
|
2016-07-22 00:43:51 +02:00
|
|
|
if (!gl_info->supported[ARB_TIMER_QUERY])
|
2010-01-17 21:31:30 +01:00
|
|
|
{
|
2016-07-22 00:43:51 +02:00
|
|
|
WARN("Unsupported in local OpenGL implementation: ARB_TIMER_QUERY.\n");
|
|
|
|
return WINED3DERR_NOTAVAILABLE;
|
2010-01-17 21:31:30 +01:00
|
|
|
}
|
|
|
|
|
2018-02-14 07:39:59 +01:00
|
|
|
if (!(object = heap_alloc_zero(sizeof(*object))))
|
2016-07-22 00:43:51 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (type == WINED3D_QUERY_TYPE_TIMESTAMP_DISJOINT)
|
2016-07-28 13:29:41 +02:00
|
|
|
{
|
|
|
|
static const struct wined3d_query_data_timestamp_disjoint disjoint_data = {1000 * 1000 * 1000, FALSE};
|
|
|
|
|
|
|
|
wined3d_query_init(object, device, type, &disjoint_data,
|
2017-05-10 15:54:07 +02:00
|
|
|
sizeof(disjoint_data), ×tamp_disjoint_query_ops, parent, parent_ops);
|
2016-07-28 13:29:41 +02:00
|
|
|
}
|
2016-07-22 00:43:51 +02:00
|
|
|
else
|
2016-07-28 13:29:41 +02:00
|
|
|
{
|
|
|
|
static const UINT64 freq = 1000 * 1000 * 1000;
|
|
|
|
|
|
|
|
wined3d_query_init(object, device, type, &freq,
|
2017-05-10 15:54:07 +02:00
|
|
|
sizeof(freq), ×tamp_disjoint_query_ops, parent, parent_ops);
|
2016-07-28 13:29:41 +02:00
|
|
|
}
|
2016-07-22 00:43:51 +02:00
|
|
|
|
|
|
|
TRACE("Created query %p.\n", object);
|
|
|
|
*query = object;
|
2010-01-17 21:31:30 +01:00
|
|
|
|
|
|
|
return WINED3D_OK;
|
|
|
|
}
|
2011-05-10 21:18:47 +02:00
|
|
|
|
2017-05-26 10:48:03 +02:00
|
|
|
static void wined3d_so_statistics_query_ops_destroy(struct wined3d_query *query)
|
|
|
|
{
|
|
|
|
struct wined3d_so_statistics_query *pq = wined3d_so_statistics_query_from_query(query);
|
|
|
|
|
|
|
|
if (pq->context)
|
|
|
|
context_free_so_statistics_query(pq);
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(pq);
|
2017-05-26 10:48:03 +02:00
|
|
|
}
|
|
|
|
|
2017-05-24 17:09:59 +02:00
|
|
|
static const struct wined3d_query_ops so_statistics_query_ops =
|
|
|
|
{
|
|
|
|
wined3d_so_statistics_query_ops_poll,
|
|
|
|
wined3d_so_statistics_query_ops_issue,
|
2017-05-26 10:48:03 +02:00
|
|
|
wined3d_so_statistics_query_ops_destroy,
|
2017-05-24 17:09:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
|
|
|
|
struct wined3d_so_statistics_query *object;
|
2017-06-05 00:47:38 +02:00
|
|
|
unsigned int stream_idx;
|
|
|
|
|
|
|
|
if (WINED3D_QUERY_TYPE_SO_STATISTICS_STREAM0 <= type && type <= WINED3D_QUERY_TYPE_SO_STATISTICS_STREAM3)
|
|
|
|
stream_idx = type - WINED3D_QUERY_TYPE_SO_STATISTICS_STREAM0;
|
|
|
|
else
|
|
|
|
return WINED3DERR_NOTAVAILABLE;
|
2017-05-24 17:09:59 +02:00
|
|
|
|
|
|
|
TRACE("device %p, type %#x, parent %p, parent_ops %p, query %p.\n",
|
|
|
|
device, type, parent, parent_ops, query);
|
|
|
|
|
|
|
|
if (!gl_info->supported[WINED3D_GL_PRIMITIVE_QUERY])
|
|
|
|
{
|
|
|
|
WARN("OpenGL implementation does not support primitive queries.\n");
|
|
|
|
return WINED3DERR_NOTAVAILABLE;
|
|
|
|
}
|
|
|
|
if (!gl_info->supported[ARB_TRANSFORM_FEEDBACK3])
|
|
|
|
{
|
|
|
|
WARN("OpenGL implementation does not support indexed queries.\n");
|
|
|
|
return WINED3DERR_NOTAVAILABLE;
|
|
|
|
}
|
|
|
|
|
2018-02-14 07:39:59 +01:00
|
|
|
if (!(object = heap_alloc_zero(sizeof(*object))))
|
2017-05-24 17:09:59 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
wined3d_query_init(&object->query, device, type, &object->statistics,
|
|
|
|
sizeof(object->statistics), &so_statistics_query_ops, parent, parent_ops);
|
2017-06-05 00:47:38 +02:00
|
|
|
object->stream_idx = stream_idx;
|
2017-05-24 17:09:59 +02:00
|
|
|
|
|
|
|
TRACE("Created query %p.\n", object);
|
|
|
|
*query = &object->query;
|
|
|
|
|
|
|
|
return WINED3D_OK;
|
|
|
|
}
|
|
|
|
|
2017-06-05 00:47:34 +02:00
|
|
|
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);
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(pq);
|
2017-06-05 00:47:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
|
|
|
|
struct wined3d_pipeline_statistics_query *object;
|
|
|
|
|
|
|
|
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 statistics queries.\n");
|
|
|
|
return WINED3DERR_NOTAVAILABLE;
|
|
|
|
}
|
|
|
|
|
2018-02-14 07:39:59 +01:00
|
|
|
if (!(object = heap_alloc_zero(sizeof(*object))))
|
2017-06-05 00:47:34 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
return WINED3D_OK;
|
|
|
|
}
|
|
|
|
|
2017-05-10 15:54:07 +02:00
|
|
|
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)
|
2011-05-10 21:18:47 +02:00
|
|
|
{
|
2017-05-10 15:54:07 +02:00
|
|
|
TRACE("device %p, type %#x, parent %p, parent_ops %p, query %p.\n",
|
|
|
|
device, type, parent, parent_ops, query);
|
2011-05-10 21:18:47 +02:00
|
|
|
|
2016-07-22 00:43:48 +02:00
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case WINED3D_QUERY_TYPE_EVENT:
|
2017-05-10 15:54:07 +02:00
|
|
|
return wined3d_event_query_create(device, type, parent, parent_ops, query);
|
2016-07-22 00:43:48 +02:00
|
|
|
|
2016-07-22 00:43:49 +02:00
|
|
|
case WINED3D_QUERY_TYPE_OCCLUSION:
|
2017-05-10 15:54:07 +02:00
|
|
|
return wined3d_occlusion_query_create(device, type, parent, parent_ops, query);
|
2016-07-22 00:43:49 +02:00
|
|
|
|
2016-07-22 00:43:50 +02:00
|
|
|
case WINED3D_QUERY_TYPE_TIMESTAMP:
|
2017-05-10 15:54:07 +02:00
|
|
|
return wined3d_timestamp_query_create(device, type, parent, parent_ops, query);
|
2016-07-22 00:43:50 +02:00
|
|
|
|
2016-07-22 00:43:51 +02:00
|
|
|
case WINED3D_QUERY_TYPE_TIMESTAMP_DISJOINT:
|
|
|
|
case WINED3D_QUERY_TYPE_TIMESTAMP_FREQ:
|
2017-05-10 15:54:07 +02:00
|
|
|
return wined3d_timestamp_disjoint_query_create(device, type, parent, parent_ops, query);
|
2011-05-10 21:18:47 +02:00
|
|
|
|
2017-05-24 17:09:59 +02:00
|
|
|
case WINED3D_QUERY_TYPE_SO_STATISTICS_STREAM0:
|
|
|
|
case WINED3D_QUERY_TYPE_SO_STATISTICS_STREAM1:
|
|
|
|
case WINED3D_QUERY_TYPE_SO_STATISTICS_STREAM2:
|
|
|
|
case WINED3D_QUERY_TYPE_SO_STATISTICS_STREAM3:
|
|
|
|
return wined3d_so_statistics_query_create(device, type, parent, parent_ops, query);
|
|
|
|
|
2017-06-05 00:47:34 +02:00
|
|
|
case WINED3D_QUERY_TYPE_PIPELINE_STATISTICS:
|
|
|
|
return wined3d_pipeline_query_create(device, type, parent, parent_ops, query);
|
|
|
|
|
2016-07-22 00:43:51 +02:00
|
|
|
default:
|
|
|
|
FIXME("Unhandled query type %#x.\n", type);
|
|
|
|
return WINED3DERR_NOTAVAILABLE;
|
2011-05-10 21:18:47 +02:00
|
|
|
}
|
|
|
|
}
|