Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Alchemy Viewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Silent mode is enabled
All outbound communications are blocked.
Learn more
.
Show more breadcrumbs
Alchemy Viewer
Alchemy Viewer
Commits
01e0de0b
Commit
01e0de0b
authored
3 years ago
by
Rye Mutt
Browse files
Options
Downloads
Patches
Plain Diff
Allow pixel format and type to be specified for render target color attachments
parent
962d9355
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
indra/llrender/llrendertarget.cpp
+14
-27
14 additions, 27 deletions
indra/llrender/llrendertarget.cpp
indra/llrender/llrendertarget.h
+3
-3
3 additions, 3 deletions
indra/llrender/llrendertarget.h
with
17 additions
and
30 deletions
indra/llrender/llrendertarget.cpp
+
14
−
27
View file @
01e0de0b
...
@@ -43,7 +43,7 @@ void check_framebuffer_status()
...
@@ -43,7 +43,7 @@ void check_framebuffer_status()
case
GL_FRAMEBUFFER_COMPLETE
:
case
GL_FRAMEBUFFER_COMPLETE
:
break
;
break
;
default:
default:
LL_WARNS
()
<<
"check_framebuffer_status failed -- "
<<
std
::
hex
<<
status
<<
LL_ENDL
;
LL_WARNS
()
<<
"check_framebuffer_status failed -- "
<<
std
::
hex
<<
status
<<
std
::
dec
<<
LL_ENDL
;
ll_fail
(
"check_framebuffer_status failed"
);
ll_fail
(
"check_framebuffer_status failed"
);
break
;
break
;
}
}
...
@@ -92,7 +92,9 @@ void LLRenderTarget::resize(U32 resx, U32 resy)
...
@@ -92,7 +92,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
,
NULL
,
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)
{
{
gGL
.
getTexUnit
(
0
)
->
bindManual
(
mUsage
,
mDepth
);
gGL
.
getTexUnit
(
0
)
->
bindManual
(
mUsage
,
mDepth
);
U32
internal_type
=
LLTexUnit
::
getInternalType
(
mUsage
);
U32
internal_type
=
LLTexUnit
::
getInternalType
(
mUsage
);
LLImageGL
::
setManualImage
(
internal_type
,
0
,
GL_DEPTH_COMPONENT24
,
mResX
,
mResY
,
GL_DEPTH_COMPONENT
,
GL_UNSIGNED_INT
,
NULL
,
false
);
LLImageGL
::
setManualImage
(
internal_type
,
0
,
GL_DEPTH_COMPONENT24
,
mResX
,
mResY
,
GL_DEPTH_COMPONENT
,
GL_UNSIGNED_INT
,
nullptr
,
false
);
}
}
sBytesAllocated
+=
pix_diff
*
4
;
sBytesAllocated
+=
pix_diff
*
4
;
...
@@ -117,7 +119,7 @@ void LLRenderTarget::resize(U32 resx, U32 resy)
...
@@ -117,7 +119,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
);
...
@@ -167,10 +169,10 @@ bool LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, boo
...
@@ -167,10 +169,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
)
{
{
...
@@ -202,10 +204,10 @@ bool LLRenderTarget::addColorAttachment(U32 color_fmt)
...
@@ -202,10 +204,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
,
NULL
,
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
;
}
}
}
}
...
@@ -252,7 +254,7 @@ bool LLRenderTarget::addColorAttachment(U32 color_fmt)
...
@@ -252,7 +254,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
)
...
@@ -290,14 +292,14 @@ bool LLRenderTarget::allocateDepth()
...
@@ -290,14 +292,14 @@ bool LLRenderTarget::allocateDepth()
gGL
.
getTexUnit
(
0
)
->
setTextureFilteringOption
(
LLTexUnit
::
TFO_POINT
);
gGL
.
getTexUnit
(
0
)
->
setTextureFilteringOption
(
LLTexUnit
::
TFO_POINT
);
}
}
sBytesAllocated
+=
mResX
*
mResY
*
4
;
if
(
glGetError
()
!=
GL_NO_ERROR
)
if
(
glGetError
()
!=
GL_NO_ERROR
)
{
{
LL_WARNS
()
<<
"Unable to allocate depth buffer for render target."
<<
LL_ENDL
;
LL_WARNS
()
<<
"Unable to allocate depth buffer for render target."
<<
LL_ENDL
;
return
false
;
return
false
;
}
}
sBytesAllocated
+=
mResX
*
mResY
*
4
;
return
true
;
return
true
;
}
}
...
@@ -490,22 +492,6 @@ U32 LLRenderTarget::getNumTextures() const
...
@@ -490,22 +492,6 @@ U32 LLRenderTarget::getNumTextures() const
void
LLRenderTarget
::
bindTexture
(
U32
index
,
S32
channel
,
LLTexUnit
::
eTextureFilterOptions
filter_options
,
LLTexUnit
::
eTextureColorSpace
color_space
)
void
LLRenderTarget
::
bindTexture
(
U32
index
,
S32
channel
,
LLTexUnit
::
eTextureFilterOptions
filter_options
,
LLTexUnit
::
eTextureColorSpace
color_space
)
{
{
gGL
.
getTexUnit
(
channel
)
->
bindManual
(
mUsage
,
getTexture
(
index
));
gGL
.
getTexUnit
(
channel
)
->
bindManual
(
mUsage
,
getTexture
(
index
));
bool
isSRGB
=
false
;
llassert
(
mInternalFormat
.
size
()
>
index
);
switch
(
mInternalFormat
[
index
])
{
case
GL_SRGB
:
case
GL_SRGB8
:
case
GL_SRGB_ALPHA
:
case
GL_SRGB8_ALPHA8
:
isSRGB
=
true
;
break
;
default:
break
;
}
gGL
.
getTexUnit
(
channel
)
->
setTextureFilteringOption
(
filter_options
);
gGL
.
getTexUnit
(
channel
)
->
setTextureFilteringOption
(
filter_options
);
gGL
.
getTexUnit
(
channel
)
->
setTextureColorSpace
(
color_space
);
gGL
.
getTexUnit
(
channel
)
->
setTextureColorSpace
(
color_space
);
}
}
...
@@ -517,6 +503,7 @@ void LLRenderTarget::flush(bool fetch_depth)
...
@@ -517,6 +503,7 @@ void LLRenderTarget::flush(bool fetch_depth)
{
{
gGL
.
getTexUnit
(
0
)
->
bind
(
this
);
gGL
.
getTexUnit
(
0
)
->
bind
(
this
);
glCopyTexSubImage2D
(
LLTexUnit
::
getInternalType
(
mUsage
),
0
,
0
,
0
,
0
,
0
,
mResX
,
mResY
);
glCopyTexSubImage2D
(
LLTexUnit
::
getInternalType
(
mUsage
),
0
,
0
,
0
,
0
,
0
,
mResX
,
mResY
);
stop_glerror
();
if
(
fetch_depth
)
if
(
fetch_depth
)
{
{
...
...
This diff is collapsed.
Click to expand it.
indra/llrender/llrendertarget.h
+
3
−
3
View file @
01e0de0b
...
@@ -73,7 +73,7 @@ class LLRenderTarget
...
@@ -73,7 +73,7 @@ class LLRenderTarget
//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
...
@@ -83,7 +83,7 @@ class LLRenderTarget
...
@@ -83,7 +83,7 @@ class LLRenderTarget
//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
();
...
@@ -147,7 +147,7 @@ class LLRenderTarget
...
@@ -147,7 +147,7 @@ class LLRenderTarget
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
;
U32
mPreviousFBO
;
U32
mPreviousFBO
;
U32
mPreviousResX
;
U32
mPreviousResX
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment