Commit 4004e2a9 by Nicolas Capens Committed by Nicolas Capens

Eliminate GL queries.

Bug 18591036 Change-Id: I1cc1539ca1f64da5706cda3405e1f9982fc56bae Reviewed-on: https://swiftshader-review.googlesource.com/1554Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent faef5e4e
......@@ -19,7 +19,6 @@
#include "utilities.h"
#include "Fence.h"
#include "Program.h"
#include "Query.h"
#include "Renderbuffer.h"
#include "Shader.h"
#include "Texture.h"
......@@ -537,30 +536,6 @@ void Context::setActiveSampler(unsigned int active)
mState.activeSampler = active;
}
GLuint Context::getActiveQuery(GLenum target) const
{
Query *queryObject = NULL;
switch(target)
{
case GL_ANY_SAMPLES_PASSED_EXT:
queryObject = mState.activeQuery[QUERY_ANY_SAMPLES_PASSED].get();
break;
case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
queryObject = mState.activeQuery[QUERY_ANY_SAMPLES_PASSED_CONSERVATIVE].get();
break;
default:
ASSERT(false);
}
if(queryObject)
{
return queryObject->id();
}
return 0;
}
void Context::setEnableVertexAttribArray(unsigned int attribNum, bool enabled)
{
mState.vertexAttribute[attribNum].mArrayEnabled = enabled;
......
......@@ -60,7 +60,6 @@ class DepthStencilbuffer;
class VertexDataManager;
class IndexDataManager;
class Fence;
class Query;
enum
{
......@@ -78,14 +77,6 @@ enum
IMPLEMENTATION_COLOR_READ_TYPE = GL_UNSIGNED_SHORT_5_6_5
};
enum QueryType
{
QUERY_ANY_SAMPLES_PASSED,
QUERY_ANY_SAMPLES_PASSED_CONSERVATIVE,
QUERY_TYPE_COUNT
};
const float ALIASED_LINE_WIDTH_RANGE_MIN = 1.0f;
const float ALIASED_LINE_WIDTH_RANGE_MAX = 1.0f;
const float ALIASED_POINT_SIZE_RANGE_MIN = 0.125f;
......@@ -221,7 +212,6 @@ struct State
egl::Image *stencilBuffer;
VertexAttribute vertexAttribute[MAX_VERTEX_ATTRIBS];
BindingPointer<Query> activeQuery[QUERY_TYPE_COUNT];
GLint unpackAlignment;
GLint packAlignment;
......@@ -297,8 +287,6 @@ public:
void setActiveSampler(unsigned int active);
GLuint getActiveQuery(GLenum target) const;
void setEnableVertexAttribArray(unsigned int attribNum, bool enabled);
const VertexAttribute &getVertexAttribState(unsigned int attribNum);
void setVertexAttribState(unsigned int attribNum, sw::Resource *buffer, GLint size, GLenum type,
......
// SwiftShader Software Renderer
//
// Copyright(c) 2005-2012 TransGaming Inc.
//
// All rights reserved. No part of this software may be copied, distributed, transmitted,
// transcribed, stored in a retrieval system, translated into any human or computer
// language by any means, or disclosed to third parties without the explicit written
// agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express
// or implied, including but not limited to any patent rights, are granted to you.
//
// Query.cpp: Implements the es2::Query class
#include "Query.h"
#include "main.h"
#include "Common/Thread.hpp"
namespace es2
{
Query::Query(GLuint id, GLenum type) : RefCountObject(id)
{
mQuery = NULL;
mStatus = GL_FALSE;
mResult = GL_FALSE;
mType = type;
}
Query::~Query()
{
if(mQuery != NULL)
{
delete mQuery;
}
}
void Query::begin()
{
if(mQuery == NULL)
{
mQuery = new sw::Query();
if(!mQuery)
{
return error(GL_OUT_OF_MEMORY);
}
}
Device *device = getDevice();
mQuery->begin();
device->addQuery(mQuery);
device->setOcclusionEnabled(true);
}
void Query::end()
{
if(mQuery == NULL)
{
return error(GL_INVALID_OPERATION);
}
Device *device = getDevice();
mQuery->end();
device->removeQuery(mQuery);
device->setOcclusionEnabled(false);
mStatus = GL_FALSE;
mResult = GL_FALSE;
}
GLuint Query::getResult()
{
if(mQuery != NULL)
{
while(!testQuery())
{
sw::Thread::yield();
}
}
return (GLuint)mResult;
}
GLboolean Query::isResultAvailable()
{
if(mQuery != NULL)
{
testQuery();
}
return mStatus;
}
GLenum Query::getType() const
{
return mType;
}
GLboolean Query::testQuery()
{
if(mQuery != NULL && mStatus != GL_TRUE)
{
if(!mQuery->building && mQuery->reference == 0)
{
unsigned int numPixels = mQuery->data;
mStatus = GL_TRUE;
switch(mType)
{
case GL_ANY_SAMPLES_PASSED_EXT:
case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
mResult = (numPixels > 0) ? GL_TRUE : GL_FALSE;
break;
default:
ASSERT(false);
}
}
return mStatus;
}
return GL_TRUE; // Prevent blocking when query is null
}
}
// SwiftShader Software Renderer
//
// Copyright(c) 2005-2012 TransGaming Inc.
//
// All rights reserved. No part of this software may be copied, distributed, transmitted,
// transcribed, stored in a retrieval system, translated into any human or computer
// language by any means, or disclosed to third parties without the explicit written
// agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express
// or implied, including but not limited to any patent rights, are granted to you.
//
// Query.h: Defines the es2::Query class
#ifndef LIBGLESV2_QUERY_H_
#define LIBGLESV2_QUERY_H_
#include "RefCountObject.h"
#include "Renderer/Renderer.hpp"
#define GL_APICALL
#include <GLES2/gl2.h>
namespace es2
{
class Query : public RefCountObject
{
public:
Query(GLuint id, GLenum type);
virtual ~Query();
void begin();
void end();
GLuint getResult();
GLboolean isResultAvailable();
GLenum getType() const;
private:
GLboolean testQuery();
sw::Query* mQuery;
GLenum mType;
GLboolean mStatus;
GLint mResult;
};
}
#endif // LIBGLESV2_QUERY_H_
......@@ -168,7 +168,6 @@ copy "$(OutDir)libRAD.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"</Comman
<ClCompile Include="libRAD.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="Program.cpp" />
<ClCompile Include="Query.cpp" />
<ClCompile Include="RefCountObject.cpp" />
<ClCompile Include="Renderbuffer.cpp" />
<ClCompile Include="Shader.cpp" />
......@@ -187,7 +186,6 @@ copy "$(OutDir)libRAD.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"</Comman
<ClInclude Include="main.h" />
<ClInclude Include="mathutil.h" />
<ClInclude Include="Program.h" />
<ClInclude Include="Query.h" />
<ClInclude Include="RefCountObject.h" />
<ClInclude Include="Renderbuffer.h" />
<ClInclude Include="resource.h" />
......
......@@ -50,9 +50,6 @@
<ClCompile Include="Image.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Query.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Context.h">
......@@ -103,9 +100,6 @@
<ClInclude Include="..\include\GLES2\gl2platform.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Query.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\common\debug.h">
<Filter>Header Files</Filter>
</ClInclude>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment