Subversion Repository Public Repository

Divide-Framework

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

Diff Revisions 910 vs 911 for /trunk/Source Code/Platform/Video/Buffers/RenderTarget/RenderTarget.cpp

Diff revisions: vs.
  @@ -8,34 +8,55 @@
8 8 namespace Divide {
9 9
10 10 namespace {
11 - // We don't need more than 4 colour attachments for now.
12 - const U8 g_maxColourAttachments = 4;
13 11 bool g_policiesInitialised = false;
14 12 };
15 13
16 - RTDrawDescriptor RenderTarget::_policyDefault;
17 - RTDrawDescriptor RenderTarget::_policyKeepDepth;
18 - RTDrawDescriptor RenderTarget::_policyDepthOnly;
14 + RTDrawDescriptor RenderTarget::s_policyDefault;
15 + RTDrawDescriptor RenderTarget::s_policyKeepDepth;
16 + RTDrawDescriptor RenderTarget::s_policyDepthOnly;
19 17
20 - RenderTarget::RenderTarget(GFXDevice& context, const vec2<U16>& resolution, const stringImpl& name)
18 + RTDrawDescriptor& RenderTarget::defaultPolicy() {
19 + return s_policyDefault;
20 + }
21 +
22 + RTDrawDescriptor& RenderTarget::defaultPolicyKeepDepth() {
23 + return s_policyKeepDepth;
24 + }
25 +
26 + RTDrawDescriptor& RenderTarget::defaultPolicyDepthOnly() {
27 + return s_policyDepthOnly;
28 + }
29 +
30 + RenderTarget::RenderTarget(GFXDevice& context, const RenderTargetDescriptor& descriptor)
21 31 : GUIDWrapper(),
22 32 GraphicsResource(context, getGUID()),
23 - _width(resolution.w),
24 - _height(resolution.h),
33 + _width(descriptor._resolution.w),
34 + _height(descriptor._resolution.h),
25 35 _depthValue(1.0),
26 - _name(name)
36 + _name(descriptor._name)
27 37 {
38 + if (!g_policiesInitialised) {
39 + s_policyKeepDepth.disableState(RTDrawDescriptor::State::CLEAR_DEPTH_BUFFER);
40 + s_policyDepthOnly.drawMask().disableAll();
41 + s_policyDepthOnly.drawMask().setEnabled(RTAttachment::Type::Depth, 0, true);
42 + g_policiesInitialised = true;
43 + }
44 +
28 45 if (Config::Profile::USE_2x2_TEXTURES) {
29 46 _width = _height = 2;
30 47 }
31 48
32 - _attachmentPool = MemoryManager_NEW RTAttachmentPool(*this, g_maxColourAttachments);
49 + U8 colourAttachmentCount = 0;
50 + for (U8 i = 0; i < descriptor._attachmentCount; ++i) {
51 + if (descriptor._attachments[i]._type == RTAttachment::Type::Colour) {
52 + ++colourAttachmentCount;
53 + }
54 + }
33 55
34 - if (!g_policiesInitialised) {
35 - _policyKeepDepth.disableState(RTDrawDescriptor::State::CLEAR_DEPTH_BUFFER);
36 - _policyDepthOnly.drawMask().disableAll();
37 - _policyDepthOnly.drawMask().setEnabled(RTAttachment::Type::Depth, 0, true);
38 - g_policiesInitialised = true;
56 + _attachmentPool = MemoryManager_NEW RTAttachmentPool(*this, colourAttachmentCount);
57 +
58 + for (U8 i = 0; i < descriptor._attachmentCount; ++i) {
59 + _attachmentPool->update(descriptor._attachments[i]);
39 60 }
40 61 }
41 62
  @@ -44,43 +65,10 @@
44 65 MemoryManager::DELETE(_attachmentPool);
45 66 }
46 67
47 - void RenderTarget::copy(const RenderTarget& other) {
48 - _attachmentPool->copy(*other._attachmentPool);
49 - _width = other._width;
50 - _height = other._height;
51 - _depthValue = other._depthValue;
52 - }
53 -
54 - void RenderTarget::addAttachment(const RTAttachment& attachment, RTAttachment::Type type, U8 index) {
55 - if (attachment.used()) {
56 - _attachmentPool->update(type, index, attachment.texture()->getDescriptor());
57 - } else {
58 - _attachmentPool->clear(type, index);
59 - }
60 - }
61 -
62 - void RenderTarget::addAttachment(const TextureDescriptor& descriptor,
63 - RTAttachment::Type type,
64 - U8 index) {
65 - _attachmentPool->update(type, index, descriptor);
66 - }
67 -
68 68 const RTAttachment& RenderTarget::getAttachment(RTAttachment::Type type, U8 index) const {
69 69 return *_attachmentPool->get(type, index);
70 70 }
71 71
72 - RTDrawDescriptor& RenderTarget::defaultPolicy() {
73 - return _policyDefault;
74 - }
75 -
76 - RTDrawDescriptor& RenderTarget::defaultPolicyKeepDepth() {
77 - return _policyKeepDepth;
78 - }
79 -
80 - RTDrawDescriptor& RenderTarget::defaultPolicyDepthOnly() {
81 - return _policyDepthOnly;
82 - }
83 -
84 72 /// Used by cubemap FB's
85 73 void RenderTarget::drawToFace(RTAttachment::Type type, U8 index, U16 nFace, bool includeDepth) {
86 74 drawToLayer(type, index, nFace, includeDepth);
  @@ -90,20 +78,6 @@
90 78 readData(vec4<U16>(0, 0, _width, _height), imageFormat, dataType, outData);
91 79 }
92 80
93 - // Set the colour the FB will clear to when drawing to it
94 - void RenderTarget::setClearColour(RTAttachment::Type type, U8 index, const vec4<F32>& clearColour) {
95 - if (type == RTAttachment::Type::COUNT) {
96 - for (U8 i = 0; i < to_base(RTAttachment::Type::COUNT); ++i) {
97 - type = static_cast<RTAttachment::Type>(i);
98 - for (U8 j = 0; j < _attachmentPool->attachmentCount(type); ++j) {
99 - _attachmentPool->get(type, j)->clearColour(clearColour);
100 - }
101 - }
102 - } else {
103 - _attachmentPool->get(type, index)->clearColour(clearColour);
104 - }
105 - }
106 -
107 81 void RenderTarget::setClearDepth(F32 depthValue) {
108 82 _depthValue = depthValue;
109 83 }