Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 908 vs 909 for /trunk/Source Code/Rendering/PostFX/PreRenderBatch.cpp

Diff revisions: vs.
  @@ -44,9 +44,14 @@
44 44 assert(_postFXOutput._targetID._usage == RenderTargetUsage::COUNT);
45 45 _renderTarget = renderTarget;
46 46
47 - _previousLuminance = _context.allocateRT("PreviousLuminance");
48 - _currentLuminance = _context.allocateRT("Luminance");
49 - _postFXOutput = _context.allocateRT("PostFXOutput");
47 + const RenderTarget& rt = inputRT();
48 + // make the texture square sized and power of two
49 + U16 lumaRez = to_U16(nextPOW2(to_U32(rt.getWidth() / 3.0f)));
50 +
51 + _previousLuminance = _context.allocateRT(vec2<U16>(1), "PreviousLuminance");
52 + _currentLuminance = _context.allocateRT(vec2<U16>(lumaRez), "Luminance");
53 +
54 + _postFXOutput = _context.allocateRT(vec2<U16>(rt.getWidth(), rt.getHeight()), "PostFXOutput");
50 55 SamplerDescriptor screenSampler;
51 56 screenSampler.setWrapMode(TextureWrap::CLAMP_TO_EDGE);
52 57 screenSampler.setFilters(TextureFilter::LINEAR);
  @@ -58,6 +63,7 @@
58 63 outputDescriptor.setSampler(screenSampler);
59 64 //Colour0 holds the LDR screen texture
60 65 _postFXOutput._rt->addAttachment(outputDescriptor, RTAttachment::Type::Colour, 0);
66 + _postFXOutput._rt->create();
61 67
62 68 SamplerDescriptor lumaSampler;
63 69 lumaSampler.setWrapMode(TextureWrap::CLAMP_TO_EDGE);
  @@ -69,11 +75,13 @@
69 75 lumaDescriptor.setSampler(lumaSampler);
70 76 lumaDescriptor.toggleAutomaticMipMapGeneration(false);
71 77 _currentLuminance._rt->addAttachment(lumaDescriptor, RTAttachment::Type::Colour, 0);
78 + _currentLuminance._rt->create();
72 79
73 80 lumaSampler.setFilters(TextureFilter::LINEAR);
74 81 lumaDescriptor.setSampler(lumaSampler);
75 82 _previousLuminance._rt->addAttachment(lumaDescriptor, RTAttachment::Type::Colour, 0);
76 83 _previousLuminance._rt->setClearColour(RTAttachment::Type::COUNT, 0, DefaultColours::BLACK());
84 + _previousLuminance._rt->create();
77 85
78 86 // Order is very important!
79 87 OperatorBatch& hdrBatch = _operators[to_base(FilterSpace::FILTER_SPACE_HDR)];
  @@ -182,16 +190,17 @@
182 190 }
183 191
184 192 void PreRenderBatch::reshape(U16 width, U16 height) {
185 - U16 lumaRez = to_U16(nextPOW2(to_U32(width / 3.0f)));
186 193 // make the texture square sized and power of two
187 - _currentLuminance._rt->create(lumaRez, lumaRez);
188 - _previousLuminance._rt->create(1, 1);
194 + U16 lumaRez = to_U16(nextPOW2(to_U32(width / 3.0f)));
195 +
196 + _currentLuminance._rt->resize(lumaRez, lumaRez);
197 + _previousLuminance._rt->resize(1, 1);
189 198
190 199 _toneMap->Uniform("luminanceMipLevel",
191 200 _currentLuminance
192 201 ._rt
193 202 ->getAttachment(RTAttachment::Type::Colour, 0)
194 - .asTexture()
203 + .texture()
195 204 ->getMaxMipLevel());
196 205
197 206 for (OperatorBatch& batch : _operators) {
  @@ -202,6 +211,6 @@
202 211 }
203 212 }
204 213
205 - _postFXOutput._rt->create(width, height);
214 + _postFXOutput._rt->resize(width, height);
206 215 }
207 216 };