1 // SwiftShader Software Renderer
\r
3 // Copyright(c) 2005-2012 TransGaming Inc.
\r
5 // All rights reserved. No part of this software may be copied, distributed, transmitted,
\r
6 // transcribed, stored in a retrieval system, translated into any human or computer
\r
7 // language by any means, or disclosed to third parties without the explicit written
\r
8 // agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express
\r
9 // or implied, including but not limited to any patent rights, are granted to you.
\r
12 // Query.cpp: Implements the es2::Query class
\r
17 #include "Common/Thread.hpp"
\r
22 Query::Query(GLuint id, GLenum type) : RefCountObject(id)
\r
42 mQuery = new sw::Query();
\r
46 return error(GL_OUT_OF_MEMORY);
\r
50 Device *device = getDevice();
\r
53 device->addQuery(mQuery);
\r
54 device->setOcclusionEnabled(true);
\r
61 return error(GL_INVALID_OPERATION);
\r
64 Device *device = getDevice();
\r
67 device->removeQuery(mQuery);
\r
68 device->setOcclusionEnabled(false);
\r
74 GLuint Query::getResult()
\r
80 sw::Thread::yield();
\r
84 return (GLuint)mResult;
\r
87 GLboolean Query::isResultAvailable()
\r
97 GLenum Query::getType() const
\r
102 GLboolean Query::testQuery()
\r
104 if(mQuery != NULL && mStatus != GL_TRUE)
\r
106 if(!mQuery->building && mQuery->reference == 0)
\r
108 unsigned int numPixels = mQuery->data;
\r
113 case GL_ANY_SAMPLES_PASSED_EXT:
\r
114 case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
\r
115 mResult = (numPixels > 0) ? GL_TRUE : GL_FALSE;
\r
125 return GL_TRUE; // Prevent blocking when query is null
\r