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

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

Issue 139013008: Implement support for rendering to 32-bit float textures on ES3 (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Check that framebuffers really are supported and add tests Created 6 years, 10 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/test_helper.h" 5 #include "gpu/command_buffer/service/test_helper.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 } 220 }
221 221
222 EXPECT_CALL(*gl, DeleteTextures(4, _)) 222 EXPECT_CALL(*gl, DeleteTextures(4, _))
223 .Times(1) 223 .Times(1)
224 .RetiresOnSaturation(); 224 .RetiresOnSaturation();
225 } 225 }
226 226
227 void TestHelper::SetupContextGroupInitExpectations( 227 void TestHelper::SetupContextGroupInitExpectations(
228 ::gfx::MockGLInterface* gl, 228 ::gfx::MockGLInterface* gl,
229 const DisallowedFeatures& disallowed_features, 229 const DisallowedFeatures& disallowed_features,
230 const char* extensions) { 230 const char* extensions,
231 const char* gl_version) {
231 InSequence sequence; 232 InSequence sequence;
232 233
233 SetupFeatureInfoInitExpectations(gl, extensions); 234 SetupFeatureInfoInitExpectationsWithGLVersion(gl, extensions, "", gl_version);
234 235
235 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_RENDERBUFFER_SIZE, _)) 236 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_RENDERBUFFER_SIZE, _))
236 .WillOnce(SetArgumentPointee<1>(kMaxRenderbufferSize)) 237 .WillOnce(SetArgumentPointee<1>(kMaxRenderbufferSize))
237 .RetiresOnSaturation(); 238 .RetiresOnSaturation();
238 if (strstr(extensions, "GL_EXT_framebuffer_multisample") || 239 if (strstr(extensions, "GL_EXT_framebuffer_multisample") ||
239 strstr(extensions, "GL_EXT_multisampled_render_to_texture")) { 240 strstr(extensions, "GL_EXT_multisampled_render_to_texture")) {
240 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_SAMPLES, _)) 241 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_SAMPLES, _))
241 .WillOnce(SetArgumentPointee<1>(kMaxSamples)) 242 .WillOnce(SetArgumentPointee<1>(kMaxSamples))
242 .RetiresOnSaturation(); 243 .RetiresOnSaturation();
243 } else if (strstr(extensions, "GL_IMG_multisampled_render_to_texture")) { 244 } else if (strstr(extensions, "GL_IMG_multisampled_render_to_texture")) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 291
291 EXPECT_CALL(*gl, GetString(GL_EXTENSIONS)) 292 EXPECT_CALL(*gl, GetString(GL_EXTENSIONS))
292 .WillOnce(Return(reinterpret_cast<const uint8*>(extensions))) 293 .WillOnce(Return(reinterpret_cast<const uint8*>(extensions)))
293 .RetiresOnSaturation(); 294 .RetiresOnSaturation();
294 EXPECT_CALL(*gl, GetString(GL_RENDERER)) 295 EXPECT_CALL(*gl, GetString(GL_RENDERER))
295 .WillOnce(Return(reinterpret_cast<const uint8*>(gl_renderer))) 296 .WillOnce(Return(reinterpret_cast<const uint8*>(gl_renderer)))
296 .RetiresOnSaturation(); 297 .RetiresOnSaturation();
297 EXPECT_CALL(*gl, GetString(GL_VERSION)) 298 EXPECT_CALL(*gl, GetString(GL_VERSION))
298 .WillOnce(Return(reinterpret_cast<const uint8*>(gl_version))) 299 .WillOnce(Return(reinterpret_cast<const uint8*>(gl_version)))
299 .RetiresOnSaturation(); 300 .RetiresOnSaturation();
301
302 std::string l_version(StringToLowerASCII(std::string(gl_version)));
303 bool is_es3 = (l_version.substr(0, 12) == "opengl es 3.");
304
305 if (strstr(extensions, "GL_ARB_texture_float") ||
306 (is_es3 && strstr(extensions, "GL_EXT_color_buffer_float"))) {
307 static const GLuint gl_ids[] = {101, 102};
308 const GLsizei width = 16;
309 EXPECT_CALL(*gl, GetIntegerv(GL_FRAMEBUFFER_BINDING, _))
310 .WillOnce(SetArgumentPointee<1>(gl_ids[0]))
311 .RetiresOnSaturation();
312 EXPECT_CALL(*gl, GetIntegerv(GL_TEXTURE_BINDING_2D, _))
313 .WillOnce(SetArgumentPointee<1>(gl_ids[0]))
314 .RetiresOnSaturation();
315 EXPECT_CALL(*gl, GenTextures(1, _))
316 .WillOnce(SetArrayArgument<1>(gl_ids + 1, gl_ids + 2))
317 .RetiresOnSaturation();
318 EXPECT_CALL(*gl, GenFramebuffersEXT(1, _))
319 .WillOnce(SetArrayArgument<1>(gl_ids + 1, gl_ids + 2))
320 .RetiresOnSaturation();
321 EXPECT_CALL(*gl, BindTexture(GL_TEXTURE_2D, gl_ids[1]))
322 .Times(1)
323 .RetiresOnSaturation();
324 EXPECT_CALL(*gl, TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, width, width, 0,
325 GL_RGBA, GL_FLOAT, _))
326 .Times(1)
327 .RetiresOnSaturation();
328 EXPECT_CALL(*gl, BindFramebufferEXT(GL_FRAMEBUFFER, gl_ids[1]))
329 .Times(1)
330 .RetiresOnSaturation();
331 EXPECT_CALL(*gl, FramebufferTexture2DEXT(GL_FRAMEBUFFER,
332 GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, gl_ids[1], 0))
333 .Times(1)
334 .RetiresOnSaturation();
335 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER))
336 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE))
337 .RetiresOnSaturation();
338 EXPECT_CALL(*gl, TexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, width, width, 0,
339 GL_RGB, GL_FLOAT, _))
340 .Times(1)
341 .RetiresOnSaturation();
342 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER))
343 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE))
344 .RetiresOnSaturation();
345 EXPECT_CALL(*gl, DeleteFramebuffersEXT(1, _))
346 .Times(1)
347 .RetiresOnSaturation();
348 EXPECT_CALL(*gl, DeleteTextures(1, _))
349 .Times(1)
350 .RetiresOnSaturation();
351 EXPECT_CALL(*gl, BindFramebufferEXT(GL_FRAMEBUFFER, gl_ids[0]))
352 .Times(1)
353 .RetiresOnSaturation();
354 EXPECT_CALL(*gl, BindTexture(GL_TEXTURE_2D, gl_ids[0]))
355 .Times(1)
356 .RetiresOnSaturation();
357 if (DCHECK_IS_ON()) {
358 EXPECT_CALL(*gl, GetError())
359 .WillOnce(Return(GL_NO_ERROR))
360 .RetiresOnSaturation();
361 }
362 }
300 } 363 }
301 364
302 void TestHelper::SetupExpectationsForClearingUniforms( 365 void TestHelper::SetupExpectationsForClearingUniforms(
303 ::gfx::MockGLInterface* gl, UniformInfo* uniforms, size_t num_uniforms) { 366 ::gfx::MockGLInterface* gl, UniformInfo* uniforms, size_t num_uniforms) {
304 for (size_t ii = 0; ii < num_uniforms; ++ii) { 367 for (size_t ii = 0; ii < num_uniforms; ++ii) {
305 const UniformInfo& info = uniforms[ii]; 368 const UniformInfo& info = uniforms[ii];
306 switch (info.type) { 369 switch (info.type) {
307 case GL_FLOAT: 370 case GL_FLOAT:
308 EXPECT_CALL(*gl, Uniform1fv(info.real_location, info.size, _)) 371 EXPECT_CALL(*gl, Uniform1fv(info.real_location, info.size, _))
309 .Times(1) 372 .Times(1)
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 gfx::SetGLImplementation(implementation); 616 gfx::SetGLImplementation(implementation);
554 } 617 }
555 618
556 ScopedGLImplementationSetter::~ScopedGLImplementationSetter() { 619 ScopedGLImplementationSetter::~ScopedGLImplementationSetter() {
557 gfx::SetGLImplementation(old_implementation_); 620 gfx::SetGLImplementation(old_implementation_);
558 } 621 }
559 622
560 } // namespace gles2 623 } // namespace gles2
561 } // namespace gpu 624 } // namespace gpu
562 625
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698