Skip to content

Commit 39c7f14

Browse files
author
Rye Mutt
authored
Merge pull request #2415 from RyeMutt/add-cas
Introduce Contrast Adaptive Sharpening post process effect
2 parents 17f515c + ca11567 commit 39c7f14

File tree

14 files changed

+2762
-12
lines changed

14 files changed

+2762
-12
lines changed

indra/llrender/llglslshader.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,6 +1552,34 @@ void LLGLSLShader::uniform4fv(U32 index, U32 count, const GLfloat* v)
15521552
}
15531553
}
15541554

1555+
void LLGLSLShader::uniform4uiv(U32 index, U32 count, const GLuint* v)
1556+
{
1557+
LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
1558+
llassert(sCurBoundShaderPtr == this);
1559+
1560+
if (mProgramObject)
1561+
{
1562+
if (mUniform.size() <= index)
1563+
{
1564+
LL_WARNS_ONCE("Shader") << "Uniform index out of bounds. Size: " << (S32)mUniform.size() << " index: " << index << LL_ENDL;
1565+
llassert(false);
1566+
return;
1567+
}
1568+
1569+
if (mUniform[index] >= 0)
1570+
{
1571+
const auto& iter = mValue.find(mUniform[index]);
1572+
LLVector4 vec((F32)v[0], (F32)v[1], (F32)v[2], (F32)v[3]);
1573+
if (iter == mValue.end() || shouldChange(iter->second, vec) || count != 1)
1574+
{
1575+
LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
1576+
glUniform4uiv(mUniform[index], count, v);
1577+
mValue[mUniform[index]] = vec;
1578+
}
1579+
}
1580+
}
1581+
}
1582+
15551583
void LLGLSLShader::uniformMatrix2fv(U32 index, U32 count, GLboolean transpose, const GLfloat* v)
15561584
{
15571585
LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
@@ -1886,6 +1914,24 @@ void LLGLSLShader::uniform4fv(const LLStaticHashedString& uniform, U32 count, co
18861914
}
18871915
}
18881916

1917+
void LLGLSLShader::uniform4uiv(const LLStaticHashedString& uniform, U32 count, const GLuint* v)
1918+
{
1919+
LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
1920+
GLint location = getUniformLocation(uniform);
1921+
1922+
if (location >= 0)
1923+
{
1924+
LLVector4 vec((F32)v[0], (F32)v[1], (F32)v[2], (F32)v[3]);
1925+
const auto& iter = mValue.find(location);
1926+
if (iter == mValue.end() || shouldChange(iter->second, vec) || count != 1)
1927+
{
1928+
LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
1929+
glUniform4uiv(location, count, v);
1930+
mValue[location] = vec;
1931+
}
1932+
}
1933+
}
1934+
18891935
void LLGLSLShader::uniformMatrix4fv(const LLStaticHashedString& uniform, U32 count, GLboolean transpose, const GLfloat* v)
18901936
{
18911937
LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;

indra/llrender/llglslshader.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ class LLGLSLShader
208208
void uniform2fv(U32 index, U32 count, const GLfloat* v);
209209
void uniform3fv(U32 index, U32 count, const GLfloat* v);
210210
void uniform4fv(U32 index, U32 count, const GLfloat* v);
211+
void uniform4uiv(U32 index, U32 count, const GLuint* v);
211212
void uniform2i(const LLStaticHashedString& uniform, GLint i, GLint j);
212213
void uniformMatrix2fv(U32 index, U32 count, GLboolean transpose, const GLfloat* v);
213214
void uniformMatrix3fv(U32 index, U32 count, GLboolean transpose, const GLfloat* v);
@@ -223,6 +224,7 @@ class LLGLSLShader
223224
void uniform2fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v);
224225
void uniform3fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v);
225226
void uniform4fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v);
227+
void uniform4uiv(const LLStaticHashedString& uniform, U32 count, const GLuint* v);
226228
void uniformMatrix4fv(const LLStaticHashedString& uniform, U32 count, GLboolean transpose, const GLfloat* v);
227229

228230
void setMinimumAlpha(F32 minimum);

indra/llrender/llimagegl.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,12 @@ S32 LLImageGL::dataFormatBits(S32 dataformat)
316316
case GL_RG16F: return 32;
317317
case GL_RGB16F: return 48;
318318
case GL_RGBA16F: return 64;
319+
case GL_R32F: return 32;
320+
case GL_RG32F: return 64;
321+
case GL_RGB32F: return 96;
322+
case GL_RGBA32F: return 128;
319323
default:
320-
LL_ERRS() << "LLImageGL::Unknown format: " << dataformat << LL_ENDL;
324+
LL_ERRS() << "LLImageGL::Unknown format: " << std::hex << dataformat << std::dec << LL_ENDL;
321325
return 0;
322326
}
323327
}
@@ -367,7 +371,7 @@ S32 LLImageGL::dataFormatComponents(S32 dataformat)
367371
case GL_SRGB_ALPHA: return 4;
368372
case GL_BGRA: return 4; // Used for QuickTime media textures on the Mac
369373
default:
370-
LL_ERRS() << "LLImageGL::Unknown format: " << dataformat << LL_ENDL;
374+
LL_ERRS() << "LLImageGL::Unknown format: " << std::hex << dataformat << std::dec << LL_ENDL;
371375
return 0;
372376
}
373377
}

indra/llrender/llshadermgr.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,8 +595,6 @@ GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_lev
595595
extra_code_text[extra_code_count++] = strdup("precision highp float;\n");
596596
}
597597
}
598-
599-
extra_code_text[extra_code_count++] = strdup("#define FXAA_GLSL_130 1\n");
600598
}
601599

602600
// Use alpha float to store bit flags

indra/newview/app_settings/settings.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9810,6 +9810,17 @@
98109810
<key>Value</key>
98119811
<string>00000000-0000-0000-0000-000000000000</string>
98129812
</map>
9813+
<key>RenderCASSharpness</key>
9814+
<map>
9815+
<key>Comment</key>
9816+
<string>Level of sharpening to apply via Contrast Adaptive Sharpening (0.0(off) - 1.0)</string>
9817+
<key>Persist</key>
9818+
<integer>1</integer>
9819+
<key>Type</key>
9820+
<string>F32</string>
9821+
<key>Value</key>
9822+
<real>0.4</real>
9823+
</map>
98139824
<key>ReplaySession</key>
98149825
<map>
98159826
<key>Comment</key>

0 commit comments

Comments
 (0)