| OLD | NEW |
| 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/gles2_cmd_decoder_unittest_base.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 "GL_ARB_vertex_array_object", | 50 "GL_ARB_vertex_array_object", |
| 51 "GL_APPLE_vertex_array_object" | 51 "GL_APPLE_vertex_array_object" |
| 52 }; | 52 }; |
| 53 bool contains_vao_extension = false; | 53 bool contains_vao_extension = false; |
| 54 for (size_t ii = 0; ii < arraysize(kVAOExtensions); ++ii) { | 54 for (size_t ii = 0; ii < arraysize(kVAOExtensions); ++ii) { |
| 55 if (init->extensions.find(kVAOExtensions[ii]) != std::string::npos) { | 55 if (init->extensions.find(kVAOExtensions[ii]) != std::string::npos) { |
| 56 contains_vao_extension = true; | 56 contains_vao_extension = true; |
| 57 break; | 57 break; |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 | |
| 61 if (init->use_native_vao) { | 60 if (init->use_native_vao) { |
| 62 if (contains_vao_extension) | 61 if (contains_vao_extension) |
| 63 return; | 62 return; |
| 64 if (!init->extensions.empty()) | 63 if (!init->extensions.empty()) |
| 65 init->extensions += " "; | 64 init->extensions += " "; |
| 66 if (StartsWithASCII(init->gl_version, "opengl es", false)) { | 65 if (StartsWithASCII(init->gl_version, "opengl es", false)) { |
| 67 init->extensions += kVAOExtensions[0]; | 66 init->extensions += kVAOExtensions[0]; |
| 68 } else { | 67 } else { |
| 69 #if !defined(OS_MACOSX) | 68 #if !defined(OS_MACOSX) |
| 70 init->extensions += kVAOExtensions[1]; | 69 init->extensions += kVAOExtensions[1]; |
| 71 #else | 70 #else |
| 72 init->extensions += kVAOExtensions[2]; | 71 init->extensions += kVAOExtensions[2]; |
| 73 #endif // OS_MACOSX | 72 #endif // OS_MACOSX |
| 74 } | 73 } |
| 75 } else { | 74 } else { |
| 76 // Make sure we don't set up an invalid InitState. | 75 // Make sure we don't set up an invalid InitState. |
| 77 CHECK(!contains_vao_extension); | 76 CHECK(!contains_vao_extension); |
| 78 } | 77 } |
| 79 | |
| 80 if (!init->extensions.empty()) | |
| 81 init->extensions += " "; | |
| 82 init->extensions += "GL_EXT_framebuffer_object "; | |
| 83 } | 78 } |
| 84 | 79 |
| 85 } // namespace Anonymous | 80 } // namespace Anonymous |
| 86 | 81 |
| 87 namespace gpu { | 82 namespace gpu { |
| 88 namespace gles2 { | 83 namespace gles2 { |
| 89 | 84 |
| 90 GLES2DecoderTestBase::GLES2DecoderTestBase() | 85 GLES2DecoderTestBase::GLES2DecoderTestBase() |
| 91 : surface_(NULL), | 86 : surface_(NULL), |
| 92 context_(NULL), | 87 context_(NULL), |
| (...skipping 23 matching lines...) Expand all Loading... |
| 116 cached_depth_mask_(true), | 111 cached_depth_mask_(true), |
| 117 cached_stencil_front_mask_(static_cast<GLuint>(-1)), | 112 cached_stencil_front_mask_(static_cast<GLuint>(-1)), |
| 118 cached_stencil_back_mask_(static_cast<GLuint>(-1)) { | 113 cached_stencil_back_mask_(static_cast<GLuint>(-1)) { |
| 119 memset(immediate_buffer_, 0xEE, sizeof(immediate_buffer_)); | 114 memset(immediate_buffer_, 0xEE, sizeof(immediate_buffer_)); |
| 120 } | 115 } |
| 121 | 116 |
| 122 GLES2DecoderTestBase::~GLES2DecoderTestBase() {} | 117 GLES2DecoderTestBase::~GLES2DecoderTestBase() {} |
| 123 | 118 |
| 124 void GLES2DecoderTestBase::SetUp() { | 119 void GLES2DecoderTestBase::SetUp() { |
| 125 InitState init; | 120 InitState init; |
| 126 // Autogenerated tests do not overwrite version or extension string, | 121 init.gl_version = "3.0"; |
| 127 // so we have to pick something that supports everything here. | |
| 128 init.gl_version = "4.4"; | |
| 129 init.has_alpha = true; | 122 init.has_alpha = true; |
| 130 init.has_depth = true; | 123 init.has_depth = true; |
| 131 init.request_alpha = true; | 124 init.request_alpha = true; |
| 132 init.request_depth = true; | 125 init.request_depth = true; |
| 133 init.bind_generates_resource = true; | 126 init.bind_generates_resource = true; |
| 134 InitDecoder(init); | 127 InitDecoder(init); |
| 135 } | 128 } |
| 136 | 129 |
| 137 void GLES2DecoderTestBase::AddExpectationsForVertexAttribManager() { | 130 void GLES2DecoderTestBase::AddExpectationsForVertexAttribManager() { |
| 138 for (GLint ii = 0; ii < kNumVertexAttribs; ++ii) { | 131 for (GLint ii = 0; ii < kNumVertexAttribs; ++ii) { |
| 139 EXPECT_CALL(*gl_, VertexAttrib4f(ii, 0.0f, 0.0f, 0.0f, 1.0f)) | 132 EXPECT_CALL(*gl_, VertexAttrib4f(ii, 0.0f, 0.0f, 0.0f, 1.0f)) |
| 140 .Times(1) | 133 .Times(1) |
| 141 .RetiresOnSaturation(); | 134 .RetiresOnSaturation(); |
| 142 } | 135 } |
| 143 } | 136 } |
| 144 | 137 |
| 145 GLES2DecoderTestBase::InitState::InitState() | 138 GLES2DecoderTestBase::InitState::InitState() |
| 146 : extensions("GL_EXT_framebuffer_object"), | 139 : has_alpha(false), |
| 147 gl_version("2.1"), | |
| 148 has_alpha(false), | |
| 149 has_depth(false), | 140 has_depth(false), |
| 150 has_stencil(false), | 141 has_stencil(false), |
| 151 request_alpha(false), | 142 request_alpha(false), |
| 152 request_depth(false), | 143 request_depth(false), |
| 153 request_stencil(false), | 144 request_stencil(false), |
| 154 bind_generates_resource(false), | 145 bind_generates_resource(false), |
| 155 lose_context_when_out_of_memory(false), | 146 lose_context_when_out_of_memory(false), |
| 156 use_native_vao(true) { | 147 use_native_vao(true) { |
| 157 } | 148 } |
| 158 | 149 |
| 159 void GLES2DecoderTestBase::InitDecoder(const InitState& init) { | 150 void GLES2DecoderTestBase::InitDecoder(const InitState& init) { |
| 160 InitDecoderWithCommandLine(init, NULL); | 151 InitDecoderWithCommandLine(init, NULL); |
| 161 } | 152 } |
| 162 | 153 |
| 163 void GLES2DecoderTestBase::InitDecoderWithCommandLine( | 154 void GLES2DecoderTestBase::InitDecoderWithCommandLine( |
| 164 const InitState& init, | 155 const InitState& init, |
| 165 const base::CommandLine* command_line) { | 156 const base::CommandLine* command_line) { |
| 166 InitState normalized_init = init; | 157 InitState normalized_init = init; |
| 167 NormalizeInitState(&normalized_init); | 158 NormalizeInitState(&normalized_init); |
| 168 // For easier substring/extension matching | |
| 169 DCHECK(normalized_init.extensions.empty() || | |
| 170 *normalized_init.extensions.rbegin() == ' '); | |
| 171 Framebuffer::ClearFramebufferCompleteComboMap(); | 159 Framebuffer::ClearFramebufferCompleteComboMap(); |
| 172 | 160 |
| 173 gfx::SetGLGetProcAddressProc(gfx::MockGLInterface::GetGLProcAddress); | 161 gfx::SetGLGetProcAddressProc(gfx::MockGLInterface::GetGLProcAddress); |
| 174 gfx::GLSurface::InitializeOneOffWithMockBindingsForTests(); | 162 gfx::GLSurface::InitializeOneOffWithMockBindingsForTests(); |
| 175 | 163 |
| 176 gl_.reset(new StrictMock<MockGLInterface>()); | 164 gl_.reset(new StrictMock<MockGLInterface>()); |
| 177 ::gfx::MockGLInterface::SetGLInterface(gl_.get()); | 165 ::gfx::MockGLInterface::SetGLInterface(gl_.get()); |
| 178 | 166 |
| 179 SetupMockGLBehaviors(); | 167 SetupMockGLBehaviors(); |
| 180 | 168 |
| 169 // Only create stream texture manager if extension is requested. |
| 170 std::vector<std::string> list; |
| 171 base::SplitString(normalized_init.extensions, ' ', &list); |
| 181 scoped_refptr<FeatureInfo> feature_info; | 172 scoped_refptr<FeatureInfo> feature_info; |
| 182 if (command_line) | 173 if (command_line) |
| 183 feature_info = new FeatureInfo(*command_line); | 174 feature_info = new FeatureInfo(*command_line); |
| 184 group_ = scoped_refptr<ContextGroup>( | 175 group_ = scoped_refptr<ContextGroup>( |
| 185 new ContextGroup(NULL, | 176 new ContextGroup(NULL, |
| 186 memory_tracker_, | 177 memory_tracker_, |
| 187 new ShaderTranslatorCache, | 178 new ShaderTranslatorCache, |
| 188 feature_info.get(), | 179 feature_info.get(), |
| 189 new SubscriptionRefSet, | 180 new SubscriptionRefSet, |
| 190 new ValueStateMap, | 181 new ValueStateMap, |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 | 416 |
| 426 DoCreateProgram(client_program_id_, kServiceProgramId); | 417 DoCreateProgram(client_program_id_, kServiceProgramId); |
| 427 DoCreateShader(GL_VERTEX_SHADER, client_shader_id_, kServiceShaderId); | 418 DoCreateShader(GL_VERTEX_SHADER, client_shader_id_, kServiceShaderId); |
| 428 | 419 |
| 429 // Unsafe commands. | 420 // Unsafe commands. |
| 430 bool reset_unsafe_es3_apis_enabled = false; | 421 bool reset_unsafe_es3_apis_enabled = false; |
| 431 if (!decoder_->unsafe_es3_apis_enabled()) { | 422 if (!decoder_->unsafe_es3_apis_enabled()) { |
| 432 decoder_->set_unsafe_es3_apis_enabled(true); | 423 decoder_->set_unsafe_es3_apis_enabled(true); |
| 433 reset_unsafe_es3_apis_enabled = true; | 424 reset_unsafe_es3_apis_enabled = true; |
| 434 } | 425 } |
| 435 | 426 EXPECT_CALL(*gl_, GenSamplers(_, _)) |
| 436 const gfx::GLVersionInfo* version = context_->GetVersionInfo(); | 427 .WillOnce(SetArgumentPointee<1>(kServiceSamplerId)) |
| 437 if (version->IsAtLeastGL(3, 3) || version->IsAtLeastGLES(3, 0)) { | 428 .RetiresOnSaturation(); |
| 438 EXPECT_CALL(*gl_, GenSamplers(_, _)) | 429 GenHelper<cmds::GenSamplersImmediate>(client_sampler_id_); |
| 439 .WillOnce(SetArgumentPointee<1>(kServiceSamplerId)) | 430 EXPECT_CALL(*gl_, GenTransformFeedbacks(_, _)) |
| 440 .RetiresOnSaturation(); | 431 .WillOnce(SetArgumentPointee<1>(kServiceTransformFeedbackId)) |
| 441 GenHelper<cmds::GenSamplersImmediate>(client_sampler_id_); | 432 .RetiresOnSaturation(); |
| 442 } | 433 GenHelper<cmds::GenTransformFeedbacksImmediate>(client_transformfeedback_id_); |
| 443 if (version->IsAtLeastGL(4, 0) || version->IsAtLeastGLES(3, 0)) { | 434 DoFenceSync(client_sync_id_, kServiceSyncId); |
| 444 EXPECT_CALL(*gl_, GenTransformFeedbacks(_, _)) | |
| 445 .WillOnce(SetArgumentPointee<1>(kServiceTransformFeedbackId)) | |
| 446 .RetiresOnSaturation(); | |
| 447 GenHelper<cmds::GenTransformFeedbacksImmediate>( | |
| 448 client_transformfeedback_id_); | |
| 449 } | |
| 450 | |
| 451 if (init.extensions.find("GL_ARB_sync ") != std::string::npos || | |
| 452 version->IsAtLeastGL(3, 2) || version->IsAtLeastGLES(3, 0)) { | |
| 453 DoFenceSync(client_sync_id_, kServiceSyncId); | |
| 454 } | |
| 455 | |
| 456 if (reset_unsafe_es3_apis_enabled) { | 435 if (reset_unsafe_es3_apis_enabled) { |
| 457 decoder_->set_unsafe_es3_apis_enabled(false); | 436 decoder_->set_unsafe_es3_apis_enabled(false); |
| 458 } | 437 } |
| 459 | 438 |
| 460 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 439 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 461 } | 440 } |
| 462 | 441 |
| 463 void GLES2DecoderTestBase::ResetDecoder() { | 442 void GLES2DecoderTestBase::ResetDecoder() { |
| 464 if (!decoder_.get()) | 443 if (!decoder_.get()) |
| 465 return; | 444 return; |
| (...skipping 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1764 SetupDefaultProgram(); | 1743 SetupDefaultProgram(); |
| 1765 } | 1744 } |
| 1766 | 1745 |
| 1767 // Include the auto-generated part of this file. We split this because it means | 1746 // Include the auto-generated part of this file. We split this because it means |
| 1768 // we can easily edit the non-auto generated parts right here in this file | 1747 // we can easily edit the non-auto generated parts right here in this file |
| 1769 // instead of having to edit some template or the code generator. | 1748 // instead of having to edit some template or the code generator. |
| 1770 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_0_autogen.h" | 1749 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_0_autogen.h" |
| 1771 | 1750 |
| 1772 } // namespace gles2 | 1751 } // namespace gles2 |
| 1773 } // namespace gpu | 1752 } // namespace gpu |
| OLD | NEW |