aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llrender/llrendertarget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llrender/llrendertarget.cpp')
-rw-r--r--linden/indra/llrender/llrendertarget.cpp56
1 files changed, 23 insertions, 33 deletions
diff --git a/linden/indra/llrender/llrendertarget.cpp b/linden/indra/llrender/llrendertarget.cpp
index e18ec56..9d693a7 100644
--- a/linden/indra/llrender/llrendertarget.cpp
+++ b/linden/indra/llrender/llrendertarget.cpp
@@ -47,7 +47,7 @@ LLRenderTarget::LLRenderTarget() :
47 mStencil(0), 47 mStencil(0),
48 mUseDepth(FALSE), 48 mUseDepth(FALSE),
49 mRenderDepth(FALSE), 49 mRenderDepth(FALSE),
50 mUsage(GL_TEXTURE_2D) 50 mUsage(LLTexUnit::TT_TEXTURE)
51{ 51{
52} 52}
53 53
@@ -56,7 +56,7 @@ LLRenderTarget::~LLRenderTarget()
56 release(); 56 release();
57} 57}
58 58
59void LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, U32 usage, BOOL use_fbo) 59void LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, LLTexUnit::eTextureType usage, BOOL use_fbo)
60{ 60{
61 stop_glerror(); 61 stop_glerror();
62 mResX = resx; 62 mResX = resx;
@@ -67,22 +67,22 @@ void LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, U32
67 release(); 67 release();
68 68
69 glGenTextures(1, (GLuint *) &mTex); 69 glGenTextures(1, (GLuint *) &mTex);
70 glBindTexture(mUsage, mTex); 70 gGL.getTexUnit(0)->bindManual(mUsage, mTex);
71 glTexImage2D(mUsage, 0, color_fmt, mResX, mResY, 0, color_fmt, GL_UNSIGNED_BYTE, NULL); 71 glTexImage2D(LLTexUnit::getInternalType(mUsage), 0, color_fmt, mResX, mResY, 0, color_fmt, GL_UNSIGNED_BYTE, NULL);
72 72
73 glTexParameteri(mUsage, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 73 glTexParameteri(LLTexUnit::getInternalType(mUsage), GL_TEXTURE_MAG_FILTER, GL_LINEAR);
74 glTexParameteri(mUsage, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 74 glTexParameteri(LLTexUnit::getInternalType(mUsage), GL_TEXTURE_MIN_FILTER, GL_LINEAR);
75 75
76 if (mUsage != GL_TEXTURE_RECTANGLE_ARB) 76 if (mUsage != LLTexUnit::TT_RECT_TEXTURE)
77 { 77 {
78 glTexParameteri(mUsage, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT); 78 glTexParameteri(LLTexUnit::getInternalType(mUsage), GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
79 glTexParameteri(mUsage, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT); 79 glTexParameteri(LLTexUnit::getInternalType(mUsage), GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
80 } 80 }
81 else 81 else
82 { 82 {
83 // ATI doesn't support mirrored repeat for rectangular textures. 83 // ATI doesn't support mirrored repeat for rectangular textures.
84 glTexParameteri(mUsage, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 84 glTexParameteri(LLTexUnit::getInternalType(mUsage), GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
85 glTexParameteri(mUsage, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 85 glTexParameteri(LLTexUnit::getInternalType(mUsage), GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
86 } 86 }
87 87
88 stop_glerror(); 88 stop_glerror();
@@ -107,14 +107,14 @@ void LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, U32
107 107
108 if (mDepth) 108 if (mDepth)
109 { 109 {
110 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, mUsage, mDepth, 0); 110 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, LLTexUnit::getInternalType(mUsage), mDepth, 0);
111 stop_glerror(); 111 stop_glerror();
112 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, mUsage, mDepth, 0); 112 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, LLTexUnit::getInternalType(mUsage), mDepth, 0);
113 stop_glerror(); 113 stop_glerror();
114 } 114 }
115 115
116 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, 116 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
117 mUsage, mTex, 0); 117 LLTexUnit::getInternalType(mUsage), mTex, 0);
118 stop_glerror(); 118 stop_glerror();
119 119
120 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 120 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
@@ -125,10 +125,11 @@ void LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, U32
125void LLRenderTarget::allocateDepth() 125void LLRenderTarget::allocateDepth()
126{ 126{
127 glGenTextures(1, (GLuint *) &mDepth); 127 glGenTextures(1, (GLuint *) &mDepth);
128 glBindTexture(mUsage, mDepth); 128 gGL.getTexUnit(0)->bindManual(mUsage, mDepth);
129 glTexParameteri(mUsage, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 129 U32 internal_type = LLTexUnit::getInternalType(mUsage);
130 glTexParameteri(mUsage, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 130 glTexParameteri(internal_type, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
131 glTexImage2D(mUsage, 0, GL_DEPTH24_STENCIL8_EXT, mResX, mResY, 0, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, NULL); 131 glTexParameteri(internal_type, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
132 glTexImage2D(internal_type, 0, GL_DEPTH24_STENCIL8_EXT, mResX, mResY, 0, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, NULL);
132} 133}
133 134
134void LLRenderTarget::release() 135void LLRenderTarget::release()
@@ -191,24 +192,13 @@ void LLRenderTarget::clear()
191 } 192 }
192} 193}
193 194
194void LLRenderTarget::bindTexture()
195{
196 glBindTexture(mUsage, mTex);
197}
198
199void LLRenderTarget::bindDepth()
200{
201 glBindTexture(mUsage, mDepth);
202}
203
204
205void LLRenderTarget::flush(BOOL fetch_depth) 195void LLRenderTarget::flush(BOOL fetch_depth)
206{ 196{
207 gGL.flush(); 197 gGL.flush();
208 if (!mFBO) 198 if (!mFBO)
209 { 199 {
210 bindTexture(); 200 gGL.getTexUnit(0)->bind(this);
211 glCopyTexSubImage2D(mUsage, 0, 0, 0, 0, 0, mResX, mResY); 201 glCopyTexSubImage2D(LLTexUnit::getInternalType(mUsage), 0, 0, 0, 0, 0, mResX, mResY);
212 202
213 if (fetch_depth) 203 if (fetch_depth)
214 { 204 {
@@ -217,8 +207,8 @@ void LLRenderTarget::flush(BOOL fetch_depth)
217 allocateDepth(); 207 allocateDepth();
218 } 208 }
219 209
220 bindDepth(); 210 gGL.getTexUnit(0)->bind(this, true);
221 glCopyTexImage2D(mUsage, 0, GL_DEPTH24_STENCIL8_EXT, 0, 0, mResX, mResY, 0); 211 glCopyTexImage2D(LLTexUnit::getInternalType(mUsage), 0, GL_DEPTH24_STENCIL8_EXT, 0, 0, mResX, mResY, 0);
222 } 212 }
223 } 213 }
224 else 214 else