Nux

Merge lp:~3v1n0/nux/fbo-attachments-fix into lp:nux/raring

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: 783
Merged at revision: 780
Proposed branch: lp:~3v1n0/nux/fbo-attachments-fix
Merge into: lp:nux/raring
Prerequisite: lp:~3v1n0/nux/fix-depth-texture-initialization
Diff against target: 186 lines (+44/-26)
6 files modified
NuxGraphics/GpuDevice.cpp (+5/-0)
NuxGraphics/GpuDevice.h (+1/-0)
NuxGraphics/GraphicsDisplayWin.cpp (+6/-0)
NuxGraphics/GraphicsDisplayX11.cpp (+7/-0)
NuxGraphics/IOpenGLFrameBufferObject.cpp (+24/-26)
NuxGraphics/IOpenGLFrameBufferObject.h (+1/-0)
To merge this branch: bzr merge lp:~3v1n0/nux/fbo-attachments-fix
Reviewer Review Type Date Requested Status
Eleni Maria Stea (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+161766@code.launchpad.net

Commit message

IOpenGLFrameBufferObject: correctly use all the FBO attachments.

Description of the change

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Eleni Maria Stea (hikiko) wrote :

Cool!! :D

review: Approve
lp:~3v1n0/nux/fbo-attachments-fix updated
780. By Marco Trevisan (Treviño)

Merging with trunk

781. By Marco Trevisan (Treviño)

GpuDevice: add a getter for FrameBufferObject

782. By Marco Trevisan (Treviño)

IOpenGLFrameBufferObject: add some code cleanup

783. By Marco Trevisan (Treviño)

GraphicsDisplay: correctly (and always) setup the FBO after building the GpuDevice

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NuxGraphics/GpuDevice.cpp'
2--- NuxGraphics/GpuDevice.cpp 2012-12-08 01:03:38 +0000
3+++ NuxGraphics/GpuDevice.cpp 2013-05-01 18:16:40 +0000
4@@ -1033,6 +1033,11 @@
5 active_framebuffer_object_ = fbo;
6 }
7
8+ ObjectPtr<IOpenGLFrameBufferObject> GpuDevice::GetFrameBufferObject() const
9+ {
10+ return _FrameBufferObject;
11+ }
12+
13 ObjectPtr<IOpenGLFrameBufferObject> GpuDevice::GetCurrentFrameBufferObject()
14 {
15 return active_framebuffer_object_;
16
17=== modified file 'NuxGraphics/GpuDevice.h'
18--- NuxGraphics/GpuDevice.h 2012-11-27 17:18:13 +0000
19+++ NuxGraphics/GpuDevice.h 2013-05-01 18:16:40 +0000
20@@ -323,6 +323,7 @@
21
22 public:
23 void SetCurrentFrameBufferObject(ObjectPtr<IOpenGLFrameBufferObject> fbo);
24+ ObjectPtr<IOpenGLFrameBufferObject> GetFrameBufferObject() const;
25 ObjectPtr<IOpenGLFrameBufferObject> GetCurrentFrameBufferObject();
26 ObjectPtr<IOpenGLBaseTexture> ActiveFboTextureAttachment(int color_attachment_index);
27 ObjectPtr<IOpenGLBaseTexture> ActiveFboDepthTextureAttachment();
28
29=== modified file 'NuxGraphics/GraphicsDisplayWin.cpp'
30--- NuxGraphics/GraphicsDisplayWin.cpp 2012-12-08 01:03:38 +0000
31+++ NuxGraphics/GraphicsDisplayWin.cpp 2013-05-01 18:16:40 +0000
32@@ -540,6 +540,9 @@
33 new_opengl_rendering_context,
34 1, 0, false);
35
36+ if (m_DeviceFactory->GetGpuInfo().Support_EXT_Framebuffer_Object())
37+ m_DeviceFactory->GetFrameBufferObject()->SetupFrameBufferObject();
38+
39 if (new_opengl_rendering_context != 0)
40 {
41 opengl_rendering_context_ = new_opengl_rendering_context;
42@@ -578,6 +581,9 @@
43 device_context_,
44 opengl_rendering_context_);
45
46+ if (m_DeviceFactory->GetGpuInfo().Support_EXT_Framebuffer_Object())
47+ m_DeviceFactory->GetFrameBufferObject()->SetupFrameBufferObject();
48+
49 m_GraphicsContext = new GraphicsEngine(*this);
50
51 InitGlobalGrabWindow();
52
53=== modified file 'NuxGraphics/GraphicsDisplayX11.cpp'
54--- NuxGraphics/GraphicsDisplayX11.cpp 2013-03-12 14:04:45 +0000
55+++ NuxGraphics/GraphicsDisplayX11.cpp 2013-05-01 18:16:40 +0000
56@@ -656,6 +656,9 @@
57 m_GLCtx,
58 1, 0, false);
59
60+ if (m_DeviceFactory->GetGpuInfo().Support_EXT_Framebuffer_Object())
61+ m_DeviceFactory->GetFrameBufferObject()->SetupFrameBufferObject();
62+
63 m_GraphicsContext = new GraphicsEngine(*this);
64
65 //EnableVSyncSwapControl();
66@@ -711,6 +714,10 @@
67 _fb_config,
68 m_GLCtx,
69 1, 0, false);
70+
71+ if (m_DeviceFactory->GetGpuInfo().Support_EXT_Framebuffer_Object())
72+ m_DeviceFactory->GetFrameBufferObject()->SetupFrameBufferObject();
73+
74 m_GraphicsContext = new GraphicsEngine(*this);
75
76 InitGlobalGrabWindow();
77
78=== modified file 'NuxGraphics/IOpenGLFrameBufferObject.cpp'
79--- NuxGraphics/IOpenGLFrameBufferObject.cpp 2012-11-27 17:18:13 +0000
80+++ NuxGraphics/IOpenGLFrameBufferObject.cpp 2013-05-01 18:16:40 +0000
81@@ -40,19 +40,21 @@
82 _PixelFormat = BITFMT_R8G8B8A8;
83 _IsActive = false;
84
85- for (int i = 0; i < 1 /*GetGraphicsDisplay()->GetGpuDevice()->GetGpuInfo().GetMaxFboAttachment()*/; i++)
86- {
87- texture_attachment_array_.push_back(ObjectPtr<IOpenGLBaseTexture> (0));
88- surface_attachment_array_.push_back(ObjectPtr<IOpenGLSurface> (0));
89- }
90-
91- if (GetGraphicsDisplay()->GetGpuDevice() && GetGraphicsDisplay()->GetGpuDevice()->GetGpuInfo().Support_Depth_Buffer())
92- {
93- platform_support_for_depth_texture_ = true;
94- }
95+ SetupFrameBufferObject();
96+ GRunTimeStats.Register(this);
97+ }
98+
99+ void IOpenGLFrameBufferObject::SetupFrameBufferObject()
100+ {
101+ if (!GetGraphicsDisplay()->GetGpuDevice())
102+ return;
103+
104+ auto const& gpu_info = GetGraphicsDisplay()->GetGpuDevice()->GetGpuInfo();
105+ texture_attachment_array_.resize(gpu_info.GetMaxFboAttachment());
106+ surface_attachment_array_.resize(gpu_info.GetMaxFboAttachment());
107+ platform_support_for_depth_texture_ = gpu_info.Support_Depth_Buffer();
108
109 FormatFrameBufferObject(attachment_width_, attachment_height_, _PixelFormat);
110- GRunTimeStats.Register(this);
111 }
112
113 IOpenGLFrameBufferObject::~IOpenGLFrameBufferObject()
114@@ -67,14 +69,8 @@
115 {
116 Deactivate();
117
118- if (!surface_attachment_array_.empty())
119- {
120- for (int i = 0; i < 1 /*GetGraphicsDisplay()->GetGpuDevice()->GetGpuInfo().GetMaxFboAttachment()*/; i++)
121- {
122- texture_attachment_array_[i].Release();
123- surface_attachment_array_[i].Release();
124- }
125- }
126+ texture_attachment_array_.clear();
127+ surface_attachment_array_.clear();
128
129 depth_surface_attachment_ = ObjectPtr<IOpenGLSurface> (0);
130 stencil_surface_attachment_ = ObjectPtr<IOpenGLSurface> (0);
131@@ -100,7 +96,7 @@
132
133 int IOpenGLFrameBufferObject::SetRenderTarget(int color_attachment_index, ObjectPtr<IOpenGLSurface> pRenderTargetSurface)
134 {
135- nuxAssert(color_attachment_index < 1 /*GetGraphicsDisplay()->GetGpuDevice()->GetGpuInfo().GetMaxFboAttachment()*/);
136+ nuxAssert(color_attachment_index < GetGraphicsDisplay()->GetGpuDevice()->GetGpuInfo().GetMaxFboAttachment());
137
138 if (pRenderTargetSurface.IsNull())
139 {
140@@ -135,7 +131,7 @@
141
142 int IOpenGLFrameBufferObject::SetTextureAttachment(int color_attachment_index, ObjectPtr<IOpenGLBaseTexture> texture, int mip_level)
143 {
144- nuxAssert(color_attachment_index < 1 /*GetGraphicsDisplay()->GetGpuDevice()->GetGpuInfo().GetMaxFboAttachment()*/);
145+ nuxAssert(color_attachment_index < GetGraphicsDisplay()->GetGpuDevice()->GetGpuInfo().GetMaxFboAttachment());
146
147 if (texture.IsNull())
148 {
149@@ -266,7 +262,7 @@
150
151 ObjectPtr<IOpenGLSurface> IOpenGLFrameBufferObject::GetRenderTarget(int ColorAttachmentIndex)
152 {
153- nuxAssert(ColorAttachmentIndex < 1 /*GetGraphicsDisplay()->GetGpuDevice()->GetGpuInfo().GetMaxFboAttachment()*/);
154+ nuxAssert(ColorAttachmentIndex < GetGraphicsDisplay()->GetGpuDevice()->GetGpuInfo().GetMaxFboAttachment());
155 return surface_attachment_array_[ColorAttachmentIndex];
156 }
157
158@@ -280,10 +276,12 @@
159 GLuint NumBuffers = 0;
160 _Fbo.Bind();
161
162- if (GetGraphicsDisplay()->GetGpuDevice())
163- GetGraphicsDisplay()->GetGpuDevice()->SetCurrentFrameBufferObject(ObjectPtr<IOpenGLFrameBufferObject> (this));
164-
165- for (int i = 0; i < 1 /*GetGraphicsDisplay()->GetGpuDevice()->GetGpuInfo().GetMaxFboAttachment()*/; i++)
166+ if (!GetGraphicsDisplay()->GetGpuDevice())
167+ return 0;
168+
169+ GetGraphicsDisplay()->GetGpuDevice()->SetCurrentFrameBufferObject(ObjectPtr<IOpenGLFrameBufferObject> (this));
170+
171+ for (int i = 0; i < GetGraphicsDisplay()->GetGpuDevice()->GetGpuInfo().GetMaxFboAttachment(); ++i)
172 {
173 if (surface_attachment_array_[i].IsValid())
174 {
175
176=== modified file 'NuxGraphics/IOpenGLFrameBufferObject.h'
177--- NuxGraphics/IOpenGLFrameBufferObject.h 2012-11-16 18:52:32 +0000
178+++ NuxGraphics/IOpenGLFrameBufferObject.h 2013-05-01 18:16:40 +0000
179@@ -33,6 +33,7 @@
180 public:
181 virtual ~IOpenGLFrameBufferObject();
182
183+ void SetupFrameBufferObject();
184 int FormatFrameBufferObject(int Width, int Height, BitmapFormat PixelFormat);
185 int SetRenderTarget(int color_attachment_index, ObjectPtr<IOpenGLSurface> pRenderTargetSurface);
186 int SetTextureAttachment(int color_attachment_index, ObjectPtr<IOpenGLBaseTexture> texture, int surface_level);

Subscribers

People subscribed via source and target branches