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