Merge branch 'future' of git://github.com/Shyotl/SingularityViewer

This commit is contained in:
Siana Gearz
2011-10-18 02:29:49 +02:00
8 changed files with 62 additions and 20 deletions

View File

@@ -68,6 +68,16 @@ BOOL gGLActive = FALSE;
std::ofstream gFailLog;
void* gl_get_proc_address(const char *pStr)
{
void* pPtr = (void*)GLH_EXT_GET_PROC_ADDRESS(pStr);
if(!pPtr)
llinfos << "Failed to find symbol '" << pStr << "'" << llendl;
return pPtr;
}
#undef GLH_EXT_GET_PROC_ADDRESS
#define GLH_EXT_GET_PROC_ADDRESS(p) gl_get_proc_address(p)
void ll_init_fail_log(std::string filename)
{
gFailLog.open(filename.c_str());

View File

@@ -38,6 +38,7 @@
#include "llfile.h"
#include "llrender.h"
#include "llcontrol.h"
#include "llvertexbuffer.h"
#if LL_DARWIN
#include "OpenGL/OpenGL.h"
@@ -133,7 +134,8 @@ BOOL LLGLSLShader::createShader(vector<string> * attributes,
mProgramObject = glCreateProgramObjectARB();
static const LLCachedControl<bool> no_texture_indexing("ShyotlUseLegacyTextureBatching",false);
if (gGLManager.mGLVersion < 3.1f || no_texture_indexing)
static const LLCachedControl<bool> use_legacy_path("ShyotlUseLegacyRenderPath", false); //Legacy does not jive with new batching.
if (gGLManager.mGLVersion < 3.1f || no_texture_indexing || use_legacy_path)
{ //force indexed texture channels to 1 if GL version is old (performance improvement for drivers with poor branching shader model support)
mFeatures.mIndexedTextureChannels = llmin(mFeatures.mIndexedTextureChannels, 1);
}
@@ -259,6 +261,13 @@ void LLGLSLShader::attachObjects(GLhandleARB* objects, S32 count)
BOOL LLGLSLShader::mapAttributes(const vector<string> * attributes)
{
//before linking, make sure reserved attributes always have consistent locations
for (U32 i = 0; i < LLShaderMgr::instance()->mReservedAttribs.size(); i++)
{
const char* name = LLShaderMgr::instance()->mReservedAttribs[i].c_str();
glBindAttribLocationARB(mProgramObject, i, (const GLcharARB *) name);
}
//link the program
BOOL res = link();
@@ -332,7 +341,7 @@ void LLGLSLShader::mapUniform(GLint index, const vector<string> * uniforms)
for (S32 i = 0; i < (S32) LLShaderMgr::instance()->mReservedUniforms.size(); i++)
{
if ( (mUniform[i] == -1)
&& (LLShaderMgr::instance()->mReservedUniforms[i].compare(0, length, name, LLShaderMgr::instance()->mReservedUniforms[i].length()) == 0))
&& (LLShaderMgr::instance()->mReservedUniforms[i] == name))
{
//found it
mUniform[i] = location;
@@ -346,7 +355,7 @@ void LLGLSLShader::mapUniform(GLint index, const vector<string> * uniforms)
for (U32 i = 0; i < uniforms->size(); i++)
{
if ( (mUniform[i+LLShaderMgr::instance()->mReservedUniforms.size()] == -1)
&& ((*uniforms)[i].compare(0, length, name, (*uniforms)[i].length()) == 0))
&& ((*uniforms)[i] == name))
{
//found it
mUniform[i+LLShaderMgr::instance()->mReservedUniforms.size()] = location;
@@ -410,6 +419,7 @@ void LLGLSLShader::bind()
gGL.flush();
if (gGLManager.mHasShaderObjects)
{
LLVertexBuffer::unbind();
glUseProgramObjectARB(mProgramObject);
sCurBoundShader = mProgramObject;
sCurBoundShaderPtr = this;
@@ -435,6 +445,7 @@ void LLGLSLShader::unbind()
stop_glerror();
}
}
LLVertexBuffer::unbind();
glUseProgramObjectARB(0);
sCurBoundShader = 0;
sCurBoundShaderPtr = NULL;
@@ -444,9 +455,13 @@ void LLGLSLShader::unbind()
void LLGLSLShader::bindNoShader(void)
{
glUseProgramObjectARB(0);
sCurBoundShader = 0;
sCurBoundShaderPtr = NULL;
LLVertexBuffer::unbind();
if (gGLManager.mHasShaderObjects)
{
glUseProgramObjectARB(0);
sCurBoundShader = 0;
sCurBoundShaderPtr = NULL;
}
}
S32 LLGLSLShader::enableTexture(S32 uniform, LLTexUnit::eTextureType mode)

View File

@@ -2919,7 +2919,6 @@ BOOL LLWindowWin32::resetDisplayResolution()
void LLWindowWin32::swapBuffers()
{
glFinish();
SwapBuffers(mhDC);
}

View File

@@ -495,7 +495,8 @@ static void settings_to_globals()
static void settings_modify()
{
LLRenderTarget::sUseFBO = gSavedSettings.getBOOL("RenderUseFBO");
bool can_defer = LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred");
LLRenderTarget::sUseFBO = gSavedSettings.getBOOL("RenderUseFBO") || (gSavedSettings.getBOOL("RenderDeferred") && can_defer);
LLVOAvatar::sUseImpostors = gSavedSettings.getBOOL("RenderUseImpostors");
LLVOSurfacePatch::sLODFactor = gSavedSettings.getF32("RenderTerrainLODFactor");
LLVOSurfacePatch::sLODFactor *= LLVOSurfacePatch::sLODFactor; //square lod factor to get exponential range of [1,4]

View File

@@ -826,7 +826,8 @@ void LLDrawPoolAvatar::beginSkinned()
}
}
if (LLGLSLShader::sNoFixedFunction)
//if (LLGLSLShader::sNoFixedFunction) //Singu Note: sNoFixedFunction being false does not imply shaders are off, unlike in V3.
if (gPipeline.canUseVertexShaders()) //Check if shaders are REALLY used.
{
sVertexProgram->setAlphaRange(0.2f, 1.f);
}

View File

@@ -445,17 +445,34 @@ static bool handleRenderLocalLightsChanged(const LLSD& newvalue)
return true;
}
static bool handleRenderDeferredChanged(const LLSD& newvalue)
{
bool can_defer = LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred");
bool old_deferred = !newvalue.asBoolean() && can_defer;
LLRenderTarget::sUseFBO = (newvalue.asBoolean() && can_defer) || gSavedSettings.getBOOL("RenderUseFBO");
if (gPipeline.isInit())
{
gPipeline.updateRenderDeferred();
gPipeline.releaseGLBuffers();
gPipeline.createGLBuffers();
gPipeline.resetVertexBuffers();
if (old_deferred != newvalue.asBoolean())
{
LLViewerShaderMgr::instance()->setShaders();
}
}
return true;
}
static bool handleRenderUseFBOChanged(const LLSD& newvalue)
{
LLRenderTarget::sUseFBO = newvalue.asBoolean();
bool can_defer = LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred");
LLRenderTarget::sUseFBO = newvalue.asBoolean() || (gSavedSettings.getBOOL("RenderDeferred") && can_defer);
if (gPipeline.isInit())
{
gPipeline.releaseGLBuffers();
gPipeline.createGLBuffers();
if (LLPipeline::sRenderDeferred && LLRenderTarget::sUseFBO)
{
LLViewerShaderMgr::instance()->setShaders();
}
gPipeline.resetVertexBuffers();
}
return true;
}
@@ -682,7 +699,7 @@ void settings_setup_listeners()
gSavedSettings.getControl("RenderDebugGL")->getSignal()->connect(boost::bind(&handleRenderDebugGLChanged, _2));
gSavedSettings.getControl("RenderDebugPipeline")->getSignal()->connect(boost::bind(&handleRenderDebugPipelineChanged, _2));
gSavedSettings.getControl("RenderResolutionDivisor")->getSignal()->connect(boost::bind(&handleRenderResolutionDivisorChanged, _2));
gSavedSettings.getControl("RenderDeferred")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
gSavedSettings.getControl("RenderDeferred")->getSignal()->connect(boost::bind(&handleRenderDeferredChanged, _2));
gSavedSettings.getControl("RenderShadowDetail")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
gSavedSettings.getControl("RenderDeferredSSAO")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
gSavedSettings.getControl("RenderDeferredGI")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));

View File

@@ -426,9 +426,6 @@ void LLViewerShaderMgr::setShaders()
deferred_class = 1;
}
//make sure framebuffer objects are enabled
gSavedSettings.setBOOL("RenderUseFBO", TRUE);
//make sure hardware skinning is enabled
gSavedSettings.setBOOL("RenderAvatarVP", TRUE);
}
@@ -655,7 +652,8 @@ BOOL LLViewerShaderMgr::loadBasicShaders()
S32 ch = gGLManager.mNumTextureImageUnits-1;
static const LLCachedControl<bool> no_texture_indexing("ShyotlUseLegacyTextureBatching",false);
if (gGLManager.mGLVersion < 3.1f || no_texture_indexing)
static const LLCachedControl<bool> use_legacy_path("ShyotlUseLegacyRenderPath", false); //Legacy does not jive with new batching.
if (gGLManager.mGLVersion < 3.1f || no_texture_indexing || use_legacy_path)
{ //force to 1 texture index channel for old drivers
ch = 1;
}

View File

@@ -3927,7 +3927,8 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
S32 texture_index_channels = gGLManager.mNumTextureImageUnits-1; //always reserve one for shiny for now just for simplicity
static const LLCachedControl<bool> no_texture_indexing("ShyotlUseLegacyTextureBatching",false);
if (gGLManager.mGLVersion < 3.1f || no_texture_indexing)
static const LLCachedControl<bool> use_legacy_path("ShyotlUseLegacyRenderPath", false); //Legacy does not jive with new batching.
if (gGLManager.mGLVersion < 3.1f || no_texture_indexing || use_legacy_path)
{
texture_index_channels = 1;
}