Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: gpu/command_buffer/service/framebuffer_manager_unittest.cc

Issue 7158002: Revert 89002 - Enforce RGB even on buggy drivers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/command_buffer/service/framebuffer_manager.h" 5 #include "gpu/command_buffer/service/framebuffer_manager.h"
6 #include "gpu/command_buffer/service/feature_info.h" 6 #include "gpu/command_buffer/service/feature_info.h"
7 7
8 #include "gpu/command_buffer/common/gl_mock.h" 8 #include "gpu/command_buffer/common/gl_mock.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 namespace gpu { 11 namespace gpu {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 const GLuint FramebufferInfoTest::kService1Id; 115 const GLuint FramebufferInfoTest::kService1Id;
116 #endif 116 #endif
117 117
118 TEST_F(FramebufferInfoTest, Basic) { 118 TEST_F(FramebufferInfoTest, Basic) {
119 EXPECT_EQ(kService1Id, info_->service_id()); 119 EXPECT_EQ(kService1Id, info_->service_id());
120 EXPECT_FALSE(info_->IsDeleted()); 120 EXPECT_FALSE(info_->IsDeleted());
121 EXPECT_TRUE(NULL == info_->GetAttachment(GL_COLOR_ATTACHMENT0)); 121 EXPECT_TRUE(NULL == info_->GetAttachment(GL_COLOR_ATTACHMENT0));
122 EXPECT_TRUE(NULL == info_->GetAttachment(GL_DEPTH_ATTACHMENT)); 122 EXPECT_TRUE(NULL == info_->GetAttachment(GL_DEPTH_ATTACHMENT));
123 EXPECT_TRUE(NULL == info_->GetAttachment(GL_STENCIL_ATTACHMENT)); 123 EXPECT_TRUE(NULL == info_->GetAttachment(GL_STENCIL_ATTACHMENT));
124 EXPECT_TRUE(NULL == info_->GetAttachment(GL_DEPTH_STENCIL_ATTACHMENT)); 124 EXPECT_TRUE(NULL == info_->GetAttachment(GL_DEPTH_STENCIL_ATTACHMENT));
125 EXPECT_FALSE(info_->HasDepthAttachment());
126 EXPECT_FALSE(info_->HasStencilAttachment());
127 EXPECT_EQ(static_cast<GLenum>(0), info_->GetColorAttachmentFormat());
128 } 125 }
129 126
130 TEST_F(FramebufferInfoTest, AttachRenderbuffer) { 127 TEST_F(FramebufferInfoTest, AttachRenderbuffer) {
131 const GLuint kRenderbufferClient1Id = 33; 128 const GLuint kRenderbufferClient1Id = 33;
132 const GLuint kRenderbufferService1Id = 333; 129 const GLuint kRenderbufferService1Id = 333;
133 const GLuint kRenderbufferClient2Id = 34; 130 const GLuint kRenderbufferClient2Id = 34;
134 const GLuint kRenderbufferService2Id = 334; 131 const GLuint kRenderbufferService2Id = 334;
135 const GLint kMaxRenderbufferSize = 128; 132 const GLint kMaxRenderbufferSize = 128;
136 const GLsizei kWidth1 = 16; 133 const GLsizei kWidth1 = 16;
137 const GLsizei kHeight1 = 32; 134 const GLsizei kHeight1 = 32;
(...skipping 19 matching lines...) Expand all
157 kRenderbufferClient1Id, kRenderbufferService1Id); 154 kRenderbufferClient1Id, kRenderbufferService1Id);
158 RenderbufferManager::RenderbufferInfo* rb_info1 = 155 RenderbufferManager::RenderbufferInfo* rb_info1 =
159 rb_manager.GetRenderbufferInfo(kRenderbufferClient1Id); 156 rb_manager.GetRenderbufferInfo(kRenderbufferClient1Id);
160 ASSERT_TRUE(rb_info1 != NULL); 157 ASSERT_TRUE(rb_info1 != NULL);
161 158
162 // check adding one attachment 159 // check adding one attachment
163 info_->AttachRenderbuffer(GL_COLOR_ATTACHMENT0, rb_info1); 160 info_->AttachRenderbuffer(GL_COLOR_ATTACHMENT0, rb_info1);
164 EXPECT_TRUE(info_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); 161 EXPECT_TRUE(info_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
165 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT)); 162 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT));
166 EXPECT_TRUE(info_->IsNotComplete()); 163 EXPECT_TRUE(info_->IsNotComplete());
167 EXPECT_EQ(static_cast<GLenum>(GL_RGBA4), info_->GetColorAttachmentFormat());
168 EXPECT_FALSE(info_->HasDepthAttachment());
169 EXPECT_FALSE(info_->HasStencilAttachment());
170
171 rb_info1->SetInfo(1, GL_RGB, 0, 0);
172 EXPECT_EQ(static_cast<GLenum>(GL_RGB), info_->GetColorAttachmentFormat());
173 EXPECT_FALSE(info_->HasDepthAttachment());
174 EXPECT_FALSE(info_->HasStencilAttachment());
175 164
176 // check adding another 165 // check adding another
177 info_->AttachRenderbuffer(GL_DEPTH_ATTACHMENT, rb_info1); 166 info_->AttachRenderbuffer(GL_DEPTH_ATTACHMENT, rb_info1);
178 EXPECT_TRUE(info_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); 167 EXPECT_TRUE(info_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
179 EXPECT_TRUE(info_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT)); 168 EXPECT_TRUE(info_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT));
180 EXPECT_TRUE(info_->IsNotComplete()); 169 EXPECT_TRUE(info_->IsNotComplete());
181 EXPECT_EQ(static_cast<GLenum>(GL_RGB), info_->GetColorAttachmentFormat());
182 EXPECT_TRUE(info_->HasDepthAttachment());
183 EXPECT_FALSE(info_->HasStencilAttachment());
184 170
185 // check marking them as cleared. 171 // check marking them as cleared.
186 info_->MarkAttachedRenderbuffersAsCleared(); 172 info_->MarkAttachedRenderbuffersAsCleared();
187 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); 173 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
188 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT)); 174 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT));
189 EXPECT_TRUE(info_->IsNotComplete()); 175 EXPECT_TRUE(info_->IsNotComplete());
190 176
191 // Check adding one that is already cleared. 177 // Check adding one that is already cleared.
192 info_->AttachRenderbuffer(GL_STENCIL_ATTACHMENT, rb_info1); 178 info_->AttachRenderbuffer(GL_STENCIL_ATTACHMENT, rb_info1);
193 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT)); 179 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT));
194 EXPECT_EQ(static_cast<GLenum>(GL_RGB), info_->GetColorAttachmentFormat());
195 EXPECT_TRUE(info_->HasDepthAttachment());
196 EXPECT_TRUE(info_->HasStencilAttachment());
197 180
198 // Check marking the renderbuffer as unclared. 181 // Check marking the renderbuffer as unclared.
199 rb_info1->SetInfo(kSamples1, kFormat1, kWidth1, kHeight1); 182 rb_info1->SetInfo(kSamples1, kFormat1, kWidth1, kHeight1);
200 EXPECT_FALSE(info_->IsNotComplete()); 183 EXPECT_FALSE(info_->IsNotComplete());
201 EXPECT_EQ(static_cast<GLenum>(kFormat1), info_->GetColorAttachmentFormat());
202 EXPECT_TRUE(info_->HasDepthAttachment());
203 EXPECT_TRUE(info_->HasStencilAttachment());
204 184
205 const FramebufferManager::FramebufferInfo::Attachment* attachment = 185 const FramebufferManager::FramebufferInfo::Attachment* attachment =
206 info_->GetAttachment(GL_COLOR_ATTACHMENT0); 186 info_->GetAttachment(GL_COLOR_ATTACHMENT0);
207 ASSERT_TRUE(attachment != NULL); 187 ASSERT_TRUE(attachment != NULL);
208 EXPECT_EQ(kWidth1, attachment->width()); 188 EXPECT_EQ(kWidth1, attachment->width());
209 EXPECT_EQ(kHeight1, attachment->height()); 189 EXPECT_EQ(kHeight1, attachment->height());
210 EXPECT_EQ(kSamples1, attachment->samples()); 190 EXPECT_EQ(kSamples1, attachment->samples());
211 EXPECT_EQ(kFormat1, attachment->internal_format()); 191 EXPECT_EQ(kFormat1, attachment->internal_format());
212 EXPECT_FALSE(attachment->cleared()); 192 EXPECT_FALSE(attachment->cleared());
213 193
(...skipping 29 matching lines...) Expand all
243 ASSERT_TRUE(attachment != NULL); 223 ASSERT_TRUE(attachment != NULL);
244 EXPECT_EQ(kWidth3, attachment->width()); 224 EXPECT_EQ(kWidth3, attachment->width());
245 EXPECT_EQ(kHeight3, attachment->height()); 225 EXPECT_EQ(kHeight3, attachment->height());
246 EXPECT_EQ(kSamples3, attachment->samples()); 226 EXPECT_EQ(kSamples3, attachment->samples());
247 EXPECT_EQ(kFormat3, attachment->internal_format()); 227 EXPECT_EQ(kFormat3, attachment->internal_format());
248 EXPECT_FALSE(attachment->cleared()); 228 EXPECT_FALSE(attachment->cleared());
249 229
250 // Check removing it. 230 // Check removing it.
251 info_->AttachRenderbuffer(GL_STENCIL_ATTACHMENT, NULL); 231 info_->AttachRenderbuffer(GL_STENCIL_ATTACHMENT, NULL);
252 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT)); 232 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT));
253 EXPECT_EQ(static_cast<GLenum>(kFormat1), info_->GetColorAttachmentFormat());
254 EXPECT_TRUE(info_->HasDepthAttachment());
255 EXPECT_FALSE(info_->HasStencilAttachment());
256 233
257 rb_manager.Destroy(false); 234 rb_manager.Destroy(false);
258 } 235 }
259 236
260 TEST_F(FramebufferInfoTest, AttachTexture) { 237 TEST_F(FramebufferInfoTest, AttachTexture) {
261 const GLuint kTextureClient1Id = 33; 238 const GLuint kTextureClient1Id = 33;
262 const GLuint kTextureService1Id = 333; 239 const GLuint kTextureService1Id = 333;
263 const GLuint kTextureClient2Id = 34; 240 const GLuint kTextureClient2Id = 34;
264 const GLuint kTextureService2Id = 334; 241 const GLuint kTextureService2Id = 334;
265 const GLint kMaxTextureSize = 128; 242 const GLint kMaxTextureSize = 128;
(...skipping 28 matching lines...) Expand all
294 tex_manager.CreateTextureInfo( 271 tex_manager.CreateTextureInfo(
295 &feature_info, kTextureClient1Id, kTextureService1Id); 272 &feature_info, kTextureClient1Id, kTextureService1Id);
296 TextureManager::TextureInfo* tex_info1 = 273 TextureManager::TextureInfo* tex_info1 =
297 tex_manager.GetTextureInfo(kTextureClient1Id); 274 tex_manager.GetTextureInfo(kTextureClient1Id);
298 ASSERT_TRUE(tex_info1 != NULL); 275 ASSERT_TRUE(tex_info1 != NULL);
299 276
300 // check adding one attachment 277 // check adding one attachment
301 info_->AttachTexture(GL_COLOR_ATTACHMENT0, tex_info1, kTarget1, kLevel1); 278 info_->AttachTexture(GL_COLOR_ATTACHMENT0, tex_info1, kTarget1, kLevel1);
302 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); 279 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
303 EXPECT_TRUE(info_->IsNotComplete()); 280 EXPECT_TRUE(info_->IsNotComplete());
304 EXPECT_EQ(static_cast<GLenum>(0), info_->GetColorAttachmentFormat());
305 281
306 tex_manager.SetInfoTarget(tex_info1, GL_TEXTURE_2D); 282 tex_manager.SetInfoTarget(tex_info1, GL_TEXTURE_2D);
307 tex_manager.SetLevelInfo( 283 tex_manager.SetLevelInfo(
308 &feature_info, tex_info1, GL_TEXTURE_2D, kLevel1, 284 &feature_info, tex_info1, GL_TEXTURE_2D, kLevel1,
309 kFormat1, kWidth1, kHeight1, kDepth, kBorder, kFormat1, kType); 285 kFormat1, kWidth1, kHeight1, kDepth, kBorder, kFormat1, kType);
310 EXPECT_FALSE(info_->IsNotComplete()); 286 EXPECT_FALSE(info_->IsNotComplete());
311 EXPECT_EQ(static_cast<GLenum>(kFormat1), info_->GetColorAttachmentFormat());
312 287
313 const FramebufferManager::FramebufferInfo::Attachment* attachment = 288 const FramebufferManager::FramebufferInfo::Attachment* attachment =
314 info_->GetAttachment(GL_COLOR_ATTACHMENT0); 289 info_->GetAttachment(GL_COLOR_ATTACHMENT0);
315 ASSERT_TRUE(attachment != NULL); 290 ASSERT_TRUE(attachment != NULL);
316 EXPECT_EQ(kWidth1, attachment->width()); 291 EXPECT_EQ(kWidth1, attachment->width());
317 EXPECT_EQ(kHeight1, attachment->height()); 292 EXPECT_EQ(kHeight1, attachment->height());
318 EXPECT_EQ(kSamples1, attachment->samples()); 293 EXPECT_EQ(kSamples1, attachment->samples());
319 EXPECT_EQ(kFormat1, attachment->internal_format()); 294 EXPECT_EQ(kFormat1, attachment->internal_format());
320 EXPECT_TRUE(attachment->cleared()); 295 EXPECT_TRUE(attachment->cleared());
321 296
322 // Check replacing an attachment 297 // Check replacing an attachment
323 tex_manager.CreateTextureInfo( 298 tex_manager.CreateTextureInfo(
324 &feature_info, kTextureClient2Id, kTextureService2Id); 299 &feature_info, kTextureClient2Id, kTextureService2Id);
325 TextureManager::TextureInfo* tex_info2 = 300 TextureManager::TextureInfo* tex_info2 =
326 tex_manager.GetTextureInfo(kTextureClient2Id); 301 tex_manager.GetTextureInfo(kTextureClient2Id);
327 ASSERT_TRUE(tex_info2 != NULL); 302 ASSERT_TRUE(tex_info2 != NULL);
328 tex_manager.SetInfoTarget(tex_info2, GL_TEXTURE_2D); 303 tex_manager.SetInfoTarget(tex_info2, GL_TEXTURE_2D);
329 tex_manager.SetLevelInfo( 304 tex_manager.SetLevelInfo(
330 &feature_info, tex_info2, GL_TEXTURE_2D, kLevel2, 305 &feature_info, tex_info2, GL_TEXTURE_2D, kLevel2,
331 kFormat2, kWidth2, kHeight2, kDepth, kBorder, kFormat2, kType); 306 kFormat2, kWidth2, kHeight2, kDepth, kBorder, kFormat2, kType);
332 307
333 info_->AttachTexture(GL_COLOR_ATTACHMENT0, tex_info2, kTarget2, kLevel2); 308 info_->AttachTexture(GL_COLOR_ATTACHMENT0, tex_info2, kTarget2, kLevel2);
334 EXPECT_EQ(static_cast<GLenum>(kFormat2), info_->GetColorAttachmentFormat());
335 309
336 attachment = info_->GetAttachment(GL_COLOR_ATTACHMENT0); 310 attachment = info_->GetAttachment(GL_COLOR_ATTACHMENT0);
337 ASSERT_TRUE(attachment != NULL); 311 ASSERT_TRUE(attachment != NULL);
338 EXPECT_EQ(kWidth2, attachment->width()); 312 EXPECT_EQ(kWidth2, attachment->width());
339 EXPECT_EQ(kHeight2, attachment->height()); 313 EXPECT_EQ(kHeight2, attachment->height());
340 EXPECT_EQ(kSamples2, attachment->samples()); 314 EXPECT_EQ(kSamples2, attachment->samples());
341 EXPECT_EQ(kFormat2, attachment->internal_format()); 315 EXPECT_EQ(kFormat2, attachment->internal_format());
342 EXPECT_TRUE(attachment->cleared()); 316 EXPECT_TRUE(attachment->cleared());
343 317
344 // Check changing attachment 318 // Check changing attachment
345 tex_manager.SetLevelInfo( 319 tex_manager.SetLevelInfo(
346 &feature_info, tex_info2, GL_TEXTURE_2D, kLevel3, 320 &feature_info, tex_info2, GL_TEXTURE_2D, kLevel3,
347 kFormat3, kWidth3, kHeight3, kDepth, kBorder, kFormat3, kType); 321 kFormat3, kWidth3, kHeight3, kDepth, kBorder, kFormat3, kType);
348 attachment = info_->GetAttachment(GL_COLOR_ATTACHMENT0); 322 attachment = info_->GetAttachment(GL_COLOR_ATTACHMENT0);
349 ASSERT_TRUE(attachment != NULL); 323 ASSERT_TRUE(attachment != NULL);
350 EXPECT_EQ(kWidth3, attachment->width()); 324 EXPECT_EQ(kWidth3, attachment->width());
351 EXPECT_EQ(kHeight3, attachment->height()); 325 EXPECT_EQ(kHeight3, attachment->height());
352 EXPECT_EQ(kSamples3, attachment->samples()); 326 EXPECT_EQ(kSamples3, attachment->samples());
353 EXPECT_EQ(kFormat3, attachment->internal_format()); 327 EXPECT_EQ(kFormat3, attachment->internal_format());
354 EXPECT_TRUE(attachment->cleared()); 328 EXPECT_TRUE(attachment->cleared());
355 EXPECT_EQ(static_cast<GLenum>(kFormat3), info_->GetColorAttachmentFormat());
356 329
357 // Check removing it. 330 // Check removing it.
358 info_->AttachTexture(GL_COLOR_ATTACHMENT0, NULL, 0, 0); 331 info_->AttachTexture(GL_COLOR_ATTACHMENT0, NULL, 0, 0);
359 EXPECT_TRUE(info_->GetAttachment(GL_COLOR_ATTACHMENT0) == NULL); 332 EXPECT_TRUE(info_->GetAttachment(GL_COLOR_ATTACHMENT0) == NULL);
360 EXPECT_EQ(static_cast<GLenum>(0), info_->GetColorAttachmentFormat());
361 333
362 tex_manager.Destroy(false); 334 tex_manager.Destroy(false);
363 } 335 }
364 336
365 } // namespace gles2 337 } // namespace gles2
366 } // namespace gpu 338 } // namespace gpu
367 339
368 340
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/framebuffer_manager.cc ('k') | gpu/command_buffer/service/gles2_cmd_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698