OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Tests for the Command Buffer Helper. | 5 // Tests for the Command Buffer Helper. |
6 | 6 |
7 #include "gpu/command_buffer/client/gles2_implementation.h" | 7 #include "gpu/command_buffer/client/gles2_implementation.h" |
8 | 8 |
9 #include <GLES2/gl2ext.h> | 9 #include <GLES2/gl2ext.h> |
10 #include "gpu/command_buffer/common/command_buffer.h" | 10 #include "gpu/command_buffer/common/command_buffer.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
13 | 13 |
14 #if !defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) | 14 #if !defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) |
15 #define GLES2_SUPPORT_CLIENT_SIDE_ARRAYS | 15 #define GLES2_SUPPORT_CLIENT_SIDE_ARRAYS |
16 #endif | 16 #endif |
17 | 17 |
18 namespace gpu { | 18 namespace gpu { |
19 | 19 |
20 class GLES2MockCommandBufferHelper : public CommandBuffer { | 20 class GLES2MockCommandBufferHelper : public CommandBuffer { |
21 public: | 21 public: |
22 static const int32 kTransferBufferId = 0x123; | 22 static const int32 kTransferBufferBaseId = 0x123; |
23 static const int32 kMaxTransferBuffers = 6; | |
23 | 24 |
24 GLES2MockCommandBufferHelper() { } | 25 GLES2MockCommandBufferHelper() { } |
25 virtual ~GLES2MockCommandBufferHelper() { } | 26 virtual ~GLES2MockCommandBufferHelper() { } |
26 | 27 |
27 // CommandBuffer implementation: | 28 // CommandBuffer implementation: |
28 virtual bool Initialize(int32 size) { | 29 virtual bool Initialize() { |
29 ring_buffer_.reset(new CommandBufferEntry[size]); | |
30 ring_buffer_buffer_.ptr = ring_buffer_.get(); | |
31 ring_buffer_buffer_.size = size; | |
32 state_.num_entries = size / sizeof(ring_buffer_[0]); | |
33 state_.token = 10000; // All token checks in the tests should pass. | |
34 return true; | 30 return true; |
35 } | 31 } |
36 | 32 |
37 virtual bool Initialize(base::SharedMemory* buffer, int32 size) { | |
38 GPU_NOTREACHED(); | |
39 return false; | |
40 } | |
41 | |
42 virtual Buffer GetRingBuffer() { | |
43 return ring_buffer_buffer_; | |
44 } | |
45 | |
46 virtual State GetState() { | 33 virtual State GetState() { |
47 return state_; | 34 return state_; |
48 } | 35 } |
49 | 36 |
50 virtual State GetLastState() { | 37 virtual State GetLastState() { |
51 return state_; | 38 return state_; |
52 } | 39 } |
53 | 40 |
54 virtual void Flush(int32 put_offset) { | 41 virtual void Flush(int32 put_offset) { |
55 state_.put_offset = put_offset; | 42 state_.put_offset = put_offset; |
56 } | 43 } |
57 | 44 |
58 virtual State FlushSync(int32 put_offset, int32 last_known_get) { | 45 virtual State FlushSync(int32 put_offset, int32 last_known_get) { |
59 state_.put_offset = put_offset; | 46 state_.put_offset = put_offset; |
60 state_.get_offset = put_offset; | 47 state_.get_offset = put_offset; |
61 OnFlush(transfer_buffer_buffer_.ptr); | 48 // Warning: This is a hack. We just happen to know that the default |
49 // transfer buffer will be the first transfer buffer. | |
50 OnFlush(transfer_buffer_buffers_[0].ptr); | |
62 return state_; | 51 return state_; |
63 } | 52 } |
64 | 53 |
54 virtual void SetGetBuffer(int shm_id) { | |
55 ring_buffer_buffer_ = GetTransferBuffer(shm_id); | |
56 ring_buffer_ = static_cast<CommandBufferEntry*>(ring_buffer_buffer_.ptr); | |
57 state_.num_entries = ring_buffer_buffer_.size / sizeof(ring_buffer_[0]); | |
58 state_.token = 10000; // All token checks in the tests should pass. | |
59 } | |
60 | |
65 virtual void SetGetOffset(int32 get_offset) { | 61 virtual void SetGetOffset(int32 get_offset) { |
66 state_.get_offset = get_offset; | 62 state_.get_offset = get_offset; |
67 } | 63 } |
68 | 64 |
65 // Get's the Id of the next transfer buffer that will be returned | |
66 // by CreateTransferBuffer. This is useful for testing expected ids. | |
67 int32 GetNextFreeTransferBufferId() { | |
68 for (size_t ii = 0; ii < arraysize(transfer_buffers_); ++ii) { | |
69 if (!transfer_buffers_[ii].get()) { | |
70 return kTransferBufferBaseId + ii; | |
71 } | |
72 } | |
73 return -1; | |
74 } | |
75 | |
69 virtual int32 CreateTransferBuffer(size_t size, int32 id_request) { | 76 virtual int32 CreateTransferBuffer(size_t size, int32 id_request) { |
70 transfer_buffer_.reset(new int8[size]); | 77 int32 id = GetNextFreeTransferBufferId(); |
71 transfer_buffer_buffer_.ptr = transfer_buffer_.get(); | 78 if (id >= 0) { |
72 transfer_buffer_buffer_.size = size; | 79 int32 ndx = id - kTransferBufferBaseId; |
73 return kTransferBufferId; | 80 transfer_buffers_[ndx].reset(new int8[size]); |
81 transfer_buffer_buffers_[ndx].ptr = transfer_buffers_[ndx].get(); | |
82 transfer_buffer_buffers_[ndx].size = size; | |
83 } | |
84 return id; | |
74 } | 85 } |
75 | 86 |
76 virtual void DestroyTransferBuffer(int32 /* id */) { | 87 virtual void DestroyTransferBuffer(int32 /* id */) { |
77 GPU_NOTREACHED(); | 88 GPU_NOTREACHED(); |
78 } | 89 } |
79 | 90 |
80 virtual Buffer GetTransferBuffer(int32 id) { | 91 virtual Buffer GetTransferBuffer(int32 id) { |
81 GPU_DCHECK_EQ(id, kTransferBufferId); | 92 GPU_DCHECK_GE(id, kTransferBufferBaseId); |
82 return transfer_buffer_buffer_; | 93 GPU_DCHECK_LT(id, kTransferBufferBaseId + kMaxTransferBuffers); |
94 return transfer_buffer_buffers_[id - kTransferBufferBaseId]; | |
83 } | 95 } |
84 | 96 |
85 virtual int32 RegisterTransferBuffer(base::SharedMemory* shared_memory, | 97 virtual int32 RegisterTransferBuffer(base::SharedMemory* shared_memory, |
86 size_t size, | 98 size_t size, |
87 int32 id_request) { | 99 int32 id_request) { |
88 GPU_NOTREACHED(); | 100 GPU_NOTREACHED(); |
89 return -1; | 101 return -1; |
90 } | 102 } |
91 | 103 |
92 virtual void SetToken(int32 token) { | 104 virtual void SetToken(int32 token) { |
93 GPU_NOTREACHED(); | 105 GPU_NOTREACHED(); |
94 state_.token = token; | 106 state_.token = token; |
95 } | 107 } |
96 | 108 |
97 virtual void SetParseError(error::Error error) { | 109 virtual void SetParseError(error::Error error) { |
98 GPU_NOTREACHED(); | 110 GPU_NOTREACHED(); |
99 state_.error = error; | 111 state_.error = error; |
100 } | 112 } |
101 | 113 |
102 virtual void SetContextLostReason(error::ContextLostReason reason) { | 114 virtual void SetContextLostReason(error::ContextLostReason reason) { |
103 GPU_NOTREACHED(); | 115 GPU_NOTREACHED(); |
104 state_.context_lost_reason = reason; | 116 state_.context_lost_reason = reason; |
105 } | 117 } |
106 | 118 |
107 virtual void OnFlush(void* transfer_buffer) = 0; | 119 virtual void OnFlush(void* transfer_buffer) = 0; |
108 | 120 |
109 private: | 121 private: |
110 scoped_array<int8> transfer_buffer_; | 122 scoped_array<int8> transfer_buffers_[10]; |
111 Buffer transfer_buffer_buffer_; | 123 Buffer transfer_buffer_buffers_[10]; |
Ken Russell (switch to Gerrit)
2011/11/21 18:04:10
Could you #define kMaxTransferBuffers at the top o
| |
112 scoped_array<CommandBufferEntry> ring_buffer_; | 124 CommandBufferEntry* ring_buffer_; |
113 Buffer ring_buffer_buffer_; | 125 Buffer ring_buffer_buffer_; |
114 State state_; | 126 State state_; |
115 }; | 127 }; |
116 | 128 |
117 class MockGLES2CommandBuffer : public GLES2MockCommandBufferHelper { | 129 class MockGLES2CommandBuffer : public GLES2MockCommandBufferHelper { |
118 public: | 130 public: |
119 virtual ~MockGLES2CommandBuffer() { | 131 virtual ~MockGLES2CommandBuffer() { |
120 } | 132 } |
121 | 133 |
122 // This is so we can use all the gmock functions when Flush is called. | 134 // This is so we can use all the gmock functions when Flush is called. |
123 MOCK_METHOD1(OnFlush, void(void* result)); | 135 MOCK_METHOD1(OnFlush, void(void* result)); |
124 MOCK_METHOD1(DestroyTransferBuffer, void(int32 id)); | 136 MOCK_METHOD1(DestroyTransferBuffer, void(int32 id)); |
125 }; | 137 }; |
126 | 138 |
127 // GCC requires these declarations, but MSVC requires they not be present | 139 // GCC requires these declarations, but MSVC requires they not be present |
128 #ifndef _MSC_VER | 140 #ifndef _MSC_VER |
129 const int32 GLES2MockCommandBufferHelper::kTransferBufferId; | 141 const int32 GLES2MockCommandBufferHelper::kTransferBufferBaseId; |
142 const int32 GLES2MockCommandBufferHelper::kMaxTransferBuffers; | |
130 #endif | 143 #endif |
131 | 144 |
132 namespace gles2 { | 145 namespace gles2 { |
133 | 146 |
134 using testing::_; | 147 using testing::_; |
135 using testing::DoAll; | 148 using testing::DoAll; |
136 using testing::InSequence; | 149 using testing::InSequence; |
137 using testing::Invoke; | 150 using testing::Invoke; |
138 using testing::Mock; | 151 using testing::Mock; |
139 using testing::Sequence; | 152 using testing::Sequence; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
188 }; | 201 }; |
189 #pragma pack(pop) | 202 #pragma pack(pop) |
190 | 203 |
191 // Test fixture for CommandBufferHelper test. | 204 // Test fixture for CommandBufferHelper test. |
192 class GLES2ImplementationTest : public testing::Test { | 205 class GLES2ImplementationTest : public testing::Test { |
193 protected: | 206 protected: |
194 static const int32 kNumCommandEntries = 400; | 207 static const int32 kNumCommandEntries = 400; |
195 static const int32 kCommandBufferSizeBytes = | 208 static const int32 kCommandBufferSizeBytes = |
196 kNumCommandEntries * sizeof(CommandBufferEntry); | 209 kNumCommandEntries * sizeof(CommandBufferEntry); |
197 static const size_t kTransferBufferSize = 256; | 210 static const size_t kTransferBufferSize = 256; |
198 static const int32 kTransferBufferId = | |
199 GLES2MockCommandBufferHelper::kTransferBufferId; | |
200 static const uint8 kInitialValue = 0xBD; | 211 static const uint8 kInitialValue = 0xBD; |
201 static const GLint kMaxCombinedTextureImageUnits = 8; | 212 static const GLint kMaxCombinedTextureImageUnits = 8; |
202 static const GLint kMaxCubeMapTextureSize = 64; | 213 static const GLint kMaxCubeMapTextureSize = 64; |
203 static const GLint kMaxFragmentUniformVectors = 16; | 214 static const GLint kMaxFragmentUniformVectors = 16; |
204 static const GLint kMaxRenderbufferSize = 64; | 215 static const GLint kMaxRenderbufferSize = 64; |
205 static const GLint kMaxTextureImageUnits = 8; | 216 static const GLint kMaxTextureImageUnits = 8; |
206 static const GLint kMaxTextureSize = 128; | 217 static const GLint kMaxTextureSize = 128; |
207 static const GLint kMaxVaryingVectors = 8; | 218 static const GLint kMaxVaryingVectors = 8; |
208 static const GLint kMaxVertexAttribs = 8; | 219 static const GLint kMaxVertexAttribs = 8; |
209 static const GLint kMaxVertexTextureImageUnits = 0; | 220 static const GLint kMaxVertexTextureImageUnits = 0; |
210 static const GLint kMaxVertexUniformVectors = 128; | 221 static const GLint kMaxVertexUniformVectors = 128; |
211 static const GLint kNumCompressedTextureFormats = 0; | 222 static const GLint kNumCompressedTextureFormats = 0; |
212 static const GLint kNumShaderBinaryFormats = 0; | 223 static const GLint kNumShaderBinaryFormats = 0; |
213 static const GLuint kStartId = 1024; | 224 static const GLuint kStartId = 1024; |
214 | 225 |
215 GLES2ImplementationTest() | 226 GLES2ImplementationTest() |
216 : commands_(NULL), | 227 : commands_(NULL), |
217 token_(0), | 228 token_(0), |
218 offset_(0) { | 229 offset_(0), |
230 transfer_buffer_id_(-1) { | |
219 } | 231 } |
220 | 232 |
221 virtual void SetUp() { | 233 virtual void SetUp() { |
222 Initialize(false, true); | 234 Initialize(false, true); |
223 } | 235 } |
224 | 236 |
225 virtual void TearDown() { | 237 virtual void TearDown() { |
226 } | 238 } |
227 | 239 |
228 void Initialize(bool shared_resources, bool bind_generates_resource) { | 240 void Initialize(bool shared_resources, bool bind_generates_resource) { |
229 offset_ = GLES2Implementation::kStartingOffset; | 241 offset_ = GLES2Implementation::kStartingOffset; |
230 | 242 |
231 command_buffer_.reset(new MockGLES2CommandBuffer()); | 243 command_buffer_.reset(new MockGLES2CommandBuffer()); |
232 command_buffer_->Initialize(kCommandBufferSizeBytes); | 244 command_buffer_->Initialize(); |
233 | 245 |
234 EXPECT_EQ(kTransferBufferId, | 246 transfer_buffer_id_ = |
235 command_buffer_->CreateTransferBuffer(kTransferBufferSize, -1)); | 247 command_buffer_->CreateTransferBuffer(kTransferBufferSize, -1); |
236 transfer_buffer_ = command_buffer_->GetTransferBuffer(kTransferBufferId); | 248 transfer_buffer_ = command_buffer_->GetTransferBuffer(transfer_buffer_id_); |
237 ClearTransferBuffer(); | 249 ClearTransferBuffer(); |
238 | 250 |
239 helper_.reset(new GLES2CmdHelper(command_buffer_.get())); | 251 helper_.reset(new GLES2CmdHelper(command_buffer_.get())); |
240 helper_->Initialize(kCommandBufferSizeBytes); | 252 helper_->Initialize(kCommandBufferSizeBytes); |
241 | 253 |
242 GLES2Implementation::GLState state; | 254 GLES2Implementation::GLState state; |
243 state.max_combined_texture_image_units = kMaxCombinedTextureImageUnits; | 255 state.max_combined_texture_image_units = kMaxCombinedTextureImageUnits; |
244 state.max_cube_map_texture_size = kMaxCubeMapTextureSize; | 256 state.max_cube_map_texture_size = kMaxCubeMapTextureSize; |
245 state.max_fragment_uniform_vectors = kMaxFragmentUniformVectors; | 257 state.max_fragment_uniform_vectors = kMaxFragmentUniformVectors; |
246 state.max_renderbuffer_size = kMaxRenderbufferSize; | 258 state.max_renderbuffer_size = kMaxRenderbufferSize; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
290 ids += num; | 302 ids += num; |
291 num_ids -= num; | 303 num_ids -= num; |
292 } | 304 } |
293 } | 305 } |
294 } | 306 } |
295 | 307 |
296 gl_.reset(new GLES2Implementation( | 308 gl_.reset(new GLES2Implementation( |
297 helper_.get(), | 309 helper_.get(), |
298 kTransferBufferSize, | 310 kTransferBufferSize, |
299 transfer_buffer_.ptr, | 311 transfer_buffer_.ptr, |
300 kTransferBufferId, | 312 transfer_buffer_id_, |
301 shared_resources, | 313 shared_resources, |
302 bind_generates_resource)); | 314 bind_generates_resource)); |
303 } | 315 } |
304 | 316 |
305 EXPECT_CALL(*command_buffer_, OnFlush(_)) | 317 EXPECT_CALL(*command_buffer_, OnFlush(_)) |
306 .Times(1) | 318 .Times(1) |
307 .RetiresOnSaturation(); | 319 .RetiresOnSaturation(); |
308 helper_->CommandBufferHelper::Finish(); | 320 helper_->CommandBufferHelper::Finish(); |
309 Buffer ring_buffer = command_buffer_->GetRingBuffer(); | 321 Buffer ring_buffer = helper_->get_ring_buffer(); |
310 commands_ = static_cast<CommandBufferEntry*>(ring_buffer.ptr) + | 322 commands_ = static_cast<CommandBufferEntry*>(ring_buffer.ptr) + |
311 command_buffer_->GetState().put_offset; | 323 command_buffer_->GetState().put_offset; |
312 ClearCommands(); | 324 ClearCommands(); |
313 } | 325 } |
314 | 326 |
315 const void* GetPut() { | 327 const void* GetPut() { |
316 return helper_->GetSpace(0); | 328 return helper_->GetSpace(0); |
317 } | 329 } |
318 | 330 |
319 size_t MaxTransferBufferSize() { | 331 size_t MaxTransferBufferSize() { |
320 return kTransferBufferSize - GLES2Implementation::kStartingOffset; | 332 return kTransferBufferSize - GLES2Implementation::kStartingOffset; |
321 } | 333 } |
322 | 334 |
323 void ClearCommands() { | 335 void ClearCommands() { |
324 Buffer ring_buffer = command_buffer_->GetRingBuffer(); | 336 Buffer ring_buffer = helper_->get_ring_buffer(); |
325 memset(ring_buffer.ptr, kInitialValue, ring_buffer.size); | 337 memset(ring_buffer.ptr, kInitialValue, ring_buffer.size); |
326 } | 338 } |
327 | 339 |
328 bool NoCommandsWritten() { | 340 bool NoCommandsWritten() { |
329 return static_cast<const uint8*>(static_cast<const void*>(commands_))[0] == | 341 return static_cast<const uint8*>(static_cast<const void*>(commands_))[0] == |
330 kInitialValue; | 342 kInitialValue; |
331 } | 343 } |
332 | 344 |
333 void ClearTransferBuffer() { | 345 void ClearTransferBuffer() { |
334 memset(transfer_buffer_.ptr, kInitialValue, kTransferBufferSize); | 346 memset(transfer_buffer_.ptr, kInitialValue, kTransferBufferSize); |
(...skipping 20 matching lines...) Expand all Loading... | |
355 void* GetTransferAddressFromOffset(uint32 offset, size_t size) { | 367 void* GetTransferAddressFromOffset(uint32 offset, size_t size) { |
356 EXPECT_LE(offset + size, transfer_buffer_.size); | 368 EXPECT_LE(offset + size, transfer_buffer_.size); |
357 return static_cast<int8*>(transfer_buffer_.ptr) + offset; | 369 return static_cast<int8*>(transfer_buffer_.ptr) + offset; |
358 } | 370 } |
359 | 371 |
360 template <typename T> | 372 template <typename T> |
361 T* GetTransferAddressFromOffsetAs(uint32 offset, size_t size) { | 373 T* GetTransferAddressFromOffsetAs(uint32 offset, size_t size) { |
362 return static_cast<T*>(GetTransferAddressFromOffset(offset, size)); | 374 return static_cast<T*>(GetTransferAddressFromOffset(offset, size)); |
363 } | 375 } |
364 | 376 |
377 int32 GetNextFreeTransferBufferId() { | |
378 return command_buffer_->GetNextFreeTransferBufferId(); | |
379 } | |
380 | |
365 Buffer transfer_buffer_; | 381 Buffer transfer_buffer_; |
366 CommandBufferEntry* commands_; | 382 CommandBufferEntry* commands_; |
367 scoped_ptr<MockGLES2CommandBuffer> command_buffer_; | 383 scoped_ptr<MockGLES2CommandBuffer> command_buffer_; |
368 scoped_ptr<GLES2CmdHelper> helper_; | 384 scoped_ptr<GLES2CmdHelper> helper_; |
369 Sequence sequence_; | 385 Sequence sequence_; |
370 scoped_ptr<GLES2Implementation> gl_; | 386 scoped_ptr<GLES2Implementation> gl_; |
371 int token_; | 387 int token_; |
372 uint32 offset_; | 388 uint32 offset_; |
389 int32 transfer_buffer_id_; | |
373 }; | 390 }; |
374 | 391 |
375 class GLES2ImplementationStrictSharedTest : public GLES2ImplementationTest { | 392 class GLES2ImplementationStrictSharedTest : public GLES2ImplementationTest { |
376 protected: | 393 protected: |
377 virtual void SetUp() { | 394 virtual void SetUp() { |
378 Initialize(true, false); | 395 Initialize(true, false); |
379 } | 396 } |
380 }; | 397 }; |
381 | 398 |
382 // GCC requires these declarations, but MSVC requires they not be present | |
383 #ifndef _MSC_VER | |
384 const int32 GLES2ImplementationTest::kTransferBufferId; | |
385 #endif | |
386 | |
387 TEST_F(GLES2ImplementationTest, ShaderSource) { | 399 TEST_F(GLES2ImplementationTest, ShaderSource) { |
388 const uint32 kBucketId = 1; // This id is hardcoded into GLES2Implemenation | 400 const uint32 kBucketId = 1; // This id is hardcoded into GLES2Implemenation |
389 const GLuint kShaderId = 456; | 401 const GLuint kShaderId = 456; |
390 const char* kString1 = "foobar"; | 402 const char* kString1 = "foobar"; |
391 const char* kString2 = "barfoo"; | 403 const char* kString2 = "barfoo"; |
392 const size_t kString1Size = strlen(kString1); | 404 const size_t kString1Size = strlen(kString1); |
393 const size_t kString2Size = strlen(kString2); | 405 const size_t kString2Size = strlen(kString2); |
394 const size_t kString3Size = 1; // Want the NULL; | 406 const size_t kString3Size = 1; // Want the NULL; |
395 const size_t kSourceSize = kString1Size + kString2Size + kString3Size; | 407 const size_t kSourceSize = kString1Size + kString2Size + kString3Size; |
396 const size_t kPaddedString1Size = RoundToAlignment(kString1Size); | 408 const size_t kPaddedString1Size = RoundToAlignment(kString1Size); |
397 const size_t kPaddedString2Size = RoundToAlignment(kString2Size); | 409 const size_t kPaddedString2Size = RoundToAlignment(kString2Size); |
398 const size_t kPaddedString3Size = RoundToAlignment(kString3Size); | 410 const size_t kPaddedString3Size = RoundToAlignment(kString3Size); |
399 struct Cmds { | 411 struct Cmds { |
400 cmd::SetBucketSize set_bucket_size; | 412 cmd::SetBucketSize set_bucket_size; |
401 cmd::SetBucketData set_bucket_data1; | 413 cmd::SetBucketData set_bucket_data1; |
402 cmd::SetToken set_token1; | 414 cmd::SetToken set_token1; |
403 cmd::SetBucketData set_bucket_data2; | 415 cmd::SetBucketData set_bucket_data2; |
404 cmd::SetToken set_token2; | 416 cmd::SetToken set_token2; |
405 cmd::SetBucketData set_bucket_data3; | 417 cmd::SetBucketData set_bucket_data3; |
406 cmd::SetToken set_token3; | 418 cmd::SetToken set_token3; |
407 ShaderSourceBucket shader_source_bucket; | 419 ShaderSourceBucket shader_source_bucket; |
408 cmd::SetBucketSize clear_bucket_size; | 420 cmd::SetBucketSize clear_bucket_size; |
409 }; | 421 }; |
410 Cmds expected; | 422 Cmds expected; |
411 expected.set_bucket_size.Init(kBucketId, kSourceSize); | 423 expected.set_bucket_size.Init(kBucketId, kSourceSize); |
412 expected.set_bucket_data1.Init( | 424 expected.set_bucket_data1.Init( |
413 kBucketId, 0, kString1Size, kTransferBufferId, | 425 kBucketId, 0, kString1Size, transfer_buffer_id_, |
414 AllocateTransferBuffer(kPaddedString1Size)); | 426 AllocateTransferBuffer(kPaddedString1Size)); |
415 expected.set_token1.Init(GetNextToken()); | 427 expected.set_token1.Init(GetNextToken()); |
416 expected.set_bucket_data2.Init( | 428 expected.set_bucket_data2.Init( |
417 kBucketId, kString1Size, kString2Size, kTransferBufferId, | 429 kBucketId, kString1Size, kString2Size, transfer_buffer_id_, |
418 AllocateTransferBuffer(kPaddedString2Size)); | 430 AllocateTransferBuffer(kPaddedString2Size)); |
419 expected.set_token2.Init(GetNextToken()); | 431 expected.set_token2.Init(GetNextToken()); |
420 expected.set_bucket_data3.Init( | 432 expected.set_bucket_data3.Init( |
421 kBucketId, kString1Size + kString2Size, | 433 kBucketId, kString1Size + kString2Size, |
422 kString3Size, kTransferBufferId, | 434 kString3Size, transfer_buffer_id_, |
423 AllocateTransferBuffer(kPaddedString3Size)); | 435 AllocateTransferBuffer(kPaddedString3Size)); |
424 expected.set_token3.Init(GetNextToken()); | 436 expected.set_token3.Init(GetNextToken()); |
425 expected.shader_source_bucket.Init(kShaderId, kBucketId); | 437 expected.shader_source_bucket.Init(kShaderId, kBucketId); |
426 expected.clear_bucket_size.Init(kBucketId, 0); | 438 expected.clear_bucket_size.Init(kBucketId, 0); |
427 const char* strings[] = { | 439 const char* strings[] = { |
428 kString1, | 440 kString1, |
429 kString2, | 441 kString2, |
430 }; | 442 }; |
431 gl_->ShaderSource(kShaderId, 2, strings, NULL); | 443 gl_->ShaderSource(kShaderId, 2, strings, NULL); |
432 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 444 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
433 } | 445 } |
434 | 446 |
435 TEST_F(GLES2ImplementationTest, GetShaderSource) { | 447 TEST_F(GLES2ImplementationTest, GetShaderSource) { |
436 const uint32 kBucketId = 1; // This id is hardcoded into GLES2Implemenation | 448 const uint32 kBucketId = 1; // This id is hardcoded into GLES2Implemenation |
437 const GLuint kShaderId = 456; | 449 const GLuint kShaderId = 456; |
438 const Str7 kString = {"foobar"}; | 450 const Str7 kString = {"foobar"}; |
439 const char kBad = 0x12; | 451 const char kBad = 0x12; |
440 struct Cmds { | 452 struct Cmds { |
441 cmd::SetBucketSize set_bucket_size1; | 453 cmd::SetBucketSize set_bucket_size1; |
442 GetShaderSource get_shader_source; | 454 GetShaderSource get_shader_source; |
443 cmd::GetBucketSize get_bucket_size; | 455 cmd::GetBucketSize get_bucket_size; |
444 cmd::GetBucketData get_bucket_data; | 456 cmd::GetBucketData get_bucket_data; |
445 cmd::SetToken set_token1; | 457 cmd::SetToken set_token1; |
446 cmd::SetBucketSize set_bucket_size2; | 458 cmd::SetBucketSize set_bucket_size2; |
447 }; | 459 }; |
448 uint32 offset = AllocateTransferBuffer(sizeof(kString)); | 460 uint32 offset = AllocateTransferBuffer(sizeof(kString)); |
449 Cmds expected; | 461 Cmds expected; |
450 expected.set_bucket_size1.Init(kBucketId, 0); | 462 expected.set_bucket_size1.Init(kBucketId, 0); |
451 expected.get_shader_source.Init(kShaderId, kBucketId); | 463 expected.get_shader_source.Init(kShaderId, kBucketId); |
452 expected.get_bucket_size.Init(kBucketId, kTransferBufferId, 0); | 464 expected.get_bucket_size.Init(kBucketId, transfer_buffer_id_, 0); |
453 expected.get_bucket_data.Init( | 465 expected.get_bucket_data.Init( |
454 kBucketId, 0, sizeof(kString), kTransferBufferId, offset); | 466 kBucketId, 0, sizeof(kString), transfer_buffer_id_, offset); |
455 expected.set_token1.Init(GetNextToken()); | 467 expected.set_token1.Init(GetNextToken()); |
456 expected.set_bucket_size2.Init(kBucketId, 0); | 468 expected.set_bucket_size2.Init(kBucketId, 0); |
457 char buf[sizeof(kString) + 1]; | 469 char buf[sizeof(kString) + 1]; |
458 memset(buf, kBad, sizeof(buf)); | 470 memset(buf, kBad, sizeof(buf)); |
459 | 471 |
460 EXPECT_CALL(*command_buffer_, OnFlush(_)) | 472 EXPECT_CALL(*command_buffer_, OnFlush(_)) |
461 .WillOnce(SetMemory(uint32(sizeof(kString)))) | 473 .WillOnce(SetMemory(uint32(sizeof(kString)))) |
462 .WillOnce(SetMemoryAtOffset(offset, kString)) | 474 .WillOnce(SetMemoryAtOffset(offset, kString)) |
463 .RetiresOnSaturation(); | 475 .RetiresOnSaturation(); |
464 | 476 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
506 const GLsizei kEmuOffset1 = 0; | 518 const GLsizei kEmuOffset1 = 0; |
507 const GLsizei kEmuOffset2 = kSize1; | 519 const GLsizei kEmuOffset2 = kSize1; |
508 | 520 |
509 const GLsizei kTotalSize = kSize1 + kSize2; | 521 const GLsizei kTotalSize = kSize1 + kSize2; |
510 Cmds expected; | 522 Cmds expected; |
511 expected.enable1.Init(kAttribIndex1); | 523 expected.enable1.Init(kAttribIndex1); |
512 expected.enable2.Init(kAttribIndex2); | 524 expected.enable2.Init(kAttribIndex2); |
513 expected.bind_to_emu.Init(GL_ARRAY_BUFFER, kEmuBufferId); | 525 expected.bind_to_emu.Init(GL_ARRAY_BUFFER, kEmuBufferId); |
514 expected.set_size.Init(GL_ARRAY_BUFFER, kTotalSize, 0, 0, GL_DYNAMIC_DRAW); | 526 expected.set_size.Init(GL_ARRAY_BUFFER, kTotalSize, 0, 0, GL_DYNAMIC_DRAW); |
515 expected.copy_data1.Init( | 527 expected.copy_data1.Init( |
516 GL_ARRAY_BUFFER, kEmuOffset1, kSize1, kTransferBufferId, | 528 GL_ARRAY_BUFFER, kEmuOffset1, kSize1, transfer_buffer_id_, |
517 AllocateTransferBuffer(kSize1)); | 529 AllocateTransferBuffer(kSize1)); |
518 expected.set_token1.Init(GetNextToken()); | 530 expected.set_token1.Init(GetNextToken()); |
519 expected.set_pointer1.Init(kAttribIndex1, kNumComponents1, | 531 expected.set_pointer1.Init(kAttribIndex1, kNumComponents1, |
520 GL_FLOAT, GL_FALSE, 0, kEmuOffset1); | 532 GL_FLOAT, GL_FALSE, 0, kEmuOffset1); |
521 expected.copy_data2.Init( | 533 expected.copy_data2.Init( |
522 GL_ARRAY_BUFFER, kEmuOffset2, kSize2, kTransferBufferId, | 534 GL_ARRAY_BUFFER, kEmuOffset2, kSize2, transfer_buffer_id_, |
523 AllocateTransferBuffer(kSize2)); | 535 AllocateTransferBuffer(kSize2)); |
524 expected.set_token2.Init(GetNextToken()); | 536 expected.set_token2.Init(GetNextToken()); |
525 expected.set_pointer2.Init(kAttribIndex2, kNumComponents2, | 537 expected.set_pointer2.Init(kAttribIndex2, kNumComponents2, |
526 GL_FLOAT, GL_FALSE, 0, kEmuOffset2); | 538 GL_FLOAT, GL_FALSE, 0, kEmuOffset2); |
527 expected.draw.Init(GL_POINTS, kFirst, kCount); | 539 expected.draw.Init(GL_POINTS, kFirst, kCount); |
528 expected.restore.Init(GL_ARRAY_BUFFER, 0); | 540 expected.restore.Init(GL_ARRAY_BUFFER, 0); |
529 gl_->EnableVertexAttribArray(kAttribIndex1); | 541 gl_->EnableVertexAttribArray(kAttribIndex1); |
530 gl_->EnableVertexAttribArray(kAttribIndex2); | 542 gl_->EnableVertexAttribArray(kAttribIndex2); |
531 gl_->VertexAttribPointer(kAttribIndex1, kNumComponents1, | 543 gl_->VertexAttribPointer(kAttribIndex1, kNumComponents1, |
532 GL_FLOAT, GL_FALSE, kClientStride, verts); | 544 GL_FLOAT, GL_FALSE, kClientStride, verts); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
582 const GLsizei kEmuOffset2 = kSize1; | 594 const GLsizei kEmuOffset2 = kSize1; |
583 | 595 |
584 const GLsizei kTotalSize = kSize1 + kSize2; | 596 const GLsizei kTotalSize = kSize1 + kSize2; |
585 Cmds expected; | 597 Cmds expected; |
586 expected.enable1.Init(kAttribIndex1); | 598 expected.enable1.Init(kAttribIndex1); |
587 expected.enable2.Init(kAttribIndex2); | 599 expected.enable2.Init(kAttribIndex2); |
588 expected.bind_to_index_emu.Init(GL_ELEMENT_ARRAY_BUFFER, kEmuIndexBufferId); | 600 expected.bind_to_index_emu.Init(GL_ELEMENT_ARRAY_BUFFER, kEmuIndexBufferId); |
589 expected.set_index_size.Init( | 601 expected.set_index_size.Init( |
590 GL_ELEMENT_ARRAY_BUFFER, kIndexSize, 0, 0, GL_DYNAMIC_DRAW); | 602 GL_ELEMENT_ARRAY_BUFFER, kIndexSize, 0, 0, GL_DYNAMIC_DRAW); |
591 expected.copy_data0.Init( | 603 expected.copy_data0.Init( |
592 GL_ELEMENT_ARRAY_BUFFER, 0, kIndexSize, kTransferBufferId, | 604 GL_ELEMENT_ARRAY_BUFFER, 0, kIndexSize, transfer_buffer_id_, |
593 AllocateTransferBuffer(kIndexSize)); | 605 AllocateTransferBuffer(kIndexSize)); |
594 expected.set_token0.Init(GetNextToken()); | 606 expected.set_token0.Init(GetNextToken()); |
595 expected.bind_to_emu.Init(GL_ARRAY_BUFFER, kEmuBufferId); | 607 expected.bind_to_emu.Init(GL_ARRAY_BUFFER, kEmuBufferId); |
596 expected.set_size.Init(GL_ARRAY_BUFFER, kTotalSize, 0, 0, GL_DYNAMIC_DRAW); | 608 expected.set_size.Init(GL_ARRAY_BUFFER, kTotalSize, 0, 0, GL_DYNAMIC_DRAW); |
597 expected.copy_data1.Init( | 609 expected.copy_data1.Init( |
598 GL_ARRAY_BUFFER, kEmuOffset1, kSize1, kTransferBufferId, | 610 GL_ARRAY_BUFFER, kEmuOffset1, kSize1, transfer_buffer_id_, |
599 AllocateTransferBuffer(kSize1)); | 611 AllocateTransferBuffer(kSize1)); |
600 expected.set_token1.Init(GetNextToken()); | 612 expected.set_token1.Init(GetNextToken()); |
601 expected.set_pointer1.Init(kAttribIndex1, kNumComponents1, | 613 expected.set_pointer1.Init(kAttribIndex1, kNumComponents1, |
602 GL_FLOAT, GL_FALSE, 0, kEmuOffset1); | 614 GL_FLOAT, GL_FALSE, 0, kEmuOffset1); |
603 expected.copy_data2.Init( | 615 expected.copy_data2.Init( |
604 GL_ARRAY_BUFFER, kEmuOffset2, kSize2, kTransferBufferId, | 616 GL_ARRAY_BUFFER, kEmuOffset2, kSize2, transfer_buffer_id_, |
605 AllocateTransferBuffer(kSize2)); | 617 AllocateTransferBuffer(kSize2)); |
606 expected.set_token2.Init(GetNextToken()); | 618 expected.set_token2.Init(GetNextToken()); |
607 expected.set_pointer2.Init(kAttribIndex2, kNumComponents2, | 619 expected.set_pointer2.Init(kAttribIndex2, kNumComponents2, |
608 GL_FLOAT, GL_FALSE, 0, kEmuOffset2); | 620 GL_FLOAT, GL_FALSE, 0, kEmuOffset2); |
609 expected.draw.Init(GL_POINTS, kCount, GL_UNSIGNED_SHORT, 0); | 621 expected.draw.Init(GL_POINTS, kCount, GL_UNSIGNED_SHORT, 0); |
610 expected.restore.Init(GL_ARRAY_BUFFER, 0); | 622 expected.restore.Init(GL_ARRAY_BUFFER, 0); |
611 expected.restore_element.Init(GL_ELEMENT_ARRAY_BUFFER, 0); | 623 expected.restore_element.Init(GL_ELEMENT_ARRAY_BUFFER, 0); |
612 gl_->EnableVertexAttribArray(kAttribIndex1); | 624 gl_->EnableVertexAttribArray(kAttribIndex1); |
613 gl_->EnableVertexAttribArray(kAttribIndex2); | 625 gl_->EnableVertexAttribArray(kAttribIndex2); |
614 gl_->VertexAttribPointer(kAttribIndex1, kNumComponents1, | 626 gl_->VertexAttribPointer(kAttribIndex1, kNumComponents1, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
658 arraysize(verts) * kNumComponents2 * sizeof(verts[0][0]); | 670 arraysize(verts) * kNumComponents2 * sizeof(verts[0][0]); |
659 const GLsizei kEmuOffset1 = 0; | 671 const GLsizei kEmuOffset1 = 0; |
660 const GLsizei kEmuOffset2 = kSize1; | 672 const GLsizei kEmuOffset2 = kSize1; |
661 | 673 |
662 const GLsizei kTotalSize = kSize1 + kSize2; | 674 const GLsizei kTotalSize = kSize1 + kSize2; |
663 Cmds expected; | 675 Cmds expected; |
664 expected.enable1.Init(kAttribIndex1); | 676 expected.enable1.Init(kAttribIndex1); |
665 expected.enable2.Init(kAttribIndex2); | 677 expected.enable2.Init(kAttribIndex2); |
666 expected.bind_to_index.Init(GL_ELEMENT_ARRAY_BUFFER, kClientIndexBufferId); | 678 expected.bind_to_index.Init(GL_ELEMENT_ARRAY_BUFFER, kClientIndexBufferId); |
667 expected.get_max.Init(kClientIndexBufferId, kCount, GL_UNSIGNED_SHORT, | 679 expected.get_max.Init(kClientIndexBufferId, kCount, GL_UNSIGNED_SHORT, |
668 kIndexOffset, kTransferBufferId, 0); | 680 kIndexOffset, transfer_buffer_id_, 0); |
669 expected.bind_to_emu.Init(GL_ARRAY_BUFFER, kEmuBufferId); | 681 expected.bind_to_emu.Init(GL_ARRAY_BUFFER, kEmuBufferId); |
670 expected.set_size.Init(GL_ARRAY_BUFFER, kTotalSize, 0, 0, GL_DYNAMIC_DRAW); | 682 expected.set_size.Init(GL_ARRAY_BUFFER, kTotalSize, 0, 0, GL_DYNAMIC_DRAW); |
671 expected.copy_data1.Init( | 683 expected.copy_data1.Init( |
672 GL_ARRAY_BUFFER, kEmuOffset1, kSize1, kTransferBufferId, | 684 GL_ARRAY_BUFFER, kEmuOffset1, kSize1, transfer_buffer_id_, |
673 AllocateTransferBuffer(kSize1)); | 685 AllocateTransferBuffer(kSize1)); |
674 expected.set_token1.Init(GetNextToken()); | 686 expected.set_token1.Init(GetNextToken()); |
675 expected.set_pointer1.Init(kAttribIndex1, kNumComponents1, | 687 expected.set_pointer1.Init(kAttribIndex1, kNumComponents1, |
676 GL_FLOAT, GL_FALSE, 0, kEmuOffset1); | 688 GL_FLOAT, GL_FALSE, 0, kEmuOffset1); |
677 expected.copy_data2.Init( | 689 expected.copy_data2.Init( |
678 GL_ARRAY_BUFFER, kEmuOffset2, kSize2, kTransferBufferId, | 690 GL_ARRAY_BUFFER, kEmuOffset2, kSize2, transfer_buffer_id_, |
679 AllocateTransferBuffer(kSize2)); | 691 AllocateTransferBuffer(kSize2)); |
680 expected.set_token2.Init(GetNextToken()); | 692 expected.set_token2.Init(GetNextToken()); |
681 expected.set_pointer2.Init(kAttribIndex2, kNumComponents2, | 693 expected.set_pointer2.Init(kAttribIndex2, kNumComponents2, |
682 GL_FLOAT, GL_FALSE, 0, kEmuOffset2); | 694 GL_FLOAT, GL_FALSE, 0, kEmuOffset2); |
683 expected.draw.Init(GL_POINTS, kCount, GL_UNSIGNED_SHORT, kIndexOffset); | 695 expected.draw.Init(GL_POINTS, kCount, GL_UNSIGNED_SHORT, kIndexOffset); |
684 expected.restore.Init(GL_ARRAY_BUFFER, 0); | 696 expected.restore.Init(GL_ARRAY_BUFFER, 0); |
685 | 697 |
686 EXPECT_CALL(*command_buffer_, OnFlush(_)) | 698 EXPECT_CALL(*command_buffer_, OnFlush(_)) |
687 .WillOnce(SetMemory(kMaxIndex)) | 699 .WillOnce(SetMemory(kMaxIndex)) |
688 .RetiresOnSaturation(); | 700 .RetiresOnSaturation(); |
(...skipping 26 matching lines...) Expand all Loading... | |
715 struct Cmds { | 727 struct Cmds { |
716 BindBuffer bind; | 728 BindBuffer bind; |
717 VertexAttribPointer set_pointer; | 729 VertexAttribPointer set_pointer; |
718 GetVertexAttribPointerv get_pointer; | 730 GetVertexAttribPointerv get_pointer; |
719 }; | 731 }; |
720 Cmds expected; | 732 Cmds expected; |
721 expected.bind.Init(GL_ARRAY_BUFFER, kBufferId); | 733 expected.bind.Init(GL_ARRAY_BUFFER, kBufferId); |
722 expected.set_pointer.Init(kAttribIndex2, kNumComponents2, GL_FLOAT, GL_FALSE, | 734 expected.set_pointer.Init(kAttribIndex2, kNumComponents2, GL_FLOAT, GL_FALSE, |
723 kStride2, kOffset2); | 735 kStride2, kOffset2); |
724 expected.get_pointer.Init(kAttribIndex2, GL_VERTEX_ATTRIB_ARRAY_POINTER, | 736 expected.get_pointer.Init(kAttribIndex2, GL_VERTEX_ATTRIB_ARRAY_POINTER, |
725 kTransferBufferId, 0); | 737 transfer_buffer_id_, 0); |
726 | 738 |
727 // One call to flush to way for GetVertexAttribPointerv | 739 // One call to flush to way for GetVertexAttribPointerv |
728 EXPECT_CALL(*command_buffer_, OnFlush(_)) | 740 EXPECT_CALL(*command_buffer_, OnFlush(_)) |
729 .WillOnce(SetMemory(SizedResultHelper<uint32>(kOffset2))) | 741 .WillOnce(SetMemory(SizedResultHelper<uint32>(kOffset2))) |
730 .RetiresOnSaturation(); | 742 .RetiresOnSaturation(); |
731 | 743 |
732 // Set one client side buffer. | 744 // Set one client side buffer. |
733 gl_->VertexAttribPointer(kAttribIndex1, kNumComponents1, | 745 gl_->VertexAttribPointer(kAttribIndex1, kNumComponents1, |
734 GL_FLOAT, GL_FALSE, kStride1, verts); | 746 GL_FLOAT, GL_FALSE, kStride1, verts); |
735 // Set one VBO | 747 // Set one VBO |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
772 GetVertexAttribiv get1; // for getting the buffer from attrib2 | 784 GetVertexAttribiv get1; // for getting the buffer from attrib2 |
773 GetVertexAttribfv get2; // for getting the value from attrib1 | 785 GetVertexAttribfv get2; // for getting the value from attrib1 |
774 }; | 786 }; |
775 Cmds expected; | 787 Cmds expected; |
776 expected.enable.Init(kAttribIndex1); | 788 expected.enable.Init(kAttribIndex1); |
777 expected.bind.Init(GL_ARRAY_BUFFER, kBufferId); | 789 expected.bind.Init(GL_ARRAY_BUFFER, kBufferId); |
778 expected.set_pointer.Init(kAttribIndex2, kNumComponents2, GL_FLOAT, GL_FALSE, | 790 expected.set_pointer.Init(kAttribIndex2, kNumComponents2, GL_FLOAT, GL_FALSE, |
779 kStride2, kOffset2); | 791 kStride2, kOffset2); |
780 expected.get1.Init(kAttribIndex2, | 792 expected.get1.Init(kAttribIndex2, |
781 GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, | 793 GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, |
782 kTransferBufferId, 0); | 794 transfer_buffer_id_, 0); |
783 expected.get2.Init(kAttribIndex1, | 795 expected.get2.Init(kAttribIndex1, |
784 GL_CURRENT_VERTEX_ATTRIB, | 796 GL_CURRENT_VERTEX_ATTRIB, |
785 kTransferBufferId, 0); | 797 transfer_buffer_id_, 0); |
786 | 798 |
787 FourFloats current_attrib(1.2f, 3.4f, 5.6f, 7.8f); | 799 FourFloats current_attrib(1.2f, 3.4f, 5.6f, 7.8f); |
788 | 800 |
789 // One call to flush to way for GetVertexAttribiv | 801 // One call to flush to way for GetVertexAttribiv |
790 EXPECT_CALL(*command_buffer_, OnFlush(_)) | 802 EXPECT_CALL(*command_buffer_, OnFlush(_)) |
791 .WillOnce(SetMemory(SizedResultHelper<GLuint>(kBufferId))) | 803 .WillOnce(SetMemory(SizedResultHelper<GLuint>(kBufferId))) |
792 .WillOnce(SetMemory(SizedResultHelper<FourFloats>(current_attrib))) | 804 .WillOnce(SetMemory(SizedResultHelper<FourFloats>(current_attrib))) |
793 .RetiresOnSaturation(); | 805 .RetiresOnSaturation(); |
794 | 806 |
795 gl_->EnableVertexAttribArray(kAttribIndex1); | 807 gl_->EnableVertexAttribArray(kAttribIndex1); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
838 | 850 |
839 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 851 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
840 } | 852 } |
841 | 853 |
842 TEST_F(GLES2ImplementationTest, ReservedIds) { | 854 TEST_F(GLES2ImplementationTest, ReservedIds) { |
843 // Only the get error command should be issued. | 855 // Only the get error command should be issued. |
844 struct Cmds { | 856 struct Cmds { |
845 GetError get; | 857 GetError get; |
846 }; | 858 }; |
847 Cmds expected; | 859 Cmds expected; |
848 expected.get.Init(kTransferBufferId, 0); | 860 expected.get.Init(transfer_buffer_id_, 0); |
849 | 861 |
850 // One call to flush to wait for GetError | 862 // One call to flush to wait for GetError |
851 EXPECT_CALL(*command_buffer_, OnFlush(_)) | 863 EXPECT_CALL(*command_buffer_, OnFlush(_)) |
852 .WillOnce(SetMemory(GLuint(GL_NO_ERROR))) | 864 .WillOnce(SetMemory(GLuint(GL_NO_ERROR))) |
853 .RetiresOnSaturation(); | 865 .RetiresOnSaturation(); |
854 | 866 |
855 gl_->BindBuffer( | 867 gl_->BindBuffer( |
856 GL_ARRAY_BUFFER, | 868 GL_ARRAY_BUFFER, |
857 GLES2Implementation::kClientSideArrayId); | 869 GLES2Implementation::kClientSideArrayId); |
858 gl_->BindBuffer( | 870 gl_->BindBuffer( |
(...skipping 17 matching lines...) Expand all Loading... | |
876 const GLint kWidth = | 888 const GLint kWidth = |
877 (kTransferBufferSize - GLES2Implementation::kStartingOffset) / | 889 (kTransferBufferSize - GLES2Implementation::kStartingOffset) / |
878 kBytesPerPixel; | 890 kBytesPerPixel; |
879 const GLint kHeight = 2; | 891 const GLint kHeight = 2; |
880 const GLenum kFormat = GL_RGBA; | 892 const GLenum kFormat = GL_RGBA; |
881 const GLenum kType = GL_UNSIGNED_BYTE; | 893 const GLenum kType = GL_UNSIGNED_BYTE; |
882 | 894 |
883 Cmds expected; | 895 Cmds expected; |
884 expected.read1.Init( | 896 expected.read1.Init( |
885 0, 0, kWidth, kHeight / 2, kFormat, kType, | 897 0, 0, kWidth, kHeight / 2, kFormat, kType, |
886 kTransferBufferId, | 898 transfer_buffer_id_, |
887 AllocateTransferBuffer(kWidth * kHeight / 2 * kBytesPerPixel), | 899 AllocateTransferBuffer(kWidth * kHeight / 2 * kBytesPerPixel), |
888 kTransferBufferId, 0); | 900 transfer_buffer_id_, 0); |
889 expected.set_token1.Init(GetNextToken()); | 901 expected.set_token1.Init(GetNextToken()); |
890 expected.read2.Init( | 902 expected.read2.Init( |
891 0, kHeight / 2, kWidth, kHeight / 2, kFormat, kType, | 903 0, kHeight / 2, kWidth, kHeight / 2, kFormat, kType, |
892 kTransferBufferId, | 904 transfer_buffer_id_, |
893 AllocateTransferBuffer(kWidth * kHeight / 2 * kBytesPerPixel), | 905 AllocateTransferBuffer(kWidth * kHeight / 2 * kBytesPerPixel), |
894 kTransferBufferId, 0); | 906 transfer_buffer_id_, 0); |
895 expected.set_token2.Init(GetNextToken()); | 907 expected.set_token2.Init(GetNextToken()); |
896 scoped_array<int8> buffer(new int8[kWidth * kHeight * kBytesPerPixel]); | 908 scoped_array<int8> buffer(new int8[kWidth * kHeight * kBytesPerPixel]); |
897 | 909 |
898 EXPECT_CALL(*command_buffer_, OnFlush(_)) | 910 EXPECT_CALL(*command_buffer_, OnFlush(_)) |
899 .WillOnce(SetMemory(static_cast<uint32>(1))) | 911 .WillOnce(SetMemory(static_cast<uint32>(1))) |
900 .WillOnce(SetMemory(static_cast<uint32>(1))) | 912 .WillOnce(SetMemory(static_cast<uint32>(1))) |
901 .RetiresOnSaturation(); | 913 .RetiresOnSaturation(); |
902 | 914 |
903 gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, buffer.get()); | 915 gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, buffer.get()); |
904 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 916 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
905 } | 917 } |
906 | 918 |
907 TEST_F(GLES2ImplementationTest, ReadPixelsBadFormatType) { | 919 TEST_F(GLES2ImplementationTest, ReadPixelsBadFormatType) { |
908 struct Cmds { | 920 struct Cmds { |
909 ReadPixels read; | 921 ReadPixels read; |
910 cmd::SetToken set_token; | 922 cmd::SetToken set_token; |
911 }; | 923 }; |
912 const GLint kBytesPerPixel = 4; | 924 const GLint kBytesPerPixel = 4; |
913 const GLint kWidth = 2; | 925 const GLint kWidth = 2; |
914 const GLint kHeight = 2; | 926 const GLint kHeight = 2; |
915 const GLenum kFormat = 0; | 927 const GLenum kFormat = 0; |
916 const GLenum kType = 0; | 928 const GLenum kType = 0; |
917 | 929 |
918 Cmds expected; | 930 Cmds expected; |
919 expected.read.Init( | 931 expected.read.Init( |
920 0, 0, kWidth, kHeight / 2, kFormat, kType, | 932 0, 0, kWidth, kHeight / 2, kFormat, kType, |
921 kTransferBufferId, | 933 transfer_buffer_id_, |
922 AllocateTransferBuffer(kWidth * kHeight * kBytesPerPixel), | 934 AllocateTransferBuffer(kWidth * kHeight * kBytesPerPixel), |
923 kTransferBufferId, 0); | 935 transfer_buffer_id_, 0); |
924 expected.set_token.Init(GetNextToken()); | 936 expected.set_token.Init(GetNextToken()); |
925 scoped_array<int8> buffer(new int8[kWidth * kHeight * kBytesPerPixel]); | 937 scoped_array<int8> buffer(new int8[kWidth * kHeight * kBytesPerPixel]); |
926 | 938 |
927 EXPECT_CALL(*command_buffer_, OnFlush(_)) | 939 EXPECT_CALL(*command_buffer_, OnFlush(_)) |
928 .Times(1) | 940 .Times(1) |
929 .RetiresOnSaturation(); | 941 .RetiresOnSaturation(); |
930 | 942 |
931 gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, buffer.get()); | 943 gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, buffer.get()); |
932 } | 944 } |
933 | 945 |
934 TEST_F(GLES2ImplementationTest, FreeUnusedSharedMemory) { | 946 TEST_F(GLES2ImplementationTest, FreeUnusedSharedMemory) { |
935 struct Cmds { | 947 struct Cmds { |
936 BufferSubData buf; | 948 BufferSubData buf; |
937 cmd::SetToken set_token; | 949 cmd::SetToken set_token; |
938 }; | 950 }; |
939 const GLenum kTarget = GL_ELEMENT_ARRAY_BUFFER; | 951 const GLenum kTarget = GL_ELEMENT_ARRAY_BUFFER; |
940 const GLintptr kOffset = 15; | 952 const GLintptr kOffset = 15; |
941 const GLsizeiptr kSize = 16; | 953 const GLsizeiptr kSize = 16; |
942 | 954 |
943 uint32 offset = 0; | 955 uint32 offset = 0; |
944 Cmds expected; | 956 Cmds expected; |
945 expected.buf.Init( | 957 expected.buf.Init( |
946 kTarget, kOffset, kSize, kTransferBufferId, offset); | 958 kTarget, kOffset, kSize, transfer_buffer_id_, offset); |
947 expected.set_token.Init(GetNextToken()); | 959 expected.set_token.Init(GetNextToken()); |
948 | 960 |
949 void* mem = gl_->MapBufferSubDataCHROMIUM( | 961 void* mem = gl_->MapBufferSubDataCHROMIUM( |
950 kTarget, kOffset, kSize, GL_WRITE_ONLY); | 962 kTarget, kOffset, kSize, GL_WRITE_ONLY); |
951 ASSERT_TRUE(mem != NULL); | 963 ASSERT_TRUE(mem != NULL); |
952 gl_->UnmapBufferSubDataCHROMIUM(mem); | 964 gl_->UnmapBufferSubDataCHROMIUM(mem); |
953 EXPECT_CALL(*command_buffer_, DestroyTransferBuffer(_))\ | 965 EXPECT_CALL(*command_buffer_, DestroyTransferBuffer(_))\ |
954 .Times(1) | 966 .Times(1) |
955 .RetiresOnSaturation(); | 967 .RetiresOnSaturation(); |
956 gl_->FreeUnusedSharedMemory(); | 968 gl_->FreeUnusedSharedMemory(); |
957 } | 969 } |
958 | 970 |
959 TEST_F(GLES2ImplementationTest, MapUnmapBufferSubDataCHROMIUM) { | 971 TEST_F(GLES2ImplementationTest, MapUnmapBufferSubDataCHROMIUM) { |
960 struct Cmds { | 972 struct Cmds { |
961 BufferSubData buf; | 973 BufferSubData buf; |
962 cmd::SetToken set_token; | 974 cmd::SetToken set_token; |
963 }; | 975 }; |
964 const GLenum kTarget = GL_ELEMENT_ARRAY_BUFFER; | 976 const GLenum kTarget = GL_ELEMENT_ARRAY_BUFFER; |
965 const GLintptr kOffset = 15; | 977 const GLintptr kOffset = 15; |
966 const GLsizeiptr kSize = 16; | 978 const GLsizeiptr kSize = 16; |
967 | 979 |
968 uint32 offset = 0; | 980 uint32 offset = 0; |
969 Cmds expected; | 981 Cmds expected; |
970 expected.buf.Init( | 982 expected.buf.Init( |
971 kTarget, kOffset, kSize, kTransferBufferId, offset); | 983 kTarget, kOffset, kSize, GetNextFreeTransferBufferId(), offset); |
972 expected.set_token.Init(GetNextToken()); | 984 expected.set_token.Init(GetNextToken()); |
973 | 985 |
974 void* mem = gl_->MapBufferSubDataCHROMIUM( | 986 void* mem = gl_->MapBufferSubDataCHROMIUM( |
975 kTarget, kOffset, kSize, GL_WRITE_ONLY); | 987 kTarget, kOffset, kSize, GL_WRITE_ONLY); |
976 ASSERT_TRUE(mem != NULL); | 988 ASSERT_TRUE(mem != NULL); |
977 gl_->UnmapBufferSubDataCHROMIUM(mem); | 989 gl_->UnmapBufferSubDataCHROMIUM(mem); |
978 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 990 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
979 } | 991 } |
980 | 992 |
981 TEST_F(GLES2ImplementationTest, MapUnmapBufferSubDataCHROMIUMBadArgs) { | 993 TEST_F(GLES2ImplementationTest, MapUnmapBufferSubDataCHROMIUMBadArgs) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1016 const GLint kYOffset = 3; | 1028 const GLint kYOffset = 3; |
1017 const GLint kWidth = 4; | 1029 const GLint kWidth = 4; |
1018 const GLint kHeight = 5; | 1030 const GLint kHeight = 5; |
1019 const GLenum kFormat = GL_RGBA; | 1031 const GLenum kFormat = GL_RGBA; |
1020 const GLenum kType = GL_UNSIGNED_BYTE; | 1032 const GLenum kType = GL_UNSIGNED_BYTE; |
1021 | 1033 |
1022 uint32 offset = 0; | 1034 uint32 offset = 0; |
1023 Cmds expected; | 1035 Cmds expected; |
1024 expected.tex.Init( | 1036 expected.tex.Init( |
1025 GL_TEXTURE_2D, kLevel, kXOffset, kYOffset, kWidth, kHeight, kFormat, | 1037 GL_TEXTURE_2D, kLevel, kXOffset, kYOffset, kWidth, kHeight, kFormat, |
1026 kType, kTransferBufferId, offset, GL_FALSE); | 1038 kType, GetNextFreeTransferBufferId(), offset, GL_FALSE); |
1027 expected.set_token.Init(GetNextToken()); | 1039 expected.set_token.Init(GetNextToken()); |
1028 | 1040 |
1029 void* mem = gl_->MapTexSubImage2DCHROMIUM( | 1041 void* mem = gl_->MapTexSubImage2DCHROMIUM( |
1030 GL_TEXTURE_2D, | 1042 GL_TEXTURE_2D, |
1031 kLevel, | 1043 kLevel, |
1032 kXOffset, | 1044 kXOffset, |
1033 kYOffset, | 1045 kYOffset, |
1034 kWidth, | 1046 kWidth, |
1035 kHeight, | 1047 kHeight, |
1036 kFormat, | 1048 kFormat, |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1151 GetMultipleIntegervCHROMIUM get_multiple; | 1163 GetMultipleIntegervCHROMIUM get_multiple; |
1152 cmd::SetToken set_token; | 1164 cmd::SetToken set_token; |
1153 }; | 1165 }; |
1154 const GLsizei kNumPnames = arraysize(pnames); | 1166 const GLsizei kNumPnames = arraysize(pnames); |
1155 const GLsizeiptr kResultsSize = num_results * sizeof(results[0]); | 1167 const GLsizeiptr kResultsSize = num_results * sizeof(results[0]); |
1156 const uint32 kPnamesOffset = | 1168 const uint32 kPnamesOffset = |
1157 AllocateTransferBuffer(kNumPnames * sizeof(pnames[0])); | 1169 AllocateTransferBuffer(kNumPnames * sizeof(pnames[0])); |
1158 const uint32 kResultsOffset = AllocateTransferBuffer(kResultsSize); | 1170 const uint32 kResultsOffset = AllocateTransferBuffer(kResultsSize); |
1159 Cmds expected; | 1171 Cmds expected; |
1160 expected.get_multiple.Init( | 1172 expected.get_multiple.Init( |
1161 kTransferBufferId, kPnamesOffset, kNumPnames, | 1173 transfer_buffer_id_, kPnamesOffset, kNumPnames, |
1162 kTransferBufferId, kResultsOffset, kResultsSize); | 1174 transfer_buffer_id_, kResultsOffset, kResultsSize); |
1163 expected.set_token.Init(GetNextToken()); | 1175 expected.set_token.Init(GetNextToken()); |
1164 | 1176 |
1165 const GLint kSentinel = 0x12345678; | 1177 const GLint kSentinel = 0x12345678; |
1166 memset(results, 0, sizeof(results)); | 1178 memset(results, 0, sizeof(results)); |
1167 results[num_results] = kSentinel; | 1179 results[num_results] = kSentinel; |
1168 const GLint returned_results[] = { | 1180 const GLint returned_results[] = { |
1169 1, 0, 1, 0, 1, -1, | 1181 1, 0, 1, 0, 1, -1, |
1170 }; | 1182 }; |
1171 // One call to flush to wait for results | 1183 // One call to flush to wait for results |
1172 EXPECT_CALL(*command_buffer_, OnFlush(_)) | 1184 EXPECT_CALL(*command_buffer_, OnFlush(_)) |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1261 cmd::SetBucketSize set_bucket_size1; | 1273 cmd::SetBucketSize set_bucket_size1; |
1262 GetProgramInfoCHROMIUM get_program_info; | 1274 GetProgramInfoCHROMIUM get_program_info; |
1263 cmd::GetBucketSize get_bucket_size; | 1275 cmd::GetBucketSize get_bucket_size; |
1264 cmd::GetBucketData get_bucket_data; | 1276 cmd::GetBucketData get_bucket_data; |
1265 cmd::SetToken set_token1; | 1277 cmd::SetToken set_token1; |
1266 cmd::SetBucketSize set_bucket_size2; | 1278 cmd::SetBucketSize set_bucket_size2; |
1267 }; | 1279 }; |
1268 Cmds expected; | 1280 Cmds expected; |
1269 expected.set_bucket_size1.Init(kBucketId, 0); | 1281 expected.set_bucket_size1.Init(kBucketId, 0); |
1270 expected.get_program_info.Init(kProgramId, kBucketId); | 1282 expected.get_program_info.Init(kProgramId, kBucketId); |
1271 expected.get_bucket_size.Init(kBucketId, kTransferBufferId, 0); | 1283 expected.get_bucket_size.Init(kBucketId, transfer_buffer_id_, 0); |
1272 expected.get_bucket_data.Init( | 1284 expected.get_bucket_data.Init( |
1273 kBucketId, 0, sizeof(kString), kTransferBufferId, offset); | 1285 kBucketId, 0, sizeof(kString), transfer_buffer_id_, offset); |
1274 expected.set_token1.Init(GetNextToken()); | 1286 expected.set_token1.Init(GetNextToken()); |
1275 expected.set_bucket_size2.Init(kBucketId, 0); | 1287 expected.set_bucket_size2.Init(kBucketId, 0); |
1276 gl_->GetProgramInfoCHROMIUM(kProgramId, sizeof(buf), &size, &buf); | 1288 gl_->GetProgramInfoCHROMIUM(kProgramId, sizeof(buf), &size, &buf); |
1277 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 1289 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
1278 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); | 1290 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); |
1279 EXPECT_EQ(sizeof(kString), static_cast<size_t>(size)); | 1291 EXPECT_EQ(sizeof(kString), static_cast<size_t>(size)); |
1280 EXPECT_STREQ(kString.str, buf); | 1292 EXPECT_STREQ(kString.str, buf); |
1281 EXPECT_EQ(buf[sizeof(kString)], kBad); | 1293 EXPECT_EQ(buf[sizeof(kString)], kBad); |
1282 } | 1294 } |
1283 | 1295 |
(...skipping 18 matching lines...) Expand all Loading... | |
1302 cmd::SetBucketSize set_bucket_size1; | 1314 cmd::SetBucketSize set_bucket_size1; |
1303 GetProgramInfoCHROMIUM get_program_info; | 1315 GetProgramInfoCHROMIUM get_program_info; |
1304 cmd::GetBucketSize get_bucket_size; | 1316 cmd::GetBucketSize get_bucket_size; |
1305 cmd::GetBucketData get_bucket_data; | 1317 cmd::GetBucketData get_bucket_data; |
1306 cmd::SetToken set_token1; | 1318 cmd::SetToken set_token1; |
1307 cmd::SetBucketSize set_bucket_size2; | 1319 cmd::SetBucketSize set_bucket_size2; |
1308 }; | 1320 }; |
1309 Cmds expected; | 1321 Cmds expected; |
1310 expected.set_bucket_size1.Init(kBucketId, 0); | 1322 expected.set_bucket_size1.Init(kBucketId, 0); |
1311 expected.get_program_info.Init(kProgramId, kBucketId); | 1323 expected.get_program_info.Init(kProgramId, kBucketId); |
1312 expected.get_bucket_size.Init(kBucketId, kTransferBufferId, 0); | 1324 expected.get_bucket_size.Init(kBucketId, transfer_buffer_id_, 0); |
1313 expected.get_bucket_data.Init( | 1325 expected.get_bucket_data.Init( |
1314 kBucketId, 0, sizeof(kString), kTransferBufferId, offset); | 1326 kBucketId, 0, sizeof(kString), transfer_buffer_id_, offset); |
1315 expected.set_token1.Init(GetNextToken()); | 1327 expected.set_token1.Init(GetNextToken()); |
1316 expected.set_bucket_size2.Init(kBucketId, 0); | 1328 expected.set_bucket_size2.Init(kBucketId, 0); |
1317 gl_->GetProgramInfoCHROMIUM(kProgramId, 6, &size, &buf); | 1329 gl_->GetProgramInfoCHROMIUM(kProgramId, 6, &size, &buf); |
1318 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 1330 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
1319 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), gl_->GetError()); | 1331 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), gl_->GetError()); |
1320 ClearCommands(); | 1332 ClearCommands(); |
1321 | 1333 |
1322 // try bad bufsize | 1334 // try bad bufsize |
1323 gl_->GetProgramInfoCHROMIUM(kProgramId, -1, &size, &buf); | 1335 gl_->GetProgramInfoCHROMIUM(kProgramId, -1, &size, &buf); |
1324 EXPECT_TRUE(NoCommandsWritten()); | 1336 EXPECT_TRUE(NoCommandsWritten()); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1480 static uint8 pixels[] = { | 1492 static uint8 pixels[] = { |
1481 11, 12, 13, 13, 14, 15, 15, 16, 17, 101, 102, 103, | 1493 11, 12, 13, 13, 14, 15, 15, 16, 17, 101, 102, 103, |
1482 21, 22, 23, 23, 24, 25, 25, 26, 27, 201, 202, 203, | 1494 21, 22, 23, 23, 24, 25, 25, 26, 27, 201, 202, 203, |
1483 31, 32, 33, 33, 34, 35, 35, 36, 37, 123, 124, 125, | 1495 31, 32, 33, 33, 34, 35, 35, 36, 37, 123, 124, 125, |
1484 41, 42, 43, 43, 44, 45, 45, 46, 47, | 1496 41, 42, 43, 43, 44, 45, 45, 46, 47, |
1485 }; | 1497 }; |
1486 uint32 offset = AllocateTransferBuffer(sizeof(pixels)); | 1498 uint32 offset = AllocateTransferBuffer(sizeof(pixels)); |
1487 Cmds expected; | 1499 Cmds expected; |
1488 expected.tex_image_2d.Init( | 1500 expected.tex_image_2d.Init( |
1489 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, | 1501 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, |
1490 kTransferBufferId, offset); | 1502 transfer_buffer_id_, offset); |
1491 expected.set_token.Init(GetNextToken()); | 1503 expected.set_token.Init(GetNextToken()); |
1492 gl_->TexImage2D( | 1504 gl_->TexImage2D( |
1493 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, | 1505 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, |
1494 pixels); | 1506 pixels); |
1495 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 1507 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
1496 EXPECT_TRUE(CheckRect( | 1508 EXPECT_TRUE(CheckRect( |
1497 kWidth, kHeight, kFormat, kType, kPixelStoreUnpackAlignment, false, | 1509 kWidth, kHeight, kFormat, kType, kPixelStoreUnpackAlignment, false, |
1498 pixels, GetTransferAddressFromOffsetAs<uint8>(offset, sizeof(pixels)))); | 1510 pixels, GetTransferAddressFromOffsetAs<uint8>(offset, sizeof(pixels)))); |
1499 | 1511 |
1500 ClearCommands(); | 1512 ClearCommands(); |
1501 uint32 offset2 = AllocateTransferBuffer(sizeof(pixels)); | 1513 uint32 offset2 = AllocateTransferBuffer(sizeof(pixels)); |
1502 Cmds2 expected2; | 1514 Cmds2 expected2; |
1503 expected2.tex_image_2d.Init( | 1515 expected2.tex_image_2d.Init( |
1504 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, | 1516 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, |
1505 kTransferBufferId, offset2); | 1517 transfer_buffer_id_, offset2); |
1506 expected2.set_token.Init(GetNextToken()); | 1518 expected2.set_token.Init(GetNextToken()); |
1507 const void* commands2 = GetPut(); | 1519 const void* commands2 = GetPut(); |
1508 gl_->PixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE); | 1520 gl_->PixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE); |
1509 gl_->TexImage2D( | 1521 gl_->TexImage2D( |
1510 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, | 1522 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, |
1511 pixels); | 1523 pixels); |
1512 EXPECT_EQ(0, memcmp(&expected2, commands2, sizeof(expected2))); | 1524 EXPECT_EQ(0, memcmp(&expected2, commands2, sizeof(expected2))); |
1513 EXPECT_TRUE(CheckRect( | 1525 EXPECT_TRUE(CheckRect( |
1514 kWidth, kHeight, kFormat, kType, kPixelStoreUnpackAlignment, true, | 1526 kWidth, kHeight, kFormat, kType, kPixelStoreUnpackAlignment, true, |
1515 pixels, GetTransferAddressFromOffsetAs<uint8>(offset2, sizeof(pixels)))); | 1527 pixels, GetTransferAddressFromOffsetAs<uint8>(offset2, sizeof(pixels)))); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1552 pixels[ii] = static_cast<uint8>(ii); | 1564 pixels[ii] = static_cast<uint8>(ii); |
1553 } | 1565 } |
1554 uint32 offset1 = AllocateTransferBuffer(half_size); | 1566 uint32 offset1 = AllocateTransferBuffer(half_size); |
1555 uint32 offset2 = AllocateTransferBuffer(half_size); | 1567 uint32 offset2 = AllocateTransferBuffer(half_size); |
1556 Cmds expected; | 1568 Cmds expected; |
1557 expected.tex_image_2d.Init( | 1569 expected.tex_image_2d.Init( |
1558 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, | 1570 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, |
1559 0, 0); | 1571 0, 0); |
1560 expected.tex_sub_image_2d1.Init( | 1572 expected.tex_sub_image_2d1.Init( |
1561 kTarget, kLevel, 0, 0, kWidth, kHeight / 2, kFormat, kType, | 1573 kTarget, kLevel, 0, 0, kWidth, kHeight / 2, kFormat, kType, |
1562 kTransferBufferId, offset1, true); | 1574 transfer_buffer_id_, offset1, true); |
1563 expected.set_token1.Init(GetNextToken()); | 1575 expected.set_token1.Init(GetNextToken()); |
1564 expected.tex_sub_image_2d2.Init( | 1576 expected.tex_sub_image_2d2.Init( |
1565 kTarget, kLevel, 0, kHeight / 2, kWidth, kHeight / 2, kFormat, kType, | 1577 kTarget, kLevel, 0, kHeight / 2, kWidth, kHeight / 2, kFormat, kType, |
1566 kTransferBufferId, offset2, true); | 1578 transfer_buffer_id_, offset2, true); |
1567 expected.set_token2.Init(GetNextToken()); | 1579 expected.set_token2.Init(GetNextToken()); |
1568 | 1580 |
1569 // TODO(gman): Make it possible to run this test | 1581 // TODO(gman): Make it possible to run this test |
1570 // EXPECT_CALL(*command_buffer_, OnFlush(_)) | 1582 // EXPECT_CALL(*command_buffer_, OnFlush(_)) |
1571 // .WillOnce(CheckRectAction( | 1583 // .WillOnce(CheckRectAction( |
1572 // kWidth, kHeight / 2, kFormat, kType, kPixelStoreUnpackAlignment, | 1584 // kWidth, kHeight / 2, kFormat, kType, kPixelStoreUnpackAlignment, |
1573 // false, pixels.get(), | 1585 // false, pixels.get(), |
1574 // GetTransferAddressFromOffsetAs<uint8>(offset1, half_size))) | 1586 // GetTransferAddressFromOffsetAs<uint8>(offset1, half_size))) |
1575 // .RetiresOnSaturation(); | 1587 // .RetiresOnSaturation(); |
1576 | 1588 |
1577 gl_->TexImage2D( | 1589 gl_->TexImage2D( |
1578 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, | 1590 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, |
1579 pixels.get()); | 1591 pixels.get()); |
1580 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 1592 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
1581 EXPECT_TRUE(CheckRect( | 1593 EXPECT_TRUE(CheckRect( |
1582 kWidth, kHeight / 2, kFormat, kType, kPixelStoreUnpackAlignment, false, | 1594 kWidth, kHeight / 2, kFormat, kType, kPixelStoreUnpackAlignment, false, |
1583 pixels.get() + kHeight / 2 * padded_row_size, | 1595 pixels.get() + kHeight / 2 * padded_row_size, |
1584 GetTransferAddressFromOffsetAs<uint8>(offset2, half_size))); | 1596 GetTransferAddressFromOffsetAs<uint8>(offset2, half_size))); |
1585 | 1597 |
1586 ClearCommands(); | 1598 ClearCommands(); |
1587 const void* commands2 = GetPut(); | 1599 const void* commands2 = GetPut(); |
1588 uint32 offset3 = AllocateTransferBuffer(half_size); | 1600 uint32 offset3 = AllocateTransferBuffer(half_size); |
1589 uint32 offset4 = AllocateTransferBuffer(half_size); | 1601 uint32 offset4 = AllocateTransferBuffer(half_size); |
1590 expected.tex_image_2d.Init( | 1602 expected.tex_image_2d.Init( |
1591 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, | 1603 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, |
1592 0, 0); | 1604 0, 0); |
1593 expected.tex_sub_image_2d1.Init( | 1605 expected.tex_sub_image_2d1.Init( |
1594 kTarget, kLevel, 0, kHeight / 2, kWidth, kHeight / 2, kFormat, kType, | 1606 kTarget, kLevel, 0, kHeight / 2, kWidth, kHeight / 2, kFormat, kType, |
1595 kTransferBufferId, offset3, true); | 1607 transfer_buffer_id_, offset3, true); |
1596 expected.set_token1.Init(GetNextToken()); | 1608 expected.set_token1.Init(GetNextToken()); |
1597 expected.tex_sub_image_2d2.Init( | 1609 expected.tex_sub_image_2d2.Init( |
1598 kTarget, kLevel, 0, 0, kWidth, kHeight / 2, kFormat, kType, | 1610 kTarget, kLevel, 0, 0, kWidth, kHeight / 2, kFormat, kType, |
1599 kTransferBufferId, offset4, true); | 1611 transfer_buffer_id_, offset4, true); |
1600 expected.set_token2.Init(GetNextToken()); | 1612 expected.set_token2.Init(GetNextToken()); |
1601 | 1613 |
1602 // TODO(gman): Make it possible to run this test | 1614 // TODO(gman): Make it possible to run this test |
1603 // EXPECT_CALL(*command_buffer_, OnFlush(_)) | 1615 // EXPECT_CALL(*command_buffer_, OnFlush(_)) |
1604 // .WillOnce(CheckRectAction( | 1616 // .WillOnce(CheckRectAction( |
1605 // kWidth, kHeight / 2, kFormat, kType, kPixelStoreUnpackAlignment, | 1617 // kWidth, kHeight / 2, kFormat, kType, kPixelStoreUnpackAlignment, |
1606 // true, pixels.get(), | 1618 // true, pixels.get(), |
1607 // GetTransferAddressFromOffsetAs<uint8>(offset3, half_size))) | 1619 // GetTransferAddressFromOffsetAs<uint8>(offset3, half_size))) |
1608 // .RetiresOnSaturation(); | 1620 // .RetiresOnSaturation(); |
1609 | 1621 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1655 uint32 offset1 = AllocateTransferBuffer(part_size); | 1667 uint32 offset1 = AllocateTransferBuffer(part_size); |
1656 uint32 offset2 = AllocateTransferBuffer(part_size); | 1668 uint32 offset2 = AllocateTransferBuffer(part_size); |
1657 uint32 offset3 = AllocateTransferBuffer(part_size); | 1669 uint32 offset3 = AllocateTransferBuffer(part_size); |
1658 uint32 offset4 = AllocateTransferBuffer(part_size); | 1670 uint32 offset4 = AllocateTransferBuffer(part_size); |
1659 Cmds expected; | 1671 Cmds expected; |
1660 expected.tex_image_2d.Init( | 1672 expected.tex_image_2d.Init( |
1661 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, | 1673 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, |
1662 0, 0); | 1674 0, 0); |
1663 expected.tex_sub_image_2d1.Init( | 1675 expected.tex_sub_image_2d1.Init( |
1664 kTarget, kLevel, 0, 0, kWidth / 2, 1, kFormat, kType, | 1676 kTarget, kLevel, 0, 0, kWidth / 2, 1, kFormat, kType, |
1665 kTransferBufferId, offset1, true); | 1677 transfer_buffer_id_, offset1, true); |
1666 expected.set_token1.Init(GetNextToken()); | 1678 expected.set_token1.Init(GetNextToken()); |
1667 expected.tex_sub_image_2d2.Init( | 1679 expected.tex_sub_image_2d2.Init( |
1668 kTarget, kLevel, kWidth / 2, 0, kWidth / 2, 1, kFormat, kType, | 1680 kTarget, kLevel, kWidth / 2, 0, kWidth / 2, 1, kFormat, kType, |
1669 kTransferBufferId, offset2, true); | 1681 transfer_buffer_id_, offset2, true); |
1670 expected.set_token2.Init(GetNextToken()); | 1682 expected.set_token2.Init(GetNextToken()); |
1671 expected.tex_sub_image_2d3.Init( | 1683 expected.tex_sub_image_2d3.Init( |
1672 kTarget, kLevel, 0, 1, kWidth / 2, 1, kFormat, kType, | 1684 kTarget, kLevel, 0, 1, kWidth / 2, 1, kFormat, kType, |
1673 kTransferBufferId, offset3, true); | 1685 transfer_buffer_id_, offset3, true); |
1674 expected.set_token3.Init(GetNextToken()); | 1686 expected.set_token3.Init(GetNextToken()); |
1675 expected.tex_sub_image_2d4.Init( | 1687 expected.tex_sub_image_2d4.Init( |
1676 kTarget, kLevel, kWidth / 2, 1, kWidth / 2, 1, kFormat, kType, | 1688 kTarget, kLevel, kWidth / 2, 1, kWidth / 2, 1, kFormat, kType, |
1677 kTransferBufferId, offset4, true); | 1689 transfer_buffer_id_, offset4, true); |
1678 expected.set_token4.Init(GetNextToken()); | 1690 expected.set_token4.Init(GetNextToken()); |
1679 | 1691 |
1680 // TODO(gman): Make it possible to run this test | 1692 // TODO(gman): Make it possible to run this test |
1681 // EXPECT_CALL(*command_buffer_, OnFlush(_)) | 1693 // EXPECT_CALL(*command_buffer_, OnFlush(_)) |
1682 // .WillOnce(CheckRectAction( | 1694 // .WillOnce(CheckRectAction( |
1683 // kWidth / 2, 1, kFormat, kType, kPixelStoreUnpackAlignment, false, | 1695 // kWidth / 2, 1, kFormat, kType, kPixelStoreUnpackAlignment, false, |
1684 // pixels.get(), | 1696 // pixels.get(), |
1685 // GetTransferAddressFromOffsetAs<uint8>(offset1, part_size))) | 1697 // GetTransferAddressFromOffsetAs<uint8>(offset1, part_size))) |
1686 // .WillOnce(CheckRectAction( | 1698 // .WillOnce(CheckRectAction( |
1687 // kWidth / 2, 1, kFormat, kType, kPixelStoreUnpackAlignment, false, | 1699 // kWidth / 2, 1, kFormat, kType, kPixelStoreUnpackAlignment, false, |
(...skipping 18 matching lines...) Expand all Loading... | |
1706 const void* commands2 = GetPut(); | 1718 const void* commands2 = GetPut(); |
1707 offset1 = AllocateTransferBuffer(part_size); | 1719 offset1 = AllocateTransferBuffer(part_size); |
1708 offset2 = AllocateTransferBuffer(part_size); | 1720 offset2 = AllocateTransferBuffer(part_size); |
1709 offset3 = AllocateTransferBuffer(part_size); | 1721 offset3 = AllocateTransferBuffer(part_size); |
1710 offset4 = AllocateTransferBuffer(part_size); | 1722 offset4 = AllocateTransferBuffer(part_size); |
1711 expected.tex_image_2d.Init( | 1723 expected.tex_image_2d.Init( |
1712 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, | 1724 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, |
1713 0, 0); | 1725 0, 0); |
1714 expected.tex_sub_image_2d1.Init( | 1726 expected.tex_sub_image_2d1.Init( |
1715 kTarget, kLevel, 0, 1, kWidth / 2, 1, kFormat, kType, | 1727 kTarget, kLevel, 0, 1, kWidth / 2, 1, kFormat, kType, |
1716 kTransferBufferId, offset1, true); | 1728 transfer_buffer_id_, offset1, true); |
1717 expected.set_token1.Init(GetNextToken()); | 1729 expected.set_token1.Init(GetNextToken()); |
1718 expected.tex_sub_image_2d2.Init( | 1730 expected.tex_sub_image_2d2.Init( |
1719 kTarget, kLevel, kWidth / 2, 1, kWidth / 2, 1, kFormat, kType, | 1731 kTarget, kLevel, kWidth / 2, 1, kWidth / 2, 1, kFormat, kType, |
1720 kTransferBufferId, offset2, true); | 1732 transfer_buffer_id_, offset2, true); |
1721 expected.set_token2.Init(GetNextToken()); | 1733 expected.set_token2.Init(GetNextToken()); |
1722 expected.tex_sub_image_2d3.Init( | 1734 expected.tex_sub_image_2d3.Init( |
1723 kTarget, kLevel, 0, 0, kWidth / 2, 1, kFormat, kType, | 1735 kTarget, kLevel, 0, 0, kWidth / 2, 1, kFormat, kType, |
1724 kTransferBufferId, offset3, true); | 1736 transfer_buffer_id_, offset3, true); |
1725 expected.set_token3.Init(GetNextToken()); | 1737 expected.set_token3.Init(GetNextToken()); |
1726 expected.tex_sub_image_2d4.Init( | 1738 expected.tex_sub_image_2d4.Init( |
1727 kTarget, kLevel, kWidth / 2, 0, kWidth / 2, 1, kFormat, kType, | 1739 kTarget, kLevel, kWidth / 2, 0, kWidth / 2, 1, kFormat, kType, |
1728 kTransferBufferId, offset4, true); | 1740 transfer_buffer_id_, offset4, true); |
1729 expected.set_token4.Init(GetNextToken()); | 1741 expected.set_token4.Init(GetNextToken()); |
1730 | 1742 |
1731 // TODO(gman): Make it possible to run this test | 1743 // TODO(gman): Make it possible to run this test |
1732 // EXPECT_CALL(*command_buffer_, OnFlush(_)) | 1744 // EXPECT_CALL(*command_buffer_, OnFlush(_)) |
1733 // .WillOnce(CheckRectAction( | 1745 // .WillOnce(CheckRectAction( |
1734 // kWidth / 2, 1, kFormat, kType, kPixelStoreUnpackAlignment, false, | 1746 // kWidth / 2, 1, kFormat, kType, kPixelStoreUnpackAlignment, false, |
1735 // pixels.get(), | 1747 // pixels.get(), |
1736 // GetTransferAddressFromOffsetAs<uint8>(offset1, part_size))) | 1748 // GetTransferAddressFromOffsetAs<uint8>(offset1, part_size))) |
1737 // .WillOnce(CheckRectAction( | 1749 // .WillOnce(CheckRectAction( |
1738 // kWidth / 2, 1, kFormat, kType, kPixelStoreUnpackAlignment, false, | 1750 // kWidth / 2, 1, kFormat, kType, kPixelStoreUnpackAlignment, false, |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1830 TEST_F(GLES2ImplementationTest, CreateStreamTextureCHROMIUM) { | 1842 TEST_F(GLES2ImplementationTest, CreateStreamTextureCHROMIUM) { |
1831 const GLuint kTextureId = 123; | 1843 const GLuint kTextureId = 123; |
1832 const GLuint kResult = 456; | 1844 const GLuint kResult = 456; |
1833 const uint32 kResultOffset = 0; | 1845 const uint32 kResultOffset = 0; |
1834 | 1846 |
1835 struct Cmds { | 1847 struct Cmds { |
1836 CreateStreamTextureCHROMIUM create_stream; | 1848 CreateStreamTextureCHROMIUM create_stream; |
1837 }; | 1849 }; |
1838 | 1850 |
1839 Cmds expected; | 1851 Cmds expected; |
1840 expected.create_stream.Init(kTextureId, kTransferBufferId, kResultOffset); | 1852 expected.create_stream.Init(kTextureId, transfer_buffer_id_, kResultOffset); |
1841 | 1853 |
1842 EXPECT_CALL(*command_buffer_, OnFlush(_)) | 1854 EXPECT_CALL(*command_buffer_, OnFlush(_)) |
1843 .WillOnce(SetMemoryAtOffset(kResultOffset, kResult)) | 1855 .WillOnce(SetMemoryAtOffset(kResultOffset, kResult)) |
1844 .WillOnce(SetMemory(GLuint(GL_NO_ERROR))) | 1856 .WillOnce(SetMemory(GLuint(GL_NO_ERROR))) |
1845 .RetiresOnSaturation(); | 1857 .RetiresOnSaturation(); |
1846 | 1858 |
1847 GLuint handle = gl_->CreateStreamTextureCHROMIUM(kTextureId); | 1859 GLuint handle = gl_->CreateStreamTextureCHROMIUM(kTextureId); |
1848 EXPECT_EQ(handle, kResult); | 1860 EXPECT_EQ(handle, kResult); |
1849 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); | 1861 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); |
1850 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 1862 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
(...skipping 10 matching lines...) Expand all Loading... | |
1861 expected.destroy_stream.Init(kTextureHandle); | 1873 expected.destroy_stream.Init(kTextureHandle); |
1862 | 1874 |
1863 gl_->DestroyStreamTextureCHROMIUM(kTextureHandle); | 1875 gl_->DestroyStreamTextureCHROMIUM(kTextureHandle); |
1864 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 1876 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
1865 } | 1877 } |
1866 | 1878 |
1867 } // namespace gles2 | 1879 } // namespace gles2 |
1868 } // namespace gpu | 1880 } // namespace gpu |
1869 | 1881 |
1870 | 1882 |
OLD | NEW |