query.c revision 589fd26cedb2b4ebbed14f2964cad03cc8ebbca2
/*
* IWineD3DQuery implementation
*
* Copyright 2005 Oliver Stieber
* Copyright 2007-2008 Stefan Dösinger for CodeWeavers
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
/*
* Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
* other than GPL or LGPL is available it will apply instead, Sun elects to use only
* the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
* a choice of LGPL license versions is made available with the language indicating
* that LGPLv2 or any later version may be used, or where a choice of which version
* of the LGPL is applied is otherwise unspecified.
*/
#include "config.h"
#include "wined3d_private.h"
/*
* Occlusion Queries:
*/
/* *******************************************
IWineD3DQuery IUnknown parts follow
******************************************* */
static HRESULT WINAPI IWineD3DQueryImpl_QueryInterface(IWineD3DQuery *iface, REFIID riid, LPVOID *ppobj)
{
return S_OK;
}
return E_NOINTERFACE;
}
}
if (ref == 0) {
ENTER_GL();
/* 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. */
{
FIXME("Query was created in a different context, skipping deletion\n");
}
else if(GL_SUPPORT(APPLE_FENCE))
{
checkGLcall("glDeleteFencesAPPLE");
} else if(GL_SUPPORT(NV_FENCE)) {
checkGLcall("glDeleteFencesNV");
}
{
FIXME("Query was created in a different context, skipping deletion\n");
}
else
{
checkGLcall("glDeleteQueriesARB");
}
}
LEAVE_GL();
}
return ref;
}
/* *******************************************
IWineD3DQuery IWineD3DQuery parts follow
******************************************* */
return WINED3D_OK;
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DQueryImpl_GetData(IWineD3DQuery* iface, void* pData, DWORD dwSize, DWORD dwGetDataFlags){
TRACE("(%p) : type %#x, pData %p, dwSize %#x, dwGetDataFlags %#x\n", This, This->type, pData, dwSize, dwGetDataFlags);
case WINED3DQUERYTYPE_VCACHE:
{
}
break;
{
int i;
for(i = 0; i < WINED3DRTYPECOUNT; i++){
/*I'm setting the default values to 1 so as to reduce the risk of a div/0 in the caller*/
/* isTextureResident could be used to get some of this information */
}
}
break;
{
}
break;
{
}
break;
{
}
break;
{
}
break;
{
}
break;
{
}
break;
{
}
break;
{
}
break;
{
}
break;
{
}
break;
default:
};
/*dwGetDataFlags = 0 || D3DGETDATA_FLUSH
D3DGETDATA_FLUSH may return WINED3DERR_DEVICELOST if the device is lost
*/
return res; /* S_OK if the query data is available*/
}
static HRESULT WINAPI IWineD3DOcclusionQueryImpl_GetData(IWineD3DQuery* iface, void* pData, DWORD dwSize, DWORD dwGetDataFlags) {
TRACE("(%p) : type D3DQUERY_OCCLUSION, pData %p, dwSize %#x, dwGetDataFlags %#x\n", This, pData, dwSize, dwGetDataFlags);
{
/* D3D allows GetData on a new query, OpenGL doesn't. So just invent the data ourselves */
TRACE("Query wasn't yet started, returning S_OK\n");
return S_OK;
}
{
/* Msdn says this returns an error, but our tests show that S_FALSE is returned */
TRACE("Query is building, returning S_FALSE\n");
return S_FALSE;
}
if (!GL_SUPPORT(ARB_OCCLUSION_QUERY))
{
*data = 1;
return S_OK;
}
{
*data = 1;
return S_OK;
}
ENTER_GL();
checkGLcall("glGetQueryObjectuivARB(GL_QUERY_RESULT_AVAILABLE)\n");
if (available)
{
if (data)
{
checkGLcall("glGetQueryObjectuivARB(GL_QUERY_RESULT)\n");
}
}
else
{
}
LEAVE_GL();
return res;
}
static HRESULT WINAPI IWineD3DEventQueryImpl_GetData(IWineD3DQuery* iface, void* pData, DWORD dwSize, DWORD dwGetDataFlags) {
TRACE("(%p) : type D3DQUERY_EVENT, pData %p, dwSize %#x, dwGetDataFlags %#x\n", This, pData, dwSize, dwGetDataFlags);
return S_OK;
/* See comment in IWineD3DQuery::Issue, event query codeblock */
FIXME("Query context not active, reporting GPU idle\n");
} else if(GL_SUPPORT(APPLE_FENCE)) {
ENTER_GL();
checkGLcall("glTestFenceAPPLE");
LEAVE_GL();
} else if(GL_SUPPORT(NV_FENCE)) {
ENTER_GL();
checkGLcall("glTestFenceNV");
LEAVE_GL();
} else {
}
return S_OK;
}
int dataSize = 0;
case WINED3DQUERYTYPE_VCACHE:
dataSize = sizeof(WINED3DDEVINFO_VCACHE);
break;
dataSize = sizeof(WINED3DDEVINFO_RESOURCEMANAGER);
break;
dataSize = sizeof(WINED3DDEVINFO_VERTEXSTATS);
break;
case WINED3DQUERYTYPE_EVENT:
break;
break;
break;
break;
dataSize = sizeof(WINED3DDEVINFO_PIPELINETIMINGS);
break;
dataSize = sizeof(WINED3DDEVINFO_INTERFACETIMINGS);
break;
dataSize = sizeof(WINED3DDEVINFO_STAGETIMINGS);
break;
dataSize = sizeof(WINED3DDEVINFO_STAGETIMINGS);
break;
dataSize = sizeof(WINED3DQUERYTYPE_BANDWIDTHTIMINGS);
break;
dataSize = sizeof(WINED3DDEVINFO_CACHEUTILIZATION);
break;
default:
dataSize = 0;
}
return dataSize;
}
return sizeof(BOOL);
}
return sizeof(DWORD);
}
}
if (dwIssueFlags & WINED3DISSUE_END) {
/* GL fences can be used only from the context that created them,
* so if a different context is active, don't bother setting the query. The penalty
* of a context switch is most likely higher than the gain of a correct query result
*
* If the query is used from a different thread, don't bother creating a multithread
* context - there's no point in doing that as the query would be unusable anyway
*/
WARN("Query context not active\n");
} else if(GL_SUPPORT(APPLE_FENCE)) {
ENTER_GL();
checkGLcall("glSetFenceAPPLE");
LEAVE_GL();
} else if (GL_SUPPORT(NV_FENCE)) {
ENTER_GL();
checkGLcall("glSetFenceNV");
LEAVE_GL();
}
} else if(dwIssueFlags & WINED3DISSUE_BEGIN) {
/* Started implicitly at device creation */
ERR("Event query issued with START flag - what to do?\n");
}
if(dwIssueFlags & WINED3DISSUE_BEGIN) {
} else {
}
return WINED3D_OK;
}
if (GL_SUPPORT(ARB_OCCLUSION_QUERY)) {
FIXME("Not the owning context, can't start query\n");
} else {
ENTER_GL();
/* This is allowed according to msdn and our tests. Reset the query and restart */
if (dwIssueFlags & WINED3DISSUE_BEGIN) {
checkGLcall("glEndQuery()");
}
GL_EXTCALL(glBeginQueryARB(GL_SAMPLES_PASSED_ARB, ((WineQueryOcclusionData *)This->extendedData)->queryId));
checkGLcall("glBeginQuery()");
}
if (dwIssueFlags & 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
*/
checkGLcall("glEndQuery()");
}
}
LEAVE_GL();
}
} else {
}
if(dwIssueFlags & WINED3DISSUE_BEGIN) {
} else {
}
return WINED3D_OK; /* can be WINED3DERR_INVALIDCALL. */
}
/* The fixme is printed when the app asks for the resulting data */
if(dwIssueFlags & WINED3DISSUE_BEGIN) {
} else {
}
return WINED3D_OK; /* can be WINED3DERR_INVALIDCALL. */
}
/**********************************************************
* IWineD3DQuery VTbl follows
**********************************************************/
const IWineD3DQueryVtbl IWineD3DQuery_Vtbl =
{
/*** IUnknown methods ***/
/*** IWineD3Dquery methods ***/
};
{
/*** IUnknown methods ***/
/*** IWineD3Dquery methods ***/
};
{
/*** IUnknown methods ***/
/*** IWineD3Dquery methods ***/
};