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 #ifndef GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_BASE_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_BASE_H_ |
6 #define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_BASE_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_BASE_H_ |
7 | 7 |
8 #include "gpu/command_buffer/common/gl_mock.h" | 8 #include "gpu/command_buffer/common/gl_mock.h" |
9 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 9 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "ui/gfx/gl/gl_surface_stub.h" | 23 #include "ui/gfx/gl/gl_surface_stub.h" |
24 | 24 |
25 namespace gpu { | 25 namespace gpu { |
26 namespace gles2 { | 26 namespace gles2 { |
27 | 27 |
28 class GLES2DecoderTestBase : public testing::Test { | 28 class GLES2DecoderTestBase : public testing::Test { |
29 public: | 29 public: |
30 GLES2DecoderTestBase(); | 30 GLES2DecoderTestBase(); |
31 virtual ~GLES2DecoderTestBase(); | 31 virtual ~GLES2DecoderTestBase(); |
32 | 32 |
33 protected: | |
34 static const GLint kMaxTextureSize = 2048; | |
35 static const GLint kMaxCubeMapTextureSize = 256; | |
36 static const GLint kNumVertexAttribs = 16; | |
37 static const GLint kNumTextureUnits = 8; | |
38 static const GLint kMaxTextureImageUnits = 8; | |
39 static const GLint kMaxVertexTextureImageUnits = 2; | |
40 static const GLint kMaxFragmentUniformVectors = 16; | |
41 static const GLint kMaxVaryingVectors = 8; | |
42 static const GLint kMaxVertexUniformVectors = 128; | |
43 | |
44 static const GLuint kServiceAttrib0BufferId = 801; | |
45 static const GLuint kServiceFixedAttribBufferId = 802; | |
46 | |
47 static const GLuint kServiceBufferId = 301; | |
48 static const GLuint kServiceFramebufferId = 302; | |
49 static const GLuint kServiceRenderbufferId = 303; | |
50 static const GLuint kServiceTextureId = 304; | |
51 static const GLuint kServiceProgramId = 305; | |
52 static const GLuint kServiceShaderId = 306; | |
53 static const GLuint kServiceElementBufferId = 308; | |
54 static const GLuint kServiceQueryId = 309; | |
55 | |
56 static const int32 kSharedMemoryId = 401; | |
57 static const size_t kSharedBufferSize = 2048; | |
58 static const uint32 kSharedMemoryOffset = 132; | |
59 static const int32 kInvalidSharedMemoryId = 402; | |
60 static const uint32 kInvalidSharedMemoryOffset = kSharedBufferSize + 1; | |
61 static const uint32 kInitialResult = 0xBDBDBDBDu; | |
62 static const uint8 kInitialMemoryValue = 0xBDu; | |
63 | |
64 static const uint32 kNewClientId = 501; | |
65 static const uint32 kNewServiceId = 502; | |
66 static const uint32 kInvalidClientId = 601; | |
67 | |
68 static const int kBackBufferWidth = 128; | |
69 static const int kBackBufferHeight = 64; | |
70 | |
71 static const GLuint kServiceVertexShaderId = 321; | |
72 static const GLuint kServiceFragmentShaderId = 322; | |
73 | |
74 static const GLsizei kNumVertices = 100; | |
75 static const GLsizei kNumIndices = 10; | |
76 static const int kValidIndexRangeStart = 1; | |
77 static const int kValidIndexRangeCount = 7; | |
78 static const int kInvalidIndexRangeStart = 0; | |
79 static const int kInvalidIndexRangeCount = 7; | |
80 static const int kOutOfRangeIndexRangeEnd = 10; | |
81 static const GLuint kMaxValidIndex = 7; | |
82 | |
83 static const GLint kMaxAttribLength = 10; | |
84 static const char* kAttrib1Name; | |
85 static const char* kAttrib2Name; | |
86 static const char* kAttrib3Name; | |
87 static const GLint kAttrib1Size = 1; | |
88 static const GLint kAttrib2Size = 1; | |
89 static const GLint kAttrib3Size = 1; | |
90 static const GLint kAttrib1Location = 0; | |
91 static const GLint kAttrib2Location = 1; | |
92 static const GLint kAttrib3Location = 2; | |
93 static const GLenum kAttrib1Type = GL_FLOAT_VEC4; | |
94 static const GLenum kAttrib2Type = GL_FLOAT_VEC2; | |
95 static const GLenum kAttrib3Type = GL_FLOAT_VEC3; | |
96 static const GLint kInvalidAttribLocation = 30; | |
97 static const GLint kBadAttribIndex = kNumVertexAttribs; | |
98 | |
99 static const GLint kMaxUniformLength = 12; | |
100 static const char* kUniform1Name; | |
101 static const char* kUniform2Name; | |
102 static const char* kUniform3Name; | |
103 static const GLint kUniform1Size = 1; | |
104 static const GLint kUniform2Size = 3; | |
105 static const GLint kUniform3Size = 2; | |
106 static const GLint kUniform1RealLocation = 3; | |
107 static const GLint kUniform2RealLocation = 10; | |
108 static const GLint kUniform2ElementRealLocation = 12; | |
109 static const GLint kUniform3RealLocation = 20; | |
110 static const GLint kUniform1FakeLocation = 0; // These are | |
111 static const GLint kUniform2FakeLocation = 1; // hardcoded | |
112 static const GLint kUniform2ElementFakeLocation = 0x10001; // to match | |
113 static const GLint kUniform3FakeLocation = 2; // ProgramManager. | |
114 static const GLenum kUniform1Type = GL_SAMPLER_2D; | |
115 static const GLenum kUniform2Type = GL_INT_VEC2; | |
116 static const GLenum kUniform3Type = GL_FLOAT_VEC3; | |
117 static const GLenum kUniformCubemapType = GL_SAMPLER_CUBE; | |
118 static const GLint kInvalidUniformLocation = 30; | |
119 static const GLint kBadUniformIndex = 1000; | |
120 | |
121 // Template to call glGenXXX functions. | 33 // Template to call glGenXXX functions. |
122 template <typename T> | 34 template <typename T> |
123 void GenHelper(GLuint client_id) { | 35 void GenHelper(GLuint client_id) { |
124 int8 buffer[sizeof(T) + sizeof(client_id)]; | 36 int8 buffer[sizeof(T) + sizeof(client_id)]; |
125 T& cmd = *reinterpret_cast<T*>(&buffer); | 37 T& cmd = *reinterpret_cast<T*>(&buffer); |
126 cmd.Init(1, &client_id); | 38 cmd.Init(1, &client_id); |
127 EXPECT_EQ(error::kNoError, | 39 EXPECT_EQ(error::kNoError, |
128 ExecuteImmediateCmd(cmd, sizeof(client_id))); | 40 ExecuteImmediateCmd(cmd, sizeof(client_id))); |
129 } | 41 } |
130 | 42 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 bool has_stencil, | 139 bool has_stencil, |
228 bool request_alpha, | 140 bool request_alpha, |
229 bool request_depth, | 141 bool request_depth, |
230 bool request_stencil, | 142 bool request_stencil, |
231 bool bind_generates_resource); | 143 bool bind_generates_resource); |
232 | 144 |
233 const ContextGroup& group() const { | 145 const ContextGroup& group() const { |
234 return *group_.get(); | 146 return *group_.get(); |
235 } | 147 } |
236 | 148 |
| 149 ::testing::StrictMock< ::gfx::MockGLInterface>* GetGLMock() const { |
| 150 return gl_.get(); |
| 151 } |
| 152 |
| 153 GLES2Decoder* GetDecoder() const { |
| 154 return decoder_.get(); |
| 155 } |
| 156 |
237 struct AttribInfo { | 157 struct AttribInfo { |
238 const char* name; | 158 const char* name; |
239 GLint size; | 159 GLint size; |
240 GLenum type; | 160 GLenum type; |
241 GLint location; | 161 GLint location; |
242 }; | 162 }; |
243 | 163 |
244 struct UniformInfo { | 164 struct UniformInfo { |
245 const char* name; | 165 const char* name; |
246 GLint size; | 166 GLint size; |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 bool IsObjectHelper(GLuint client_id) { | 318 bool IsObjectHelper(GLuint client_id) { |
399 Result* result = static_cast<Result*>(shared_memory_address_); | 319 Result* result = static_cast<Result*>(shared_memory_address_); |
400 Command cmd; | 320 Command cmd; |
401 cmd.Init(client_id, kSharedMemoryId, kSharedMemoryOffset); | 321 cmd.Init(client_id, kSharedMemoryId, kSharedMemoryOffset); |
402 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 322 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
403 bool isObject = static_cast<bool>(*result); | 323 bool isObject = static_cast<bool>(*result); |
404 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 324 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
405 return isObject; | 325 return isObject; |
406 } | 326 } |
407 | 327 |
| 328 protected: |
| 329 static const GLint kMaxTextureSize = 2048; |
| 330 static const GLint kMaxCubeMapTextureSize = 256; |
| 331 static const GLint kNumVertexAttribs = 16; |
| 332 static const GLint kNumTextureUnits = 8; |
| 333 static const GLint kMaxTextureImageUnits = 8; |
| 334 static const GLint kMaxVertexTextureImageUnits = 2; |
| 335 static const GLint kMaxFragmentUniformVectors = 16; |
| 336 static const GLint kMaxVaryingVectors = 8; |
| 337 static const GLint kMaxVertexUniformVectors = 128; |
| 338 |
| 339 static const GLuint kServiceAttrib0BufferId = 801; |
| 340 static const GLuint kServiceFixedAttribBufferId = 802; |
| 341 |
| 342 static const GLuint kServiceBufferId = 301; |
| 343 static const GLuint kServiceFramebufferId = 302; |
| 344 static const GLuint kServiceRenderbufferId = 303; |
| 345 static const GLuint kServiceTextureId = 304; |
| 346 static const GLuint kServiceProgramId = 305; |
| 347 static const GLuint kServiceShaderId = 306; |
| 348 static const GLuint kServiceElementBufferId = 308; |
| 349 static const GLuint kServiceQueryId = 309; |
| 350 |
| 351 static const int32 kSharedMemoryId = 401; |
| 352 static const size_t kSharedBufferSize = 2048; |
| 353 static const uint32 kSharedMemoryOffset = 132; |
| 354 static const int32 kInvalidSharedMemoryId = 402; |
| 355 static const uint32 kInvalidSharedMemoryOffset = kSharedBufferSize + 1; |
| 356 static const uint32 kInitialResult = 0xBDBDBDBDu; |
| 357 static const uint8 kInitialMemoryValue = 0xBDu; |
| 358 |
| 359 static const uint32 kNewClientId = 501; |
| 360 static const uint32 kNewServiceId = 502; |
| 361 static const uint32 kInvalidClientId = 601; |
| 362 |
| 363 static const int kBackBufferWidth = 128; |
| 364 static const int kBackBufferHeight = 64; |
| 365 |
| 366 static const GLuint kServiceVertexShaderId = 321; |
| 367 static const GLuint kServiceFragmentShaderId = 322; |
| 368 |
| 369 static const GLsizei kNumVertices = 100; |
| 370 static const GLsizei kNumIndices = 10; |
| 371 static const int kValidIndexRangeStart = 1; |
| 372 static const int kValidIndexRangeCount = 7; |
| 373 static const int kInvalidIndexRangeStart = 0; |
| 374 static const int kInvalidIndexRangeCount = 7; |
| 375 static const int kOutOfRangeIndexRangeEnd = 10; |
| 376 static const GLuint kMaxValidIndex = 7; |
| 377 |
| 378 static const GLint kMaxAttribLength = 10; |
| 379 static const char* kAttrib1Name; |
| 380 static const char* kAttrib2Name; |
| 381 static const char* kAttrib3Name; |
| 382 static const GLint kAttrib1Size = 1; |
| 383 static const GLint kAttrib2Size = 1; |
| 384 static const GLint kAttrib3Size = 1; |
| 385 static const GLint kAttrib1Location = 0; |
| 386 static const GLint kAttrib2Location = 1; |
| 387 static const GLint kAttrib3Location = 2; |
| 388 static const GLenum kAttrib1Type = GL_FLOAT_VEC4; |
| 389 static const GLenum kAttrib2Type = GL_FLOAT_VEC2; |
| 390 static const GLenum kAttrib3Type = GL_FLOAT_VEC3; |
| 391 static const GLint kInvalidAttribLocation = 30; |
| 392 static const GLint kBadAttribIndex = kNumVertexAttribs; |
| 393 |
| 394 static const GLint kMaxUniformLength = 12; |
| 395 static const char* kUniform1Name; |
| 396 static const char* kUniform2Name; |
| 397 static const char* kUniform3Name; |
| 398 static const GLint kUniform1Size = 1; |
| 399 static const GLint kUniform2Size = 3; |
| 400 static const GLint kUniform3Size = 2; |
| 401 static const GLint kUniform1RealLocation = 3; |
| 402 static const GLint kUniform2RealLocation = 10; |
| 403 static const GLint kUniform2ElementRealLocation = 12; |
| 404 static const GLint kUniform3RealLocation = 20; |
| 405 static const GLint kUniform1FakeLocation = 0; // These are |
| 406 static const GLint kUniform2FakeLocation = 1; // hardcoded |
| 407 static const GLint kUniform2ElementFakeLocation = 0x10001; // to match |
| 408 static const GLint kUniform3FakeLocation = 2; // ProgramManager. |
| 409 static const GLenum kUniform1Type = GL_SAMPLER_2D; |
| 410 static const GLenum kUniform2Type = GL_INT_VEC2; |
| 411 static const GLenum kUniform3Type = GL_FLOAT_VEC3; |
| 412 static const GLenum kUniformCubemapType = GL_SAMPLER_CUBE; |
| 413 static const GLint kInvalidUniformLocation = 30; |
| 414 static const GLint kBadUniformIndex = 1000; |
| 415 |
408 // Use StrictMock to make 100% sure we know how GL will be called. | 416 // Use StrictMock to make 100% sure we know how GL will be called. |
409 scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_; | 417 scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_; |
410 scoped_refptr<gfx::GLSurfaceStub> surface_; | 418 scoped_refptr<gfx::GLSurfaceStub> surface_; |
411 scoped_refptr<gfx::GLContextStub> context_; | 419 scoped_refptr<gfx::GLContextStub> context_; |
412 scoped_ptr<GLES2Decoder> decoder_; | 420 scoped_ptr<GLES2Decoder> decoder_; |
413 | 421 |
414 GLuint client_buffer_id_; | 422 GLuint client_buffer_id_; |
415 GLuint client_framebuffer_id_; | 423 GLuint client_framebuffer_id_; |
416 GLuint client_program_id_; | 424 GLuint client_program_id_; |
417 GLuint client_renderbuffer_id_; | 425 GLuint client_renderbuffer_id_; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 protected: | 498 protected: |
491 virtual void SetUp() OVERRIDE; | 499 virtual void SetUp() OVERRIDE; |
492 virtual void TearDown() OVERRIDE; | 500 virtual void TearDown() OVERRIDE; |
493 | 501 |
494 }; | 502 }; |
495 | 503 |
496 } // namespace gles2 | 504 } // namespace gles2 |
497 } // namespace gpu | 505 } // namespace gpu |
498 | 506 |
499 #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_BASE_H_ | 507 #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_BASE_H_ |
OLD | NEW |