Subversion Repository Public Repository

Divide-Framework

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

Diff Revisions 912 vs 924 for /trunk/Source Code/Rendering/PostFX/CustomOperators/BloomPreRenderOperator.cpp

Diff revisions: vs.
  @@ -18,10 +18,10 @@
18 18 BloomPreRenderOperator::BloomPreRenderOperator(GFXDevice& context, PreRenderBatch& parent, ResourceCache& cache)
19 19 : PreRenderOperator(context, parent, cache, FilterType::FILTER_BLOOM)
20 20 {
21 - vec2<U16> res(parent.inputRT().getWidth(), parent.inputRT().getHeight());
21 + vec2<U16> res(parent.inputRT()._rt->getWidth(), parent.inputRT()._rt->getHeight());
22 22
23 23 vectorImpl<RTAttachmentDescriptor> att = {
24 - { parent.inputRT().getAttachment(RTAttachmentType::Colour, 0).texture()->getDescriptor(), RTAttachmentType::Colour, 0, DefaultColours::BLACK() },
24 + { parent.inputRT()._rt->getAttachment(RTAttachmentType::Colour, 0).texture()->getDescriptor(), RTAttachmentType::Colour, 0, DefaultColours::BLACK() },
25 25 };
26 26
27 27 RenderTargetDescriptor desc = {};
  @@ -30,13 +30,13 @@
30 30 desc._attachments = att.data();
31 31
32 32 desc._name = "Bloom_Blur_0";
33 - _bloomBlurBuffer[0] = _context.allocateRT(desc);
33 + _bloomBlurBuffer[0] = _context.renderTargetPool().allocateRT(desc);
34 34 desc._name = "Bloom_Blur_1";
35 - _bloomBlurBuffer[1] = _context.allocateRT(desc);
35 + _bloomBlurBuffer[1] = _context.renderTargetPool().allocateRT(desc);
36 36
37 37 desc._name = "Bloom";
38 38 desc._resolution = vec2<U16>(to_U16(res.w / 4.0f), to_U16(res.h / 4.0f));
39 - _bloomOutput = _context.allocateRT(desc);
39 + _bloomOutput = _context.renderTargetPool().allocateRT(desc);
40 40
41 41 ResourceDescriptor bloomCalc("bloom.BloomCalc");
42 42 bloomCalc.setThreadedLoading(false);
  @@ -56,9 +56,9 @@
56 56 }
57 57
58 58 BloomPreRenderOperator::~BloomPreRenderOperator() {
59 - _context.deallocateRT(_bloomOutput);
60 - _context.deallocateRT(_bloomBlurBuffer[0]);
61 - _context.deallocateRT(_bloomBlurBuffer[1]);
59 + _context.renderTargetPool().deallocateRT(_bloomOutput);
60 + _context.renderTargetPool().deallocateRT(_bloomBlurBuffer[0]);
61 + _context.renderTargetPool().deallocateRT(_bloomBlurBuffer[1]);
62 62 }
63 63
64 64 void BloomPreRenderOperator::idle(const Configuration& config) {
  @@ -86,45 +86,48 @@
86 86 triangleCmd.primitiveType(PrimitiveType::TRIANGLES);
87 87 triangleCmd.drawCount(1);
88 88
89 - RenderTarget* screen = &_parent.inputRT();
89 + RenderTargetHandle screen = _parent.inputRT();
90 90
91 91 // Step 1: generate bloom
92 - screen->bind(to_U8(ShaderProgram::TextureUsage::UNIT0), RTAttachmentType::Colour, 0); //screen
92 + screen._rt->bind(to_U8(ShaderProgram::TextureUsage::UNIT0), RTAttachmentType::Colour, 0); //screen
93 93
94 94 // render all of the "bright spots"
95 - _bloomOutput._rt->begin(RenderTarget::defaultPolicy());
95 + _context.renderTargetPool().drawToTargetBegin(_bloomOutput._targetID);
96 96 pipelineDescriptor._shaderProgram = _bloomCalc;
97 97 triangleCmd.pipeline(_context.newPipeline(pipelineDescriptor));
98 98 _context.draw(triangleCmd);
99 - _bloomOutput._rt->end();
99 + _context.renderTargetPool().drawToTargetEnd();
100 100
101 101 // Step 2: blur bloom
102 102 _blur->bind();
103 103 // Blur horizontally
104 104 _blur->SetSubroutine(ShaderType::FRAGMENT, _horizBlur);
105 105 _bloomOutput._rt->bind(to_U8(ShaderProgram::TextureUsage::UNIT0), RTAttachmentType::Colour, 0);
106 - _bloomBlurBuffer[0]._rt->begin(RenderTarget::defaultPolicy());
106 +
107 + _context.renderTargetPool().drawToTargetBegin(_bloomBlurBuffer[0]._targetID);
107 108 pipelineDescriptor._shaderProgram = _blur;
108 109 triangleCmd.pipeline(_context.newPipeline(pipelineDescriptor));
109 110 _context.draw(triangleCmd);
110 - _bloomBlurBuffer[0]._rt->end();
111 + _context.renderTargetPool().drawToTargetEnd();
111 112
112 113 // Blur vertically (recycle the render target. We have a copy)
113 114 _blur->SetSubroutine(ShaderType::FRAGMENT, _vertBlur);
114 115 _bloomBlurBuffer[0]._rt->bind(to_U8(ShaderProgram::TextureUsage::UNIT0), RTAttachmentType::Colour, 0);
115 - _bloomBlurBuffer[1]._rt->begin(RenderTarget::defaultPolicy());
116 +
117 + _context.renderTargetPool().drawToTargetBegin(_bloomBlurBuffer[1]._targetID);
116 118 _context.draw(triangleCmd);
117 - _bloomBlurBuffer[1]._rt->end();
119 + _context.renderTargetPool().drawToTargetEnd();
118 120
119 121 // Step 3: apply bloom
120 - _bloomBlurBuffer[0]._rt->blitFrom(screen);
122 + _bloomBlurBuffer[0]._rt->blitFrom(screen._rt);
121 123 _bloomBlurBuffer[0]._rt->bind(to_U8(ShaderProgram::TextureUsage::UNIT0), RTAttachmentType::Colour, 0); //Screen
122 124 _bloomBlurBuffer[1]._rt->bind(to_U8(ShaderProgram::TextureUsage::UNIT1), RTAttachmentType::Colour, 0); //Bloom
123 - screen->begin(_screenOnlyDraw);
125 +
126 + _context.renderTargetPool().drawToTargetBegin(screen._targetID, _screenOnlyDraw);
124 127 pipelineDescriptor._shaderProgram = _bloomApply;
125 128 triangleCmd.pipeline(_context.newPipeline(pipelineDescriptor));
126 129 _context.draw(triangleCmd);
127 - screen->end();
130 + _context.renderTargetPool().drawToTargetEnd();
128 131 }
129 132
130 133 void BloomPreRenderOperator::debugPreview(U8 slot) const {