Subversion Repository Public Repository

Divide-Framework

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

Diff Revisions 792 vs 801 for /trunk/Source Code/Rendering/PostFX/CustomOperators/BloomPreRenderOperator.cpp

Diff revisions: vs.
  @@ -9,16 +9,16 @@
9 9
10 10 namespace Divide {
11 11
12 - BloomPreRenderOperator::BloomPreRenderOperator(RenderTarget* hdrTarget, RenderTarget* ldrTarget)
13 - : PreRenderOperator(FilterType::FILTER_BLOOM, hdrTarget, ldrTarget)
12 + BloomPreRenderOperator::BloomPreRenderOperator(GFXDevice& context, RenderTarget* hdrTarget, RenderTarget* ldrTarget)
13 + : PreRenderOperator(context, FilterType::FILTER_BLOOM, hdrTarget, ldrTarget)
14 14 {
15 15 for (U8 i = 0; i < 2; ++i) {
16 - _bloomBlurBuffer[i] = GFX_DEVICE.allocateRT(Util::StringFormat("Bloom_Blur_%d", i));
16 + _bloomBlurBuffer[i] = _context.allocateRT(Util::StringFormat("Bloom_Blur_%d", i));
17 17 _bloomBlurBuffer[i]._rt->addAttachment(_hdrTarget->getDescriptor(RTAttachment::Type::Colour, 0), RTAttachment::Type::Colour, 0, false);
18 18 _bloomBlurBuffer[i]._rt->setClearColour(RTAttachment::Type::COUNT, 0, DefaultColours::BLACK());
19 19 }
20 20
21 - _bloomOutput = GFX_DEVICE.allocateRT("Bloom");
21 + _bloomOutput = _context.allocateRT("Bloom");
22 22 _bloomOutput._rt->addAttachment(_hdrTarget->getDescriptor(RTAttachment::Type::Colour, 0), RTAttachment::Type::Colour, 0, false);
23 23 _bloomOutput._rt->setClearColour(RTAttachment::Type::COUNT, 0, DefaultColours::BLACK());
24 24
  @@ -40,9 +40,9 @@
40 40 }
41 41
42 42 BloomPreRenderOperator::~BloomPreRenderOperator() {
43 - GFX_DEVICE.deallocateRT(_bloomOutput);
44 - GFX_DEVICE.deallocateRT(_bloomBlurBuffer[0]);
45 - GFX_DEVICE.deallocateRT(_bloomBlurBuffer[1]);
43 + _context.deallocateRT(_bloomOutput);
44 + _context.deallocateRT(_bloomBlurBuffer[0]);
45 + _context.deallocateRT(_bloomBlurBuffer[1]);
46 46 }
47 47
48 48 void BloomPreRenderOperator::idle() {
  @@ -67,14 +67,14 @@
67 67 GenericDrawCommand triangleCmd;
68 68 triangleCmd.primitiveType(PrimitiveType::TRIANGLES);
69 69 triangleCmd.drawCount(1);
70 - triangleCmd.stateHash(GFX_DEVICE.getDefaultStateBlock(true));
70 + triangleCmd.stateHash(_context.getDefaultStateBlock(true));
71 71
72 72 // Step 1: generate bloom
73 73 _hdrTarget->bind(to_const_ubyte(ShaderProgram::TextureUsage::UNIT0), RTAttachment::Type::Colour, 0); //screen
74 74 // render all of the "bright spots"
75 75 _bloomOutput._rt->begin(RenderTarget::defaultPolicy());
76 76 triangleCmd.shaderProgram(_bloomCalc);
77 - GFX_DEVICE.draw(triangleCmd);
77 + _context.draw(triangleCmd);
78 78 _bloomOutput._rt->end();
79 79
80 80 // Step 2: blur bloom
  @@ -84,7 +84,7 @@
84 84 _bloomOutput._rt->bind(to_const_ubyte(ShaderProgram::TextureUsage::UNIT0), RTAttachment::Type::Colour, 0);
85 85 _bloomBlurBuffer[0]._rt->begin(RenderTarget::defaultPolicy());
86 86 triangleCmd.shaderProgram(_blur);
87 - GFX_DEVICE.draw(triangleCmd);
87 + _context.draw(triangleCmd);
88 88 _bloomBlurBuffer[0]._rt->end();
89 89
90 90 // Blur vertically (recycle the render target. We have a copy)
  @@ -92,7 +92,7 @@
92 92 _bloomBlurBuffer[0]._rt->bind(to_const_ubyte(ShaderProgram::TextureUsage::UNIT0), RTAttachment::Type::Colour, 0);
93 93 _bloomBlurBuffer[1]._rt->begin(RenderTarget::defaultPolicy());
94 94 triangleCmd.shaderProgram(_blur);
95 - GFX_DEVICE.draw(triangleCmd);
95 + _context.draw(triangleCmd);
96 96 _bloomBlurBuffer[1]._rt->end();
97 97
98 98 // Step 3: apply bloom
  @@ -101,7 +101,7 @@
101 101 _bloomBlurBuffer[1]._rt->bind(to_const_ubyte(ShaderProgram::TextureUsage::UNIT1), RTAttachment::Type::Colour, 0); //Bloom
102 102 _hdrTarget->begin(_screenOnlyDraw);
103 103 triangleCmd.shaderProgram(_bloomApply);
104 - GFX_DEVICE.draw(triangleCmd);
104 + _context.draw(triangleCmd);
105 105 _hdrTarget->end();
106 106 }
107 107