SL-18037 Workaround AMD driver bug (drop reflection probe count to 16 on amd)

master
Dave Parks 2022-08-29 18:46:48 -05:00
parent d6e8a6c98a
commit 9c6b197b3e
4 changed files with 51 additions and 23 deletions

View File

@ -10313,6 +10313,17 @@
<key>Value</key>
<integer>1</integer>
</map>
<key>RenderReflectionProbeCount</key>
<map>
<key>Comment</key>
<string>Number of reflection probes (maximum is 256, requires restart)</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>S32</string>
<key>Value</key>
<integer>256</integer>
</map>
<key>RenderReflectionProbeDrawDistance</key>
<map>

View File

@ -1,4 +1,4 @@
version 35
version 36
// The version number above should be incremented IF AND ONLY IF some
// change has been made that is sufficiently important to justify
// resetting the graphics preferences of all users to the recommended
@ -64,6 +64,7 @@ RenderTextureMemoryMultiple 1 1.0
RenderCompressTextures 1 1
RenderShaderLightingMaxLevel 1 3
RenderPBR 1 1
RenderReflectionProbeCount 1 256
RenderDeferred 1 1
RenderDeferredSSAO 1 1
RenderUseAdvancedAtmospherics 1 0
@ -291,8 +292,11 @@ RenderGLContextCoreProfile 1 0
// AMD cards generally perform better when not using VBOs for streaming data
// AMD cards also prefer an OpenGL Compatibility Profile Context
// HACK: Current AMD drivers have bugged cubemap arrays, limit number of reflection probes to 16
list AMD
RenderUseStreamVBO 1 0
RenderGLContextCoreProfile 1 0
RenderReflectionProbeCount 1 16

View File

@ -40,7 +40,7 @@ extern BOOL gTeleportDisplay;
LLReflectionMapManager::LLReflectionMapManager()
{
for (int i = 0; i < LL_REFLECTION_PROBE_COUNT; ++i)
for (int i = 0; i < LL_MAX_REFLECTION_PROBE_COUNT; ++i)
{
mCubeFree[i] = true;
}
@ -76,16 +76,7 @@ void LLReflectionMapManager::update()
}
// =============== TODO -- move to an init function =================
if (mTexture.isNull())
{
mTexture = new LLCubeMapArray();
// store LL_REFLECTION_PROBE_COUNT+2 cube maps, final two cube maps are used for render target and radiance map generation source)
mTexture->allocate(LL_REFLECTION_PROBE_RESOLUTION, 3, LL_REFLECTION_PROBE_COUNT+2);
mIrradianceMaps = new LLCubeMapArray();
mIrradianceMaps->allocate(LL_IRRADIANCE_MAP_RESOLUTION, 3, LL_REFLECTION_PROBE_COUNT);
}
initReflectionMaps();
if (!mRenderTarget.isComplete())
{
@ -167,7 +158,7 @@ void LLReflectionMapManager::update()
LLVector4a d;
if (!did_update &&
i < LL_REFLECTION_PROBE_COUNT &&
i < mReflectionProbeCount &&
(oldestProbe == nullptr || probe->mLastUpdateTime < oldestProbe->mLastUpdateTime))
{
oldestProbe = probe;
@ -317,7 +308,7 @@ LLReflectionMap* LLReflectionMapManager::registerViewerObject(LLViewerObject* vo
S32 LLReflectionMapManager::allocateCubeIndex()
{
for (int i = 0; i < LL_REFLECTION_PROBE_COUNT; ++i)
for (int i = 0; i < mReflectionProbeCount; ++i)
{
if (mCubeFree[i])
{
@ -327,7 +318,7 @@ S32 LLReflectionMapManager::allocateCubeIndex()
}
// no cubemaps free, steal one from the back of the probe list
for (int i = mProbes.size() - 1; i >= LL_REFLECTION_PROBE_COUNT; --i)
for (int i = mProbes.size() - 1; i >= mReflectionProbeCount; --i)
{
if (mProbes[i]->mCubeIndex != -1)
{
@ -392,7 +383,7 @@ void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face)
gPipeline.mRT = &gPipeline.mMainRT;
mRenderTarget.flush();
S32 targetIdx = LL_REFLECTION_PROBE_COUNT;
S32 targetIdx = mReflectionProbeCount;
if (probe != mUpdatingProbe)
{ // this is the "realtime" probe that's updating every frame, use the secondary scratch space channel
@ -625,15 +616,15 @@ void LLReflectionMapManager::updateUniforms()
// see class3/deferred/reflectionProbeF.glsl
struct ReflectionProbeData
{
LLMatrix4 refBox[LL_REFLECTION_PROBE_COUNT]; // object bounding box as needed
LLVector4 refSphere[LL_REFLECTION_PROBE_COUNT]; //origin and radius of refmaps in clip space
LLVector4 refParams[LL_REFLECTION_PROBE_COUNT]; //extra parameters (currently only ambiance)
GLint refIndex[LL_REFLECTION_PROBE_COUNT][4];
LLMatrix4 refBox[LL_MAX_REFLECTION_PROBE_COUNT]; // object bounding box as needed
LLVector4 refSphere[LL_MAX_REFLECTION_PROBE_COUNT]; //origin and radius of refmaps in clip space
LLVector4 refParams[LL_MAX_REFLECTION_PROBE_COUNT]; //extra parameters (currently only ambiance)
GLint refIndex[LL_MAX_REFLECTION_PROBE_COUNT][4];
GLint refNeighbor[4096];
GLint refmapCount;
};
mReflectionMaps.resize(LL_REFLECTION_PROBE_COUNT);
mReflectionMaps.resize(mReflectionProbeCount);
getReflectionMaps(mReflectionMaps);
ReflectionProbeData rpd;
@ -830,3 +821,19 @@ void LLReflectionMapManager::renderDebug()
gDebugProgram.unbind();
}
void LLReflectionMapManager::initReflectionMaps()
{
if (mTexture.isNull())
{
mReflectionProbeCount = llclamp(gSavedSettings.getS32("RenderReflectionProbeCount"), 1, LL_MAX_REFLECTION_PROBE_COUNT);
mTexture = new LLCubeMapArray();
// store mReflectionProbeCount+2 cube maps, final two cube maps are used for render target and radiance map generation source)
mTexture->allocate(LL_REFLECTION_PROBE_RESOLUTION, 3, mReflectionProbeCount + 2);
mIrradianceMaps = new LLCubeMapArray();
mIrradianceMaps->allocate(LL_IRRADIANCE_MAP_RESOLUTION, 3, mReflectionProbeCount);
}
}

View File

@ -35,7 +35,7 @@ class LLSpatialGroup;
class LLViewerObject;
// number of reflection probes to keep in vram
#define LL_REFLECTION_PROBE_COUNT 256
#define LL_MAX_REFLECTION_PROBE_COUNT 256
// reflection probe resolution
#define LL_REFLECTION_PROBE_RESOLUTION 256
@ -88,6 +88,9 @@ public:
// probe debug display is active
void renderDebug();
// call once at startup to allocate cubemap arrays
void initReflectionMaps();
private:
friend class LLPipeline;
@ -120,7 +123,7 @@ private:
LLPointer<LLCubeMapArray> mIrradianceMaps;
// array indicating if a particular cubemap is free
bool mCubeFree[LL_REFLECTION_PROBE_COUNT];
bool mCubeFree[LL_MAX_REFLECTION_PROBE_COUNT];
// start tracking the given spatial group
void trackGroup(LLSpatialGroup* group);
@ -148,5 +151,8 @@ private:
LLReflectionMap* mUpdatingProbe = nullptr;
U32 mUpdatingFace = 0;
// number of reflection probes to use for rendering (based on saved setting RenderReflectionProbeCount)
U32 mReflectionProbeCount;
};