LLGLState::sStateMap now using hash map (boost::unordered_map) opposed to std::map

This commit is contained in:
Shyotl
2011-03-24 05:03:21 -05:00
parent 23e1521a6b
commit 0150bac422
2 changed files with 28 additions and 4 deletions

View File

@@ -1056,7 +1056,7 @@ void clear_glerror()
//
// Static members
std::map<LLGLenum, LLGLboolean> LLGLState::sStateMap;
boost::unordered_map<LLGLenum, LLGLboolean> LLGLState::sStateMap;
GLboolean LLGLDepthTest::sDepthEnabled = GL_FALSE; // OpenGL default
GLenum LLGLDepthTest::sDepthFunc = GL_LESS; // OpenGL default
@@ -1104,7 +1104,7 @@ void LLGLState::resetTextureStates()
void LLGLState::dumpStates()
{
LL_INFOS("RenderState") << "GL States:" << LL_ENDL;
for (std::map<LLGLenum, LLGLboolean>::iterator iter = sStateMap.begin();
for (boost::unordered_map<LLGLenum, LLGLboolean>::iterator iter = sStateMap.begin();
iter != sStateMap.end(); ++iter)
{
LL_INFOS("RenderState") << llformat(" 0x%04x : %s",(S32)iter->first,iter->second?"TRUE":"FALSE") << LL_ENDL;
@@ -1130,7 +1130,7 @@ void LLGLState::checkStates(const std::string& msg)
LL_GL_ERRS << "Blend function corrupted: " << std::hex << src << " " << std::hex << dst << " " << msg << std::dec << LL_ENDL;
}
for (std::map<LLGLenum, LLGLboolean>::iterator iter = sStateMap.begin();
for (boost::unordered_map<LLGLenum, LLGLboolean>::iterator iter = sStateMap.begin();
iter != sStateMap.end(); ++iter)
{
LLGLenum state = iter->first;
@@ -1769,6 +1769,8 @@ LLGLDepthTest::LLGLDepthTest(GLboolean depth_enabled, GLboolean write_enabled, G
: mPrevDepthEnabled(sDepthEnabled), mPrevDepthFunc(sDepthFunc), mPrevWriteEnabled(sWriteEnabled)
{
stop_glerror();
checkState();
if (!depth_enabled)
{ // always disable depth writes if depth testing is disabled
@@ -1800,6 +1802,7 @@ LLGLDepthTest::LLGLDepthTest(GLboolean depth_enabled, GLboolean write_enabled, G
LLGLDepthTest::~LLGLDepthTest()
{
checkState();
if (sDepthEnabled != mPrevDepthEnabled )
{
gGL.flush();
@@ -1821,6 +1824,26 @@ LLGLDepthTest::~LLGLDepthTest()
}
}
void LLGLDepthTest::checkState()
{
if (gDebugGL)
{
GLint func = 0;
GLboolean mask = FALSE;
glGetIntegerv(GL_DEPTH_FUNC, &func);
glGetBooleanv(GL_DEPTH_WRITEMASK, &mask);
if (glIsEnabled(GL_DEPTH_TEST) != sDepthEnabled ||
sWriteEnabled != mask ||
sDepthFunc != func)
{
{
LL_GL_ERRS << "Unexpected depth testing state." << LL_ENDL;
}
}
}
}
LLGLSquashToFarClip::LLGLSquashToFarClip(glh::matrix4f P)
{
for (U32 i = 0; i < 4; i++)

View File

@@ -36,6 +36,7 @@
// This file contains various stuff for handling gl extensions and other gl related stuff.
#include <string>
#include <boost/unordered_map.hpp>
#include <map>
#include "llerror.h"
@@ -233,7 +234,7 @@ public:
static void checkClientArrays(const std::string& msg = "", U32 data_mask = 0x0001);
protected:
static std::map<LLGLenum, LLGLboolean> sStateMap;
static boost::unordered_map<LLGLenum, LLGLboolean> sStateMap;
public:
enum { CURRENT_STATE = -2 };