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

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

Issue 221783002: Revert of gpu: Raise GL_OUT_OF_MEMORY when BeginQueryEXT fails to allocate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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) 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
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/string_split.h" 12 #include "base/strings/string_split.h"
13 #include "gpu/command_buffer/common/gles2_cmd_format.h" 13 #include "gpu/command_buffer/common/gles2_cmd_format.h"
14 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 14 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
15 #include "gpu/command_buffer/service/cmd_buffer_engine.h" 15 #include "gpu/command_buffer/service/cmd_buffer_engine.h"
16 #include "gpu/command_buffer/service/context_group.h" 16 #include "gpu/command_buffer/service/context_group.h"
17 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h"
17 #include "gpu/command_buffer/service/logger.h" 18 #include "gpu/command_buffer/service/logger.h"
18 #include "gpu/command_buffer/service/program_manager.h" 19 #include "gpu/command_buffer/service/program_manager.h"
19 #include "gpu/command_buffer/service/test_helper.h" 20 #include "gpu/command_buffer/service/test_helper.h"
20 #include "gpu/command_buffer/service/vertex_attrib_manager.h" 21 #include "gpu/command_buffer/service/vertex_attrib_manager.h"
21 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
22 #include "ui/gl/gl_implementation.h" 23 #include "ui/gl/gl_implementation.h"
23 #include "ui/gl/gl_mock.h" 24 #include "ui/gl/gl_mock.h"
24 #include "ui/gl/gl_surface.h" 25 #include "ui/gl/gl_surface.h"
25 26
26 using ::gfx::MockGLInterface; 27 using ::gfx::MockGLInterface;
(...skipping 26 matching lines...) Expand all
53 client_vertex_shader_id_(121), 54 client_vertex_shader_id_(121),
54 client_fragment_shader_id_(122), 55 client_fragment_shader_id_(122),
55 client_query_id_(123), 56 client_query_id_(123),
56 client_vertexarray_id_(124) { 57 client_vertexarray_id_(124) {
57 memset(immediate_buffer_, 0xEE, sizeof(immediate_buffer_)); 58 memset(immediate_buffer_, 0xEE, sizeof(immediate_buffer_));
58 } 59 }
59 60
60 GLES2DecoderTestBase::~GLES2DecoderTestBase() {} 61 GLES2DecoderTestBase::~GLES2DecoderTestBase() {}
61 62
62 void GLES2DecoderTestBase::SetUp() { 63 void GLES2DecoderTestBase::SetUp() {
63 InitState init; 64 InitDecoder(
64 init.gl_version = "3.0"; 65 "", // extensions
65 init.has_alpha = true; 66 "3.0", // gl version
66 init.has_depth = true; 67 true, // has alpha
67 init.request_alpha = true; 68 true, // has depth
68 init.request_depth = true; 69 false, // has stencil
69 init.bind_generates_resource = true; 70 true, // request alpha
70 InitDecoder(init); 71 true, // request depth
72 false, // request stencil
73 true); // bind generates resource
71 } 74 }
72 75
73 void GLES2DecoderTestBase::AddExpectationsForVertexAttribManager() { 76 void GLES2DecoderTestBase::AddExpectationsForVertexAttribManager() {
74 for (GLint ii = 0; ii < kNumVertexAttribs; ++ii) { 77 for (GLint ii = 0; ii < kNumVertexAttribs; ++ii) {
75 EXPECT_CALL(*gl_, VertexAttrib4f(ii, 0.0f, 0.0f, 0.0f, 1.0f)) 78 EXPECT_CALL(*gl_, VertexAttrib4f(ii, 0.0f, 0.0f, 0.0f, 1.0f))
76 .Times(1) 79 .Times(1)
77 .RetiresOnSaturation(); 80 .RetiresOnSaturation();
78 } 81 }
79 } 82 }
80 83
81 GLES2DecoderTestBase::InitState::InitState() 84 void GLES2DecoderTestBase::InitDecoder(
82 : has_alpha(false), 85 const char* extensions,
83 has_depth(false), 86 const char* gl_version,
84 has_stencil(false), 87 bool has_alpha,
85 request_alpha(false), 88 bool has_depth,
86 request_depth(false), 89 bool has_stencil,
87 request_stencil(false), 90 bool request_alpha,
88 bind_generates_resource(false), 91 bool request_depth,
89 lose_context_when_out_of_memory(false) {} 92 bool request_stencil,
90 93 bool bind_generates_resource) {
91 void GLES2DecoderTestBase::InitDecoder(const InitState& init) { 94 InitDecoderWithCommandLine(extensions,
92 InitDecoderWithCommandLine(init, NULL); 95 gl_version,
96 has_alpha,
97 has_depth,
98 has_stencil,
99 request_alpha,
100 request_depth,
101 request_stencil,
102 bind_generates_resource,
103 NULL);
93 } 104 }
94 105
95 void GLES2DecoderTestBase::InitDecoderWithCommandLine( 106 void GLES2DecoderTestBase::InitDecoderWithCommandLine(
96 const InitState& init, 107 const char* extensions,
108 const char* gl_version,
109 bool has_alpha,
110 bool has_depth,
111 bool has_stencil,
112 bool request_alpha,
113 bool request_depth,
114 bool request_stencil,
115 bool bind_generates_resource,
97 const base::CommandLine* command_line) { 116 const base::CommandLine* command_line) {
98 Framebuffer::ClearFramebufferCompleteComboMap(); 117 Framebuffer::ClearFramebufferCompleteComboMap();
99 118
100 gfx::SetGLGetProcAddressProc(gfx::MockGLInterface::GetGLProcAddress); 119 gfx::SetGLGetProcAddressProc(gfx::MockGLInterface::GetGLProcAddress);
101 gfx::GLSurface::InitializeOneOffWithMockBindingsForTests(); 120 gfx::GLSurface::InitializeOneOffWithMockBindingsForTests();
102 121
103 gl_.reset(new StrictMock<MockGLInterface>()); 122 gl_.reset(new StrictMock<MockGLInterface>());
104 ::gfx::MockGLInterface::SetGLInterface(gl_.get()); 123 ::gfx::MockGLInterface::SetGLInterface(gl_.get());
105 124
106 // Only create stream texture manager if extension is requested. 125 // Only create stream texture manager if extension is requested.
107 std::vector<std::string> list; 126 std::vector<std::string> list;
108 base::SplitString(init.extensions, ' ', &list); 127 base::SplitString(std::string(extensions), ' ', &list);
109 scoped_refptr<FeatureInfo> feature_info; 128 scoped_refptr<FeatureInfo> feature_info;
110 if (command_line) 129 if (command_line)
111 feature_info = new FeatureInfo(*command_line); 130 feature_info = new FeatureInfo(*command_line);
112 group_ = scoped_refptr<ContextGroup>( 131 group_ = scoped_refptr<ContextGroup>(new ContextGroup(
113 new ContextGroup(NULL, 132 NULL,
114 NULL, 133 NULL,
115 memory_tracker_, 134 memory_tracker_,
116 feature_info.get(), 135 feature_info.get(),
117 init.bind_generates_resource)); 136 bind_generates_resource));
118 137
119 InSequence sequence; 138 InSequence sequence;
120 139
121 surface_ = new gfx::GLSurfaceStub; 140 surface_ = new gfx::GLSurfaceStub;
122 surface_->SetSize(gfx::Size(kBackBufferWidth, kBackBufferHeight)); 141 surface_->SetSize(gfx::Size(kBackBufferWidth, kBackBufferHeight));
123 142
124 // Context needs to be created before initializing ContextGroup, which will 143 // Context needs to be created before initializing ContextGroup, which will
125 // in turn initialize FeatureInfo, which needs a context to determine 144 // in turn initialize FeatureInfo, which needs a context to determine
126 // extension support. 145 // extension support.
127 context_ = new gfx::GLContextStubWithExtensions; 146 context_ = new gfx::GLContextStubWithExtensions;
128 context_->AddExtensionsString(init.extensions.c_str()); 147 context_->AddExtensionsString(extensions);
129 context_->SetGLVersionString(init.gl_version.c_str()); 148 context_->SetGLVersionString(gl_version);
130 149
131 context_->MakeCurrent(surface_.get()); 150 context_->MakeCurrent(surface_.get());
132 gfx::GLSurface::InitializeDynamicMockBindingsForTests(context_); 151 gfx::GLSurface::InitializeDynamicMockBindingsForTests(context_);
133 152
134 TestHelper::SetupContextGroupInitExpectations(gl_.get(), 153 TestHelper::SetupContextGroupInitExpectations(gl_.get(),
135 DisallowedFeatures(), 154 DisallowedFeatures(), extensions, gl_version);
136 init.extensions.c_str(),
137 init.gl_version.c_str());
138 155
139 // We initialize the ContextGroup with a MockGLES2Decoder so that 156 // We initialize the ContextGroup with a MockGLES2Decoder so that
140 // we can use the ContextGroup to figure out how the real GLES2Decoder 157 // we can use the ContextGroup to figure out how the real GLES2Decoder
141 // will initialize itself. 158 // will initialize itself.
142 mock_decoder_.reset(new MockGLES2Decoder()); 159 mock_decoder_.reset(new MockGLES2Decoder());
143 EXPECT_TRUE( 160 EXPECT_TRUE(
144 group_->Initialize(mock_decoder_.get(), DisallowedFeatures())); 161 group_->Initialize(mock_decoder_.get(), DisallowedFeatures()));
145 162
146 if (group_->feature_info()->workarounds().init_vertex_attributes) 163 if (group_->feature_info()->workarounds().init_vertex_attributes)
147 AddExpectationsForVertexAttribManager(); 164 AddExpectationsForVertexAttribManager();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 .RetiresOnSaturation(); 221 .RetiresOnSaturation();
205 } 222 }
206 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)) 223 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0))
207 .Times(1) 224 .Times(1)
208 .RetiresOnSaturation(); 225 .RetiresOnSaturation();
209 226
210 EXPECT_CALL(*gl_, BindFramebufferEXT(GL_FRAMEBUFFER, 0)) 227 EXPECT_CALL(*gl_, BindFramebufferEXT(GL_FRAMEBUFFER, 0))
211 .Times(1) 228 .Times(1)
212 .RetiresOnSaturation(); 229 .RetiresOnSaturation();
213 EXPECT_CALL(*gl_, GetIntegerv(GL_ALPHA_BITS, _)) 230 EXPECT_CALL(*gl_, GetIntegerv(GL_ALPHA_BITS, _))
214 .WillOnce(SetArgumentPointee<1>(init.has_alpha ? 8 : 0)) 231 .WillOnce(SetArgumentPointee<1>(has_alpha ? 8 : 0))
215 .RetiresOnSaturation(); 232 .RetiresOnSaturation();
216 EXPECT_CALL(*gl_, GetIntegerv(GL_DEPTH_BITS, _)) 233 EXPECT_CALL(*gl_, GetIntegerv(GL_DEPTH_BITS, _))
217 .WillOnce(SetArgumentPointee<1>(init.has_depth ? 24 : 0)) 234 .WillOnce(SetArgumentPointee<1>(has_depth ? 24 : 0))
218 .RetiresOnSaturation(); 235 .RetiresOnSaturation();
219 EXPECT_CALL(*gl_, GetIntegerv(GL_STENCIL_BITS, _)) 236 EXPECT_CALL(*gl_, GetIntegerv(GL_STENCIL_BITS, _))
220 .WillOnce(SetArgumentPointee<1>(init.has_stencil ? 8 : 0)) 237 .WillOnce(SetArgumentPointee<1>(has_stencil ? 8 : 0))
221 .RetiresOnSaturation(); 238 .RetiresOnSaturation();
222 239
223 EXPECT_CALL(*gl_, Enable(GL_VERTEX_PROGRAM_POINT_SIZE)) 240 EXPECT_CALL(*gl_, Enable(GL_VERTEX_PROGRAM_POINT_SIZE))
224 .Times(1) 241 .Times(1)
225 .RetiresOnSaturation(); 242 .RetiresOnSaturation();
226 243
227 EXPECT_CALL(*gl_, Enable(GL_POINT_SPRITE)) 244 EXPECT_CALL(*gl_, Enable(GL_POINT_SPRITE))
228 .Times(1) 245 .Times(1)
229 .RetiresOnSaturation(); 246 .RetiresOnSaturation();
230 247
231 static GLint max_viewport_dims[] = { 248 static GLint max_viewport_dims[] = {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 285
269 engine_.reset(new StrictMock<MockCommandBufferEngine>()); 286 engine_.reset(new StrictMock<MockCommandBufferEngine>());
270 scoped_refptr<gpu::Buffer> buffer = 287 scoped_refptr<gpu::Buffer> buffer =
271 engine_->GetSharedMemoryBuffer(kSharedMemoryId); 288 engine_->GetSharedMemoryBuffer(kSharedMemoryId);
272 shared_memory_offset_ = kSharedMemoryOffset; 289 shared_memory_offset_ = kSharedMemoryOffset;
273 shared_memory_address_ = 290 shared_memory_address_ =
274 reinterpret_cast<int8*>(buffer->memory()) + shared_memory_offset_; 291 reinterpret_cast<int8*>(buffer->memory()) + shared_memory_offset_;
275 shared_memory_id_ = kSharedMemoryId; 292 shared_memory_id_ = kSharedMemoryId;
276 shared_memory_base_ = buffer->memory(); 293 shared_memory_base_ = buffer->memory();
277 294
278 static const int32 kLoseContextWhenOutOfMemory = 0x10003; 295 int32 attributes[] = {
279 296 EGL_ALPHA_SIZE, request_alpha ? 8 : 0,
280 int32 attributes[] = {EGL_ALPHA_SIZE, 297 EGL_DEPTH_SIZE, request_depth ? 24 : 0,
281 init.request_alpha ? 8 : 0, 298 EGL_STENCIL_SIZE, request_stencil ? 8 : 0,
282 EGL_DEPTH_SIZE, 299 };
283 init.request_depth ? 24 : 0,
284 EGL_STENCIL_SIZE,
285 init.request_stencil ? 8 : 0,
286 kLoseContextWhenOutOfMemory,
287 init.lose_context_when_out_of_memory ? 1 : 0, };
288 std::vector<int32> attribs(attributes, attributes + arraysize(attributes)); 300 std::vector<int32> attribs(attributes, attributes + arraysize(attributes));
289 301
290 decoder_.reset(GLES2Decoder::Create(group_.get())); 302 decoder_.reset(GLES2Decoder::Create(group_.get()));
291 decoder_->GetLogger()->set_log_synthesized_gl_errors(false); 303 decoder_->GetLogger()->set_log_synthesized_gl_errors(false);
292 decoder_->Initialize(surface_, 304 decoder_->Initialize(surface_,
293 context_, 305 context_,
294 false, 306 false,
295 surface_->GetSize(), 307 surface_->GetSize(),
296 DisallowedFeatures(), 308 DisallowedFeatures(),
297 attribs); 309 attribs);
(...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 SetupDefaultProgram(); 1464 SetupDefaultProgram();
1453 } 1465 }
1454 1466
1455 // Include the auto-generated part of this file. We split this because it means 1467 // Include the auto-generated part of this file. We split this because it means
1456 // we can easily edit the non-auto generated parts right here in this file 1468 // we can easily edit the non-auto generated parts right here in this file
1457 // instead of having to edit some template or the code generator. 1469 // instead of having to edit some template or the code generator.
1458 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_0_autogen.h" 1470 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_0_autogen.h"
1459 1471
1460 } // namespace gles2 1472 } // namespace gles2
1461 } // namespace gpu 1473 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h ('k') | gpu/command_buffer/tests/gl_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698