Skip to content
Snippets Groups Projects
Commit c25a22f0 authored by Rye Mutt's avatar Rye Mutt :bread:
Browse files

Add ability to manually select internal storage formats for render targets

parent 5201d38d
No related branches found
No related tags found
No related merge requests found
...@@ -84,7 +84,9 @@ void LLRenderTarget::resize(U32 resx, U32 resy) ...@@ -84,7 +84,9 @@ void LLRenderTarget::resize(U32 resx, U32 resy)
for (U32 i = 0; i < mTex.size(); ++i) for (U32 i = 0; i < mTex.size(); ++i)
{ //resize color attachments { //resize color attachments
gGL.getTexUnit(0)->bindManual(mUsage, mTex[i]); gGL.getTexUnit(0)->bindManual(mUsage, mTex[i]);
LLImageGL::setManualImage(LLTexUnit::getInternalType(mUsage), 0, mInternalFormat[i], mResX, mResY, GL_RGBA, GL_UNSIGNED_BYTE, nullptr, false); const auto& internal_format = mInternalFormat[i];
LLImageGL::setManualImage(LLTexUnit::getInternalType(mUsage), 0, std::get<0>(internal_format), mResX, mResY,
std::get<1>(internal_format), std::get<2>(internal_format), nullptr, false);
sBytesAllocated += pix_diff*4; sBytesAllocated += pix_diff*4;
} }
...@@ -109,7 +111,7 @@ void LLRenderTarget::resize(U32 resx, U32 resy) ...@@ -109,7 +111,7 @@ void LLRenderTarget::resize(U32 resx, U32 resy)
} }
bool LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, bool stencil, LLTexUnit::eTextureType usage, bool use_fbo, S32 samples) bool LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, bool stencil, LLTexUnit::eTextureType usage, bool use_fbo, S32 samples, U32 pix_format, U32 pix_type)
{ {
resx = llmin(resx, (U32) gGLManager.mGLMaxTextureSize); resx = llmin(resx, (U32) gGLManager.mGLMaxTextureSize);
resy = llmin(resy, (U32) gGLManager.mGLMaxTextureSize); resy = llmin(resy, (U32) gGLManager.mGLMaxTextureSize);
...@@ -159,10 +161,10 @@ bool LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, boo ...@@ -159,10 +161,10 @@ bool LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, boo
stop_glerror(); stop_glerror();
} }
return addColorAttachment(color_fmt); return addColorAttachment(color_fmt, pix_format, pix_type);
} }
bool LLRenderTarget::addColorAttachment(U32 color_fmt) bool LLRenderTarget::addColorAttachment(U32 color_fmt, U32 pix_format, U32 pix_type)
{ {
if (color_fmt == 0) if (color_fmt == 0)
{ {
...@@ -194,10 +196,10 @@ bool LLRenderTarget::addColorAttachment(U32 color_fmt) ...@@ -194,10 +196,10 @@ bool LLRenderTarget::addColorAttachment(U32 color_fmt)
{ {
clear_glerror(); clear_glerror();
LLImageGL::setManualImage(LLTexUnit::getInternalType(mUsage), 0, color_fmt, mResX, mResY, GL_RGBA, GL_UNSIGNED_BYTE, nullptr, false); LLImageGL::setManualImage(LLTexUnit::getInternalType(mUsage), 0, color_fmt, mResX, mResY, pix_format, pix_type, nullptr, false);
if (glGetError() != GL_NO_ERROR) if (glGetError() != GL_NO_ERROR)
{ {
LL_WARNS() << "Could not allocate color buffer for render target." << LL_ENDL; LL_WARNS() << "Could not allocate color buffer for render target." << "format:" << color_fmt << " pixformat:" << pix_format << " pixtype:" << pix_type << LL_ENDL;
return false; return false;
} }
} }
...@@ -235,7 +237,7 @@ bool LLRenderTarget::addColorAttachment(U32 color_fmt) ...@@ -235,7 +237,7 @@ bool LLRenderTarget::addColorAttachment(U32 color_fmt)
} }
mTex.push_back(tex); mTex.push_back(tex);
mInternalFormat.push_back(color_fmt); mInternalFormat.emplace_back(color_fmt, pix_format, pix_type);
#if !LL_DARWIN #if !LL_DARWIN
if (gDebugGL) if (gDebugGL)
......
...@@ -70,7 +70,7 @@ public: ...@@ -70,7 +70,7 @@ public:
//allocate resources for rendering //allocate resources for rendering
//must be called before use //must be called before use
//multiple calls will release previously allocated resources //multiple calls will release previously allocated resources
bool allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, bool stencil, LLTexUnit::eTextureType usage = LLTexUnit::TT_TEXTURE, bool use_fbo = false, S32 samples = 0); bool allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, bool stencil, LLTexUnit::eTextureType usage = LLTexUnit::TT_TEXTURE, bool use_fbo = false, S32 samples = 0, U32 pix_format = GL_RGBA, U32 pix_type = GL_UNSIGNED_BYTE);
//resize existing attachments to use new resolution and color format //resize existing attachments to use new resolution and color format
// CAUTION: if the GL runs out of memory attempting to resize, this render target will be undefined // CAUTION: if the GL runs out of memory attempting to resize, this render target will be undefined
...@@ -80,7 +80,7 @@ public: ...@@ -80,7 +80,7 @@ public:
//add color buffer attachment //add color buffer attachment
//limit of 4 color attachments per render target //limit of 4 color attachments per render target
bool addColorAttachment(U32 color_fmt); bool addColorAttachment(U32 color_fmt, U32 pix_format = GL_RGBA, U32 pix_type = GL_UNSIGNED_BYTE);
//allocate a depth texture //allocate a depth texture
bool allocateDepth(); bool allocateDepth();
...@@ -146,7 +146,7 @@ protected: ...@@ -146,7 +146,7 @@ protected:
U32 mResX; U32 mResX;
U32 mResY; U32 mResY;
std::vector<U32> mTex; std::vector<U32> mTex;
std::vector<U32> mInternalFormat; std::vector<std::tuple<U32, U32, U32> > mInternalFormat;
U32 mFBO; U32 mFBO;
LLRenderTarget* mPreviousFBO; LLRenderTarget* mPreviousFBO;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment