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 using testing::_; | |
19 using testing::DoAll; | |
20 using testing::InSequence; | |
21 using testing::Invoke; | |
22 using testing::Mock; | |
23 using testing::Sequence; | |
24 using testing::Truly; | |
25 using testing::Return; | |
26 | |
27 namespace gpu { | 18 namespace gpu { |
28 | 19 |
29 class GLES2MockCommandBufferHelper : public CommandBuffer { | 20 class GLES2MockCommandBufferHelper : public CommandBuffer { |
30 public: | 21 public: |
31 static const int32 kTransferBufferBaseId = 0x123; | 22 static const int32 kTransferBufferId = 0x123; |
32 static const int32 kMaxTransferBuffers = 6; | |
33 | 23 |
34 GLES2MockCommandBufferHelper() { } | 24 GLES2MockCommandBufferHelper() { } |
35 virtual ~GLES2MockCommandBufferHelper() { } | 25 virtual ~GLES2MockCommandBufferHelper() { } |
36 | 26 |
37 // CommandBuffer implementation: | 27 // CommandBuffer implementation: |
38 virtual bool Initialize() { | 28 virtual bool Initialize(int32 size) { |
| 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. |
39 return true; | 34 return true; |
40 } | 35 } |
41 | 36 |
| 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 |
42 virtual State GetState() { | 46 virtual State GetState() { |
43 return state_; | 47 return state_; |
44 } | 48 } |
45 | 49 |
46 virtual State GetLastState() { | 50 virtual State GetLastState() { |
47 return state_; | 51 return state_; |
48 } | 52 } |
49 | 53 |
50 virtual void Flush(int32 put_offset) { | 54 virtual void Flush(int32 put_offset) { |
51 state_.put_offset = put_offset; | 55 state_.put_offset = put_offset; |
52 } | 56 } |
53 | 57 |
54 virtual State FlushSync(int32 put_offset, int32 last_known_get) { | 58 virtual State FlushSync(int32 put_offset, int32 last_known_get) { |
55 state_.put_offset = put_offset; | 59 state_.put_offset = put_offset; |
56 state_.get_offset = put_offset; | 60 state_.get_offset = put_offset; |
57 // Warning: This is a hack. We just happen to know that the default | 61 OnFlush(transfer_buffer_buffer_.ptr); |
58 // transfer buffer will be the first transfer buffer. | |
59 OnFlush(transfer_buffer_buffers_[0].ptr); | |
60 return state_; | 62 return state_; |
61 } | 63 } |
62 | 64 |
63 virtual void SetGetBuffer(int transfer_buffer_id) { | |
64 ring_buffer_buffer_ = GetTransferBuffer(transfer_buffer_id); | |
65 ring_buffer_ = static_cast<CommandBufferEntry*>(ring_buffer_buffer_.ptr); | |
66 state_.num_entries = ring_buffer_buffer_.size / sizeof(ring_buffer_[0]); | |
67 state_.token = 10000; // All token checks in the tests should pass. | |
68 } | |
69 | |
70 virtual void SetGetOffset(int32 get_offset) { | 65 virtual void SetGetOffset(int32 get_offset) { |
71 state_.get_offset = get_offset; | 66 state_.get_offset = get_offset; |
72 } | 67 } |
73 | 68 |
74 // Get's the Id of the next transfer buffer that will be returned | 69 virtual int32 CreateTransferBuffer(size_t size, int32 id_request) { |
75 // by CreateTransferBuffer. This is useful for testing expected ids. | 70 transfer_buffer_.reset(new int8[size]); |
76 int32 GetNextFreeTransferBufferId() { | 71 transfer_buffer_buffer_.ptr = transfer_buffer_.get(); |
77 for (size_t ii = 0; ii < arraysize(transfer_buffers_); ++ii) { | 72 transfer_buffer_buffer_.size = size; |
78 if (!transfer_buffers_[ii].get()) { | 73 return kTransferBufferId; |
79 return kTransferBufferBaseId + ii; | |
80 } | |
81 } | |
82 return -1; | |
83 } | 74 } |
84 | 75 |
85 virtual int32 CreateTransferBuffer(size_t size, int32 id_request) { | 76 virtual void DestroyTransferBuffer(int32 /* id */) { |
86 int32 id = GetNextFreeTransferBufferId(); | 77 GPU_NOTREACHED(); |
87 if (id >= 0) { | |
88 int32 ndx = id - kTransferBufferBaseId; | |
89 transfer_buffers_[ndx].reset(new int8[size]); | |
90 transfer_buffer_buffers_[ndx].ptr = transfer_buffers_[ndx].get(); | |
91 transfer_buffer_buffers_[ndx].size = size; | |
92 } | |
93 return id; | |
94 } | |
95 | |
96 void DestroyTransferBufferHelper(int32 id) { | |
97 GPU_DCHECK_GE(id, kTransferBufferBaseId); | |
98 GPU_DCHECK_LT(id, kTransferBufferBaseId + kMaxTransferBuffers); | |
99 id -= kTransferBufferBaseId; | |
100 transfer_buffers_[id].reset(); | |
101 transfer_buffer_buffers_[id] = Buffer(); | |
102 } | 78 } |
103 | 79 |
104 virtual Buffer GetTransferBuffer(int32 id) { | 80 virtual Buffer GetTransferBuffer(int32 id) { |
105 GPU_DCHECK_GE(id, kTransferBufferBaseId); | 81 GPU_DCHECK_EQ(id, kTransferBufferId); |
106 GPU_DCHECK_LT(id, kTransferBufferBaseId + kMaxTransferBuffers); | 82 return transfer_buffer_buffer_; |
107 return transfer_buffer_buffers_[id - kTransferBufferBaseId]; | |
108 } | 83 } |
109 | 84 |
110 virtual int32 RegisterTransferBuffer(base::SharedMemory* shared_memory, | 85 virtual int32 RegisterTransferBuffer(base::SharedMemory* shared_memory, |
111 size_t size, | 86 size_t size, |
112 int32 id_request) { | 87 int32 id_request) { |
113 GPU_NOTREACHED(); | 88 GPU_NOTREACHED(); |
114 return -1; | 89 return -1; |
115 } | 90 } |
116 | 91 |
117 virtual void SetToken(int32 token) { | 92 virtual void SetToken(int32 token) { |
118 GPU_NOTREACHED(); | 93 GPU_NOTREACHED(); |
119 state_.token = token; | 94 state_.token = token; |
120 } | 95 } |
121 | 96 |
122 virtual void SetParseError(error::Error error) { | 97 virtual void SetParseError(error::Error error) { |
123 GPU_NOTREACHED(); | 98 GPU_NOTREACHED(); |
124 state_.error = error; | 99 state_.error = error; |
125 } | 100 } |
126 | 101 |
127 virtual void SetContextLostReason(error::ContextLostReason reason) { | 102 virtual void SetContextLostReason(error::ContextLostReason reason) { |
128 GPU_NOTREACHED(); | 103 GPU_NOTREACHED(); |
129 state_.context_lost_reason = reason; | 104 state_.context_lost_reason = reason; |
130 } | 105 } |
131 | 106 |
132 virtual void OnFlush(void* transfer_buffer) = 0; | 107 virtual void OnFlush(void* transfer_buffer) = 0; |
133 | 108 |
134 private: | 109 private: |
135 scoped_array<int8> transfer_buffers_[kMaxTransferBuffers]; | 110 scoped_array<int8> transfer_buffer_; |
136 Buffer transfer_buffer_buffers_[kMaxTransferBuffers]; | 111 Buffer transfer_buffer_buffer_; |
137 CommandBufferEntry* ring_buffer_; | 112 scoped_array<CommandBufferEntry> ring_buffer_; |
138 Buffer ring_buffer_buffer_; | 113 Buffer ring_buffer_buffer_; |
139 State state_; | 114 State state_; |
140 }; | 115 }; |
141 | 116 |
142 class MockGLES2CommandBuffer : public GLES2MockCommandBufferHelper { | 117 class MockGLES2CommandBuffer : public GLES2MockCommandBufferHelper { |
143 public: | 118 public: |
144 MockGLES2CommandBuffer() { | |
145 DelegateToFake(); | |
146 } | |
147 | |
148 virtual ~MockGLES2CommandBuffer() { | 119 virtual ~MockGLES2CommandBuffer() { |
149 } | 120 } |
150 | 121 |
151 // This is so we can use all the gmock functions when Flush is called. | 122 // This is so we can use all the gmock functions when Flush is called. |
152 MOCK_METHOD1(OnFlush, void(void* result)); | 123 MOCK_METHOD1(OnFlush, void(void* result)); |
153 MOCK_METHOD1(DestroyTransferBuffer, void(int32 id)); | 124 MOCK_METHOD1(DestroyTransferBuffer, void(int32 id)); |
154 | |
155 void DelegateToFake() { | |
156 ON_CALL(*this, DestroyTransferBuffer(_)) | |
157 .WillByDefault(Invoke( | |
158 this, &GLES2MockCommandBufferHelper::DestroyTransferBufferHelper)); | |
159 } | |
160 }; | 125 }; |
161 | 126 |
162 // GCC requires these declarations, but MSVC requires they not be present | 127 // GCC requires these declarations, but MSVC requires they not be present |
163 #ifndef _MSC_VER | 128 #ifndef _MSC_VER |
164 const int32 GLES2MockCommandBufferHelper::kTransferBufferBaseId; | 129 const int32 GLES2MockCommandBufferHelper::kTransferBufferId; |
165 const int32 GLES2MockCommandBufferHelper::kMaxTransferBuffers; | |
166 #endif | 130 #endif |
167 | 131 |
168 namespace gles2 { | 132 namespace gles2 { |
169 | 133 |
| 134 using testing::_; |
| 135 using testing::DoAll; |
| 136 using testing::InSequence; |
| 137 using testing::Invoke; |
| 138 using testing::Mock; |
| 139 using testing::Sequence; |
| 140 using testing::Truly; |
| 141 using testing::Return; |
| 142 |
170 ACTION_P(SetMemory, obj) { | 143 ACTION_P(SetMemory, obj) { |
171 memcpy(arg0, &obj, sizeof(obj)); | 144 memcpy(arg0, &obj, sizeof(obj)); |
172 } | 145 } |
173 | 146 |
174 ACTION_P2(SetMemoryAtOffset, offset, obj) { | 147 ACTION_P2(SetMemoryAtOffset, offset, obj) { |
175 memcpy(static_cast<char*>(arg0) + offset, &obj, sizeof(obj)); | 148 memcpy(static_cast<char*>(arg0) + offset, &obj, sizeof(obj)); |
176 } | 149 } |
177 | 150 |
178 ACTION_P3(SetMemoryAtOffsetFromArray, offset, array, size) { | 151 ACTION_P3(SetMemoryAtOffsetFromArray, offset, array, size) { |
179 memcpy(static_cast<char*>(arg0) + offset, array, size); | 152 memcpy(static_cast<char*>(arg0) + offset, array, size); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 char str[7]; | 187 char str[7]; |
215 }; | 188 }; |
216 #pragma pack(pop) | 189 #pragma pack(pop) |
217 | 190 |
218 class GLES2CommandBufferTestBase : public testing::Test { | 191 class GLES2CommandBufferTestBase : public testing::Test { |
219 protected: | 192 protected: |
220 static const int32 kNumCommandEntries = 400; | 193 static const int32 kNumCommandEntries = 400; |
221 static const int32 kCommandBufferSizeBytes = | 194 static const int32 kCommandBufferSizeBytes = |
222 kNumCommandEntries * sizeof(CommandBufferEntry); | 195 kNumCommandEntries * sizeof(CommandBufferEntry); |
223 static const size_t kTransferBufferSize = 256; | 196 static const size_t kTransferBufferSize = 256; |
| 197 static const int32 kTransferBufferId = |
| 198 GLES2MockCommandBufferHelper::kTransferBufferId; |
224 static const uint8 kInitialValue = 0xBD; | 199 static const uint8 kInitialValue = 0xBD; |
225 | 200 |
226 GLES2CommandBufferTestBase() | 201 GLES2CommandBufferTestBase() |
227 : commands_(NULL), | 202 : commands_(NULL), |
228 token_(0), | 203 token_(0), |
229 offset_(0), | 204 offset_(0), |
230 initial_offset_(0), | 205 initial_offset_(0), |
231 alignment_(0), | 206 alignment_(0) { |
232 transfer_buffer_id_(-1) { | |
233 } | 207 } |
234 | 208 |
235 void SetupCommandBuffer(unsigned int offset, unsigned alignment) { | 209 void SetupCommandBuffer(unsigned int offset, unsigned alignment) { |
236 initial_offset_ = offset; | 210 initial_offset_ = offset; |
237 offset_ = offset; | 211 offset_ = offset; |
238 alignment_ = alignment; | 212 alignment_ = alignment; |
239 | 213 |
240 command_buffer_.reset(new MockGLES2CommandBuffer()); | 214 command_buffer_.reset(new MockGLES2CommandBuffer()); |
241 command_buffer_->Initialize(); | 215 command_buffer_->Initialize(kCommandBufferSizeBytes); |
242 | 216 |
243 transfer_buffer_id_ = | 217 EXPECT_EQ(kTransferBufferId, |
244 command_buffer_->CreateTransferBuffer(kTransferBufferSize, -1); | 218 command_buffer_->CreateTransferBuffer(kTransferBufferSize, -1)); |
245 transfer_buffer_ = command_buffer_->GetTransferBuffer(transfer_buffer_id_); | 219 transfer_buffer_ = command_buffer_->GetTransferBuffer(kTransferBufferId); |
246 ClearTransferBuffer(); | 220 ClearTransferBuffer(); |
247 | 221 |
248 helper_.reset(new GLES2CmdHelper(command_buffer_.get())); | 222 helper_.reset(new GLES2CmdHelper(command_buffer_.get())); |
249 helper_->Initialize(kCommandBufferSizeBytes); | 223 helper_->Initialize(kCommandBufferSizeBytes); |
250 } | 224 } |
251 | 225 |
252 const void* GetPut() { | 226 const void* GetPut() { |
253 return helper_->GetSpace(0); | 227 return helper_->GetSpace(0); |
254 } | 228 } |
255 | 229 |
256 size_t MaxTransferBufferSize() { | 230 size_t MaxTransferBufferSize() { |
257 return kTransferBufferSize - initial_offset_; | 231 return kTransferBufferSize - initial_offset_; |
258 } | 232 } |
259 | 233 |
260 void ClearCommands() { | 234 void ClearCommands() { |
261 Buffer ring_buffer = helper_->get_ring_buffer(); | 235 Buffer ring_buffer = command_buffer_->GetRingBuffer(); |
262 memset(ring_buffer.ptr, kInitialValue, ring_buffer.size); | 236 memset(ring_buffer.ptr, kInitialValue, ring_buffer.size); |
263 } | 237 } |
264 | 238 |
265 bool NoCommandsWritten() { | 239 bool NoCommandsWritten() { |
266 return static_cast<const uint8*>(static_cast<const void*>(commands_))[0] == | 240 return static_cast<const uint8*>(static_cast<const void*>(commands_))[0] == |
267 kInitialValue; | 241 kInitialValue; |
268 } | 242 } |
269 | 243 |
270 void ClearTransferBuffer() { | 244 void ClearTransferBuffer() { |
271 memset(transfer_buffer_.ptr, kInitialValue, kTransferBufferSize); | 245 memset(transfer_buffer_.ptr, kInitialValue, kTransferBufferSize); |
272 } | 246 } |
273 | 247 |
274 unsigned int RoundToAlignment(unsigned int size) { | 248 unsigned int RoundToAlignment(unsigned int size) { |
275 return (size + alignment_ - 1) & ~(alignment_ - 1); | 249 return (size + alignment_ - 1) & ~(alignment_ - 1); |
276 } | 250 } |
277 | 251 |
278 int GetNextToken() { | 252 int GetNextToken() { |
279 return ++token_; | 253 return ++token_; |
280 } | 254 } |
281 | 255 |
282 int32 GetNextFreeTransferBufferId() { | |
283 return command_buffer_->GetNextFreeTransferBufferId(); | |
284 } | |
285 | |
286 uint32 AllocateTransferBuffer(size_t size) { | 256 uint32 AllocateTransferBuffer(size_t size) { |
287 if (offset_ + size > kTransferBufferSize) { | 257 if (offset_ + size > kTransferBufferSize) { |
288 offset_ = initial_offset_; | 258 offset_ = initial_offset_; |
289 } | 259 } |
290 uint32 offset = offset_; | 260 uint32 offset = offset_; |
291 offset_ += RoundToAlignment(size); | 261 offset_ += RoundToAlignment(size); |
292 return offset; | 262 return offset; |
293 } | 263 } |
294 | 264 |
295 void* GetTransferAddressFromOffset(uint32 offset, size_t size) { | 265 void* GetTransferAddressFromOffset(uint32 offset, size_t size) { |
296 EXPECT_LE(offset + size, transfer_buffer_.size); | 266 EXPECT_LE(offset + size, transfer_buffer_.size); |
297 return static_cast<int8*>(transfer_buffer_.ptr) + offset; | 267 return static_cast<int8*>(transfer_buffer_.ptr) + offset; |
298 } | 268 } |
299 | 269 |
300 template <typename T> | 270 template <typename T> |
301 T* GetTransferAddressFromOffsetAs(uint32 offset, size_t size) { | 271 T* GetTransferAddressFromOffsetAs(uint32 offset, size_t size) { |
302 return static_cast<T*>(GetTransferAddressFromOffset(offset, size)); | 272 return static_cast<T*>(GetTransferAddressFromOffset(offset, size)); |
303 } | 273 } |
304 | 274 |
305 Buffer transfer_buffer_; | 275 Buffer transfer_buffer_; |
306 CommandBufferEntry* commands_; | 276 CommandBufferEntry* commands_; |
307 scoped_ptr<MockGLES2CommandBuffer> command_buffer_; | 277 scoped_ptr<MockGLES2CommandBuffer> command_buffer_; |
308 scoped_ptr<GLES2CmdHelper> helper_; | 278 scoped_ptr<GLES2CmdHelper> helper_; |
309 int token_; | 279 int token_; |
310 uint32 offset_; | 280 uint32 offset_; |
311 uint32 initial_offset_; | 281 uint32 initial_offset_; |
312 uint32 alignment_; | 282 uint32 alignment_; |
313 int32 transfer_buffer_id_; | |
314 }; | 283 }; |
315 | 284 |
316 // GCC requires these declarations, but MSVC requires they not be present | 285 // GCC requires these declarations, but MSVC requires they not be present |
317 #ifndef _MSC_VER | 286 #ifndef _MSC_VER |
318 const int32 GLES2CommandBufferTestBase::kNumCommandEntries; | 287 const int32 GLES2CommandBufferTestBase::kNumCommandEntries; |
319 const int32 GLES2CommandBufferTestBase::kCommandBufferSizeBytes; | 288 const int32 GLES2CommandBufferTestBase::kCommandBufferSizeBytes; |
320 const size_t GLES2CommandBufferTestBase::kTransferBufferSize; | 289 const size_t GLES2CommandBufferTestBase::kTransferBufferSize; |
| 290 const int32 GLES2CommandBufferTestBase::kTransferBufferId; |
321 const uint8 GLES2CommandBufferTestBase::kInitialValue; | 291 const uint8 GLES2CommandBufferTestBase::kInitialValue; |
322 #endif | 292 #endif |
323 | 293 |
324 class TransferBufferTest : public GLES2CommandBufferTestBase { | 294 class TransferBufferTest : public GLES2CommandBufferTestBase { |
325 protected: | 295 protected: |
326 static const unsigned int kStartingOffset = 64; | 296 static const unsigned int kStartingOffset = 64; |
327 static const unsigned int kAlignment = 4; | 297 static const unsigned int kAlignment = 4; |
328 | 298 |
329 TransferBufferTest() { } | 299 TransferBufferTest() { } |
330 | 300 |
331 virtual void SetUp() { | 301 virtual void SetUp() { |
332 SetupCommandBuffer( | 302 SetupCommandBuffer( |
333 GLES2Implementation::kStartingOffset, | 303 GLES2Implementation::kStartingOffset, |
334 GLES2Implementation::kAlignment); | 304 GLES2Implementation::kAlignment); |
335 | 305 |
336 transfer_buffer_id_ = | |
337 command_buffer_->CreateTransferBuffer(kTransferBufferSize, -1); | |
338 | |
339 transfer_buffer_.reset(new TransferBuffer( | 306 transfer_buffer_.reset(new TransferBuffer( |
340 helper_.get(), | 307 helper_.get(), |
341 transfer_buffer_id_, | 308 kTransferBufferId, |
342 GetTransferAddressFromOffset(0, 0), | 309 GetTransferAddressFromOffset(0, 0), |
343 kTransferBufferSize, | 310 kTransferBufferSize, |
344 kStartingOffset, | 311 kStartingOffset, |
345 kAlignment)); | 312 kAlignment)); |
346 } | 313 } |
347 | 314 |
348 virtual void TearDown() { | 315 virtual void TearDown() { |
349 transfer_buffer_.reset(); | 316 transfer_buffer_.reset(); |
350 } | 317 } |
351 | 318 |
352 scoped_ptr<TransferBuffer> transfer_buffer_; | 319 scoped_ptr<TransferBuffer> transfer_buffer_; |
353 }; | 320 }; |
354 | 321 |
355 // GCC requires these declarations, but MSVC requires they not be present | 322 // GCC requires these declarations, but MSVC requires they not be present |
356 #ifndef _MSC_VER | 323 #ifndef _MSC_VER |
357 const unsigned int TransferBufferTest::kStartingOffset; | 324 const unsigned int TransferBufferTest::kStartingOffset; |
358 const unsigned int TransferBufferTest::kAlignment; | 325 const unsigned int TransferBufferTest::kAlignment; |
359 #endif | 326 #endif |
360 | 327 |
361 TEST_F(TransferBufferTest, Basic) { | 328 TEST_F(TransferBufferTest, Basic) { |
362 EXPECT_TRUE(transfer_buffer_->HaveBuffer()); | 329 EXPECT_TRUE(transfer_buffer_->HaveBuffer()); |
363 EXPECT_EQ(transfer_buffer_id_, transfer_buffer_->GetShmId()); | 330 EXPECT_EQ(kTransferBufferId, transfer_buffer_->GetShmId()); |
364 } | 331 } |
365 | 332 |
366 TEST_F(TransferBufferTest, Free) { | 333 TEST_F(TransferBufferTest, Free) { |
367 EXPECT_TRUE(transfer_buffer_->HaveBuffer()); | 334 EXPECT_TRUE(transfer_buffer_->HaveBuffer()); |
368 | 335 |
369 // Free buffer. | 336 // Free buffer. |
370 EXPECT_CALL(*command_buffer_, DestroyTransferBuffer(_)) | 337 EXPECT_CALL(*command_buffer_, DestroyTransferBuffer(_)) |
371 .Times(1) | 338 .Times(1) |
372 .RetiresOnSaturation(); | 339 .RetiresOnSaturation(); |
373 transfer_buffer_->Free(); | 340 transfer_buffer_->Free(); |
374 // See it's freed. | 341 // See it's freed. |
375 EXPECT_FALSE(transfer_buffer_->HaveBuffer()); | 342 EXPECT_FALSE(transfer_buffer_->HaveBuffer()); |
376 // See that it gets reallocated. | 343 // See that it gets reallocated. |
377 EXPECT_EQ(transfer_buffer_id_, transfer_buffer_->GetShmId()); | 344 EXPECT_EQ(kTransferBufferId, transfer_buffer_->GetShmId()); |
378 EXPECT_TRUE(transfer_buffer_->HaveBuffer()); | 345 EXPECT_TRUE(transfer_buffer_->HaveBuffer()); |
379 | 346 |
380 // Free buffer. | 347 // Free buffer. |
381 EXPECT_CALL(*command_buffer_, DestroyTransferBuffer(_)) | 348 EXPECT_CALL(*command_buffer_, DestroyTransferBuffer(_)) |
382 .Times(1) | 349 .Times(1) |
383 .RetiresOnSaturation(); | 350 .RetiresOnSaturation(); |
384 transfer_buffer_->Free(); | 351 transfer_buffer_->Free(); |
385 // See it's freed. | 352 // See it's freed. |
386 EXPECT_FALSE(transfer_buffer_->HaveBuffer()); | 353 EXPECT_FALSE(transfer_buffer_->HaveBuffer()); |
387 // See that it gets reallocated. | 354 // See that it gets reallocated. |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 ids += num; | 466 ids += num; |
500 num_ids -= num; | 467 num_ids -= num; |
501 } | 468 } |
502 } | 469 } |
503 } | 470 } |
504 | 471 |
505 gl_.reset(new GLES2Implementation( | 472 gl_.reset(new GLES2Implementation( |
506 helper_.get(), | 473 helper_.get(), |
507 kTransferBufferSize, | 474 kTransferBufferSize, |
508 transfer_buffer_.ptr, | 475 transfer_buffer_.ptr, |
509 transfer_buffer_id_, | 476 kTransferBufferId, |
510 shared_resources, | 477 shared_resources, |
511 bind_generates_resource)); | 478 bind_generates_resource)); |
512 } | 479 } |
513 | 480 |
514 EXPECT_CALL(*command_buffer_, OnFlush(_)) | 481 EXPECT_CALL(*command_buffer_, OnFlush(_)) |
515 .Times(1) | 482 .Times(1) |
516 .RetiresOnSaturation(); | 483 .RetiresOnSaturation(); |
517 helper_->CommandBufferHelper::Finish(); | 484 helper_->CommandBufferHelper::Finish(); |
518 Buffer ring_buffer = helper_->get_ring_buffer(); | 485 Buffer ring_buffer = command_buffer_->GetRingBuffer(); |
519 commands_ = static_cast<CommandBufferEntry*>(ring_buffer.ptr) + | 486 commands_ = static_cast<CommandBufferEntry*>(ring_buffer.ptr) + |
520 command_buffer_->GetState().put_offset; | 487 command_buffer_->GetState().put_offset; |
521 ClearCommands(); | 488 ClearCommands(); |
522 } | 489 } |
523 | 490 |
524 Sequence sequence_; | 491 Sequence sequence_; |
525 scoped_ptr<GLES2Implementation> gl_; | 492 scoped_ptr<GLES2Implementation> gl_; |
526 }; | 493 }; |
527 | 494 |
528 class GLES2ImplementationStrictSharedTest : public GLES2ImplementationTest { | 495 class GLES2ImplementationStrictSharedTest : public GLES2ImplementationTest { |
(...skipping 22 matching lines...) Expand all Loading... |
551 cmd::SetBucketData set_bucket_data2; | 518 cmd::SetBucketData set_bucket_data2; |
552 cmd::SetToken set_token2; | 519 cmd::SetToken set_token2; |
553 cmd::SetBucketData set_bucket_data3; | 520 cmd::SetBucketData set_bucket_data3; |
554 cmd::SetToken set_token3; | 521 cmd::SetToken set_token3; |
555 ShaderSourceBucket shader_source_bucket; | 522 ShaderSourceBucket shader_source_bucket; |
556 cmd::SetBucketSize clear_bucket_size; | 523 cmd::SetBucketSize clear_bucket_size; |
557 }; | 524 }; |
558 Cmds expected; | 525 Cmds expected; |
559 expected.set_bucket_size.Init(kBucketId, kSourceSize); | 526 expected.set_bucket_size.Init(kBucketId, kSourceSize); |
560 expected.set_bucket_data1.Init( | 527 expected.set_bucket_data1.Init( |
561 kBucketId, 0, kString1Size, transfer_buffer_id_, | 528 kBucketId, 0, kString1Size, kTransferBufferId, |
562 AllocateTransferBuffer(kPaddedString1Size)); | 529 AllocateTransferBuffer(kPaddedString1Size)); |
563 expected.set_token1.Init(GetNextToken()); | 530 expected.set_token1.Init(GetNextToken()); |
564 expected.set_bucket_data2.Init( | 531 expected.set_bucket_data2.Init( |
565 kBucketId, kString1Size, kString2Size, transfer_buffer_id_, | 532 kBucketId, kString1Size, kString2Size, kTransferBufferId, |
566 AllocateTransferBuffer(kPaddedString2Size)); | 533 AllocateTransferBuffer(kPaddedString2Size)); |
567 expected.set_token2.Init(GetNextToken()); | 534 expected.set_token2.Init(GetNextToken()); |
568 expected.set_bucket_data3.Init( | 535 expected.set_bucket_data3.Init( |
569 kBucketId, kString1Size + kString2Size, | 536 kBucketId, kString1Size + kString2Size, |
570 kString3Size, transfer_buffer_id_, | 537 kString3Size, kTransferBufferId, |
571 AllocateTransferBuffer(kPaddedString3Size)); | 538 AllocateTransferBuffer(kPaddedString3Size)); |
572 expected.set_token3.Init(GetNextToken()); | 539 expected.set_token3.Init(GetNextToken()); |
573 expected.shader_source_bucket.Init(kShaderId, kBucketId); | 540 expected.shader_source_bucket.Init(kShaderId, kBucketId); |
574 expected.clear_bucket_size.Init(kBucketId, 0); | 541 expected.clear_bucket_size.Init(kBucketId, 0); |
575 const char* strings[] = { | 542 const char* strings[] = { |
576 kString1, | 543 kString1, |
577 kString2, | 544 kString2, |
578 }; | 545 }; |
579 gl_->ShaderSource(kShaderId, 2, strings, NULL); | 546 gl_->ShaderSource(kShaderId, 2, strings, NULL); |
580 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 547 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
581 } | 548 } |
582 | 549 |
583 TEST_F(GLES2ImplementationTest, GetShaderSource) { | 550 TEST_F(GLES2ImplementationTest, GetShaderSource) { |
584 const uint32 kBucketId = 1; // This id is hardcoded into GLES2Implemenation | 551 const uint32 kBucketId = 1; // This id is hardcoded into GLES2Implemenation |
585 const GLuint kShaderId = 456; | 552 const GLuint kShaderId = 456; |
586 const Str7 kString = {"foobar"}; | 553 const Str7 kString = {"foobar"}; |
587 const char kBad = 0x12; | 554 const char kBad = 0x12; |
588 struct Cmds { | 555 struct Cmds { |
589 cmd::SetBucketSize set_bucket_size1; | 556 cmd::SetBucketSize set_bucket_size1; |
590 GetShaderSource get_shader_source; | 557 GetShaderSource get_shader_source; |
591 cmd::GetBucketSize get_bucket_size; | 558 cmd::GetBucketSize get_bucket_size; |
592 cmd::GetBucketData get_bucket_data; | 559 cmd::GetBucketData get_bucket_data; |
593 cmd::SetToken set_token1; | 560 cmd::SetToken set_token1; |
594 cmd::SetBucketSize set_bucket_size2; | 561 cmd::SetBucketSize set_bucket_size2; |
595 }; | 562 }; |
596 uint32 offset = AllocateTransferBuffer(sizeof(kString)); | 563 uint32 offset = AllocateTransferBuffer(sizeof(kString)); |
597 Cmds expected; | 564 Cmds expected; |
598 expected.set_bucket_size1.Init(kBucketId, 0); | 565 expected.set_bucket_size1.Init(kBucketId, 0); |
599 expected.get_shader_source.Init(kShaderId, kBucketId); | 566 expected.get_shader_source.Init(kShaderId, kBucketId); |
600 expected.get_bucket_size.Init(kBucketId, transfer_buffer_id_, 0); | 567 expected.get_bucket_size.Init(kBucketId, kTransferBufferId, 0); |
601 expected.get_bucket_data.Init( | 568 expected.get_bucket_data.Init( |
602 kBucketId, 0, sizeof(kString), transfer_buffer_id_, offset); | 569 kBucketId, 0, sizeof(kString), kTransferBufferId, offset); |
603 expected.set_token1.Init(GetNextToken()); | 570 expected.set_token1.Init(GetNextToken()); |
604 expected.set_bucket_size2.Init(kBucketId, 0); | 571 expected.set_bucket_size2.Init(kBucketId, 0); |
605 char buf[sizeof(kString) + 1]; | 572 char buf[sizeof(kString) + 1]; |
606 memset(buf, kBad, sizeof(buf)); | 573 memset(buf, kBad, sizeof(buf)); |
607 | 574 |
608 EXPECT_CALL(*command_buffer_, OnFlush(_)) | 575 EXPECT_CALL(*command_buffer_, OnFlush(_)) |
609 .WillOnce(SetMemory(uint32(sizeof(kString)))) | 576 .WillOnce(SetMemory(uint32(sizeof(kString)))) |
610 .WillOnce(SetMemoryAtOffset(offset, kString)) | 577 .WillOnce(SetMemoryAtOffset(offset, kString)) |
611 .RetiresOnSaturation(); | 578 .RetiresOnSaturation(); |
612 | 579 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 const GLsizei kEmuOffset1 = 0; | 621 const GLsizei kEmuOffset1 = 0; |
655 const GLsizei kEmuOffset2 = kSize1; | 622 const GLsizei kEmuOffset2 = kSize1; |
656 | 623 |
657 const GLsizei kTotalSize = kSize1 + kSize2; | 624 const GLsizei kTotalSize = kSize1 + kSize2; |
658 Cmds expected; | 625 Cmds expected; |
659 expected.enable1.Init(kAttribIndex1); | 626 expected.enable1.Init(kAttribIndex1); |
660 expected.enable2.Init(kAttribIndex2); | 627 expected.enable2.Init(kAttribIndex2); |
661 expected.bind_to_emu.Init(GL_ARRAY_BUFFER, kEmuBufferId); | 628 expected.bind_to_emu.Init(GL_ARRAY_BUFFER, kEmuBufferId); |
662 expected.set_size.Init(GL_ARRAY_BUFFER, kTotalSize, 0, 0, GL_DYNAMIC_DRAW); | 629 expected.set_size.Init(GL_ARRAY_BUFFER, kTotalSize, 0, 0, GL_DYNAMIC_DRAW); |
663 expected.copy_data1.Init( | 630 expected.copy_data1.Init( |
664 GL_ARRAY_BUFFER, kEmuOffset1, kSize1, transfer_buffer_id_, | 631 GL_ARRAY_BUFFER, kEmuOffset1, kSize1, kTransferBufferId, |
665 AllocateTransferBuffer(kSize1)); | 632 AllocateTransferBuffer(kSize1)); |
666 expected.set_token1.Init(GetNextToken()); | 633 expected.set_token1.Init(GetNextToken()); |
667 expected.set_pointer1.Init(kAttribIndex1, kNumComponents1, | 634 expected.set_pointer1.Init(kAttribIndex1, kNumComponents1, |
668 GL_FLOAT, GL_FALSE, 0, kEmuOffset1); | 635 GL_FLOAT, GL_FALSE, 0, kEmuOffset1); |
669 expected.copy_data2.Init( | 636 expected.copy_data2.Init( |
670 GL_ARRAY_BUFFER, kEmuOffset2, kSize2, transfer_buffer_id_, | 637 GL_ARRAY_BUFFER, kEmuOffset2, kSize2, kTransferBufferId, |
671 AllocateTransferBuffer(kSize2)); | 638 AllocateTransferBuffer(kSize2)); |
672 expected.set_token2.Init(GetNextToken()); | 639 expected.set_token2.Init(GetNextToken()); |
673 expected.set_pointer2.Init(kAttribIndex2, kNumComponents2, | 640 expected.set_pointer2.Init(kAttribIndex2, kNumComponents2, |
674 GL_FLOAT, GL_FALSE, 0, kEmuOffset2); | 641 GL_FLOAT, GL_FALSE, 0, kEmuOffset2); |
675 expected.draw.Init(GL_POINTS, kFirst, kCount); | 642 expected.draw.Init(GL_POINTS, kFirst, kCount); |
676 expected.restore.Init(GL_ARRAY_BUFFER, 0); | 643 expected.restore.Init(GL_ARRAY_BUFFER, 0); |
677 gl_->EnableVertexAttribArray(kAttribIndex1); | 644 gl_->EnableVertexAttribArray(kAttribIndex1); |
678 gl_->EnableVertexAttribArray(kAttribIndex2); | 645 gl_->EnableVertexAttribArray(kAttribIndex2); |
679 gl_->VertexAttribPointer(kAttribIndex1, kNumComponents1, | 646 gl_->VertexAttribPointer(kAttribIndex1, kNumComponents1, |
680 GL_FLOAT, GL_FALSE, kClientStride, verts); | 647 GL_FLOAT, GL_FALSE, kClientStride, verts); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 const GLsizei kEmuOffset2 = kSize1; | 697 const GLsizei kEmuOffset2 = kSize1; |
731 | 698 |
732 const GLsizei kTotalSize = kSize1 + kSize2; | 699 const GLsizei kTotalSize = kSize1 + kSize2; |
733 Cmds expected; | 700 Cmds expected; |
734 expected.enable1.Init(kAttribIndex1); | 701 expected.enable1.Init(kAttribIndex1); |
735 expected.enable2.Init(kAttribIndex2); | 702 expected.enable2.Init(kAttribIndex2); |
736 expected.bind_to_index_emu.Init(GL_ELEMENT_ARRAY_BUFFER, kEmuIndexBufferId); | 703 expected.bind_to_index_emu.Init(GL_ELEMENT_ARRAY_BUFFER, kEmuIndexBufferId); |
737 expected.set_index_size.Init( | 704 expected.set_index_size.Init( |
738 GL_ELEMENT_ARRAY_BUFFER, kIndexSize, 0, 0, GL_DYNAMIC_DRAW); | 705 GL_ELEMENT_ARRAY_BUFFER, kIndexSize, 0, 0, GL_DYNAMIC_DRAW); |
739 expected.copy_data0.Init( | 706 expected.copy_data0.Init( |
740 GL_ELEMENT_ARRAY_BUFFER, 0, kIndexSize, transfer_buffer_id_, | 707 GL_ELEMENT_ARRAY_BUFFER, 0, kIndexSize, kTransferBufferId, |
741 AllocateTransferBuffer(kIndexSize)); | 708 AllocateTransferBuffer(kIndexSize)); |
742 expected.set_token0.Init(GetNextToken()); | 709 expected.set_token0.Init(GetNextToken()); |
743 expected.bind_to_emu.Init(GL_ARRAY_BUFFER, kEmuBufferId); | 710 expected.bind_to_emu.Init(GL_ARRAY_BUFFER, kEmuBufferId); |
744 expected.set_size.Init(GL_ARRAY_BUFFER, kTotalSize, 0, 0, GL_DYNAMIC_DRAW); | 711 expected.set_size.Init(GL_ARRAY_BUFFER, kTotalSize, 0, 0, GL_DYNAMIC_DRAW); |
745 expected.copy_data1.Init( | 712 expected.copy_data1.Init( |
746 GL_ARRAY_BUFFER, kEmuOffset1, kSize1, transfer_buffer_id_, | 713 GL_ARRAY_BUFFER, kEmuOffset1, kSize1, kTransferBufferId, |
747 AllocateTransferBuffer(kSize1)); | 714 AllocateTransferBuffer(kSize1)); |
748 expected.set_token1.Init(GetNextToken()); | 715 expected.set_token1.Init(GetNextToken()); |
749 expected.set_pointer1.Init(kAttribIndex1, kNumComponents1, | 716 expected.set_pointer1.Init(kAttribIndex1, kNumComponents1, |
750 GL_FLOAT, GL_FALSE, 0, kEmuOffset1); | 717 GL_FLOAT, GL_FALSE, 0, kEmuOffset1); |
751 expected.copy_data2.Init( | 718 expected.copy_data2.Init( |
752 GL_ARRAY_BUFFER, kEmuOffset2, kSize2, transfer_buffer_id_, | 719 GL_ARRAY_BUFFER, kEmuOffset2, kSize2, kTransferBufferId, |
753 AllocateTransferBuffer(kSize2)); | 720 AllocateTransferBuffer(kSize2)); |
754 expected.set_token2.Init(GetNextToken()); | 721 expected.set_token2.Init(GetNextToken()); |
755 expected.set_pointer2.Init(kAttribIndex2, kNumComponents2, | 722 expected.set_pointer2.Init(kAttribIndex2, kNumComponents2, |
756 GL_FLOAT, GL_FALSE, 0, kEmuOffset2); | 723 GL_FLOAT, GL_FALSE, 0, kEmuOffset2); |
757 expected.draw.Init(GL_POINTS, kCount, GL_UNSIGNED_SHORT, 0); | 724 expected.draw.Init(GL_POINTS, kCount, GL_UNSIGNED_SHORT, 0); |
758 expected.restore.Init(GL_ARRAY_BUFFER, 0); | 725 expected.restore.Init(GL_ARRAY_BUFFER, 0); |
759 expected.restore_element.Init(GL_ELEMENT_ARRAY_BUFFER, 0); | 726 expected.restore_element.Init(GL_ELEMENT_ARRAY_BUFFER, 0); |
760 gl_->EnableVertexAttribArray(kAttribIndex1); | 727 gl_->EnableVertexAttribArray(kAttribIndex1); |
761 gl_->EnableVertexAttribArray(kAttribIndex2); | 728 gl_->EnableVertexAttribArray(kAttribIndex2); |
762 gl_->VertexAttribPointer(kAttribIndex1, kNumComponents1, | 729 gl_->VertexAttribPointer(kAttribIndex1, kNumComponents1, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 arraysize(verts) * kNumComponents2 * sizeof(verts[0][0]); | 773 arraysize(verts) * kNumComponents2 * sizeof(verts[0][0]); |
807 const GLsizei kEmuOffset1 = 0; | 774 const GLsizei kEmuOffset1 = 0; |
808 const GLsizei kEmuOffset2 = kSize1; | 775 const GLsizei kEmuOffset2 = kSize1; |
809 | 776 |
810 const GLsizei kTotalSize = kSize1 + kSize2; | 777 const GLsizei kTotalSize = kSize1 + kSize2; |
811 Cmds expected; | 778 Cmds expected; |
812 expected.enable1.Init(kAttribIndex1); | 779 expected.enable1.Init(kAttribIndex1); |
813 expected.enable2.Init(kAttribIndex2); | 780 expected.enable2.Init(kAttribIndex2); |
814 expected.bind_to_index.Init(GL_ELEMENT_ARRAY_BUFFER, kClientIndexBufferId); | 781 expected.bind_to_index.Init(GL_ELEMENT_ARRAY_BUFFER, kClientIndexBufferId); |
815 expected.get_max.Init(kClientIndexBufferId, kCount, GL_UNSIGNED_SHORT, | 782 expected.get_max.Init(kClientIndexBufferId, kCount, GL_UNSIGNED_SHORT, |
816 kIndexOffset, transfer_buffer_id_, 0); | 783 kIndexOffset, kTransferBufferId, 0); |
817 expected.bind_to_emu.Init(GL_ARRAY_BUFFER, kEmuBufferId); | 784 expected.bind_to_emu.Init(GL_ARRAY_BUFFER, kEmuBufferId); |
818 expected.set_size.Init(GL_ARRAY_BUFFER, kTotalSize, 0, 0, GL_DYNAMIC_DRAW); | 785 expected.set_size.Init(GL_ARRAY_BUFFER, kTotalSize, 0, 0, GL_DYNAMIC_DRAW); |
819 expected.copy_data1.Init( | 786 expected.copy_data1.Init( |
820 GL_ARRAY_BUFFER, kEmuOffset1, kSize1, transfer_buffer_id_, | 787 GL_ARRAY_BUFFER, kEmuOffset1, kSize1, kTransferBufferId, |
821 AllocateTransferBuffer(kSize1)); | 788 AllocateTransferBuffer(kSize1)); |
822 expected.set_token1.Init(GetNextToken()); | 789 expected.set_token1.Init(GetNextToken()); |
823 expected.set_pointer1.Init(kAttribIndex1, kNumComponents1, | 790 expected.set_pointer1.Init(kAttribIndex1, kNumComponents1, |
824 GL_FLOAT, GL_FALSE, 0, kEmuOffset1); | 791 GL_FLOAT, GL_FALSE, 0, kEmuOffset1); |
825 expected.copy_data2.Init( | 792 expected.copy_data2.Init( |
826 GL_ARRAY_BUFFER, kEmuOffset2, kSize2, transfer_buffer_id_, | 793 GL_ARRAY_BUFFER, kEmuOffset2, kSize2, kTransferBufferId, |
827 AllocateTransferBuffer(kSize2)); | 794 AllocateTransferBuffer(kSize2)); |
828 expected.set_token2.Init(GetNextToken()); | 795 expected.set_token2.Init(GetNextToken()); |
829 expected.set_pointer2.Init(kAttribIndex2, kNumComponents2, | 796 expected.set_pointer2.Init(kAttribIndex2, kNumComponents2, |
830 GL_FLOAT, GL_FALSE, 0, kEmuOffset2); | 797 GL_FLOAT, GL_FALSE, 0, kEmuOffset2); |
831 expected.draw.Init(GL_POINTS, kCount, GL_UNSIGNED_SHORT, kIndexOffset); | 798 expected.draw.Init(GL_POINTS, kCount, GL_UNSIGNED_SHORT, kIndexOffset); |
832 expected.restore.Init(GL_ARRAY_BUFFER, 0); | 799 expected.restore.Init(GL_ARRAY_BUFFER, 0); |
833 | 800 |
834 EXPECT_CALL(*command_buffer_, OnFlush(_)) | 801 EXPECT_CALL(*command_buffer_, OnFlush(_)) |
835 .WillOnce(SetMemory(kMaxIndex)) | 802 .WillOnce(SetMemory(kMaxIndex)) |
836 .RetiresOnSaturation(); | 803 .RetiresOnSaturation(); |
(...skipping 26 matching lines...) Expand all Loading... |
863 struct Cmds { | 830 struct Cmds { |
864 BindBuffer bind; | 831 BindBuffer bind; |
865 VertexAttribPointer set_pointer; | 832 VertexAttribPointer set_pointer; |
866 GetVertexAttribPointerv get_pointer; | 833 GetVertexAttribPointerv get_pointer; |
867 }; | 834 }; |
868 Cmds expected; | 835 Cmds expected; |
869 expected.bind.Init(GL_ARRAY_BUFFER, kBufferId); | 836 expected.bind.Init(GL_ARRAY_BUFFER, kBufferId); |
870 expected.set_pointer.Init(kAttribIndex2, kNumComponents2, GL_FLOAT, GL_FALSE, | 837 expected.set_pointer.Init(kAttribIndex2, kNumComponents2, GL_FLOAT, GL_FALSE, |
871 kStride2, kOffset2); | 838 kStride2, kOffset2); |
872 expected.get_pointer.Init(kAttribIndex2, GL_VERTEX_ATTRIB_ARRAY_POINTER, | 839 expected.get_pointer.Init(kAttribIndex2, GL_VERTEX_ATTRIB_ARRAY_POINTER, |
873 transfer_buffer_id_, 0); | 840 kTransferBufferId, 0); |
874 | 841 |
875 // One call to flush to way for GetVertexAttribPointerv | 842 // One call to flush to way for GetVertexAttribPointerv |
876 EXPECT_CALL(*command_buffer_, OnFlush(_)) | 843 EXPECT_CALL(*command_buffer_, OnFlush(_)) |
877 .WillOnce(SetMemory(SizedResultHelper<uint32>(kOffset2))) | 844 .WillOnce(SetMemory(SizedResultHelper<uint32>(kOffset2))) |
878 .RetiresOnSaturation(); | 845 .RetiresOnSaturation(); |
879 | 846 |
880 // Set one client side buffer. | 847 // Set one client side buffer. |
881 gl_->VertexAttribPointer(kAttribIndex1, kNumComponents1, | 848 gl_->VertexAttribPointer(kAttribIndex1, kNumComponents1, |
882 GL_FLOAT, GL_FALSE, kStride1, verts); | 849 GL_FLOAT, GL_FALSE, kStride1, verts); |
883 // Set one VBO | 850 // Set one VBO |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
920 GetVertexAttribiv get1; // for getting the buffer from attrib2 | 887 GetVertexAttribiv get1; // for getting the buffer from attrib2 |
921 GetVertexAttribfv get2; // for getting the value from attrib1 | 888 GetVertexAttribfv get2; // for getting the value from attrib1 |
922 }; | 889 }; |
923 Cmds expected; | 890 Cmds expected; |
924 expected.enable.Init(kAttribIndex1); | 891 expected.enable.Init(kAttribIndex1); |
925 expected.bind.Init(GL_ARRAY_BUFFER, kBufferId); | 892 expected.bind.Init(GL_ARRAY_BUFFER, kBufferId); |
926 expected.set_pointer.Init(kAttribIndex2, kNumComponents2, GL_FLOAT, GL_FALSE, | 893 expected.set_pointer.Init(kAttribIndex2, kNumComponents2, GL_FLOAT, GL_FALSE, |
927 kStride2, kOffset2); | 894 kStride2, kOffset2); |
928 expected.get1.Init(kAttribIndex2, | 895 expected.get1.Init(kAttribIndex2, |
929 GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, | 896 GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, |
930 transfer_buffer_id_, 0); | 897 kTransferBufferId, 0); |
931 expected.get2.Init(kAttribIndex1, | 898 expected.get2.Init(kAttribIndex1, |
932 GL_CURRENT_VERTEX_ATTRIB, | 899 GL_CURRENT_VERTEX_ATTRIB, |
933 transfer_buffer_id_, 0); | 900 kTransferBufferId, 0); |
934 | 901 |
935 FourFloats current_attrib(1.2f, 3.4f, 5.6f, 7.8f); | 902 FourFloats current_attrib(1.2f, 3.4f, 5.6f, 7.8f); |
936 | 903 |
937 // One call to flush to way for GetVertexAttribiv | 904 // One call to flush to way for GetVertexAttribiv |
938 EXPECT_CALL(*command_buffer_, OnFlush(_)) | 905 EXPECT_CALL(*command_buffer_, OnFlush(_)) |
939 .WillOnce(SetMemory(SizedResultHelper<GLuint>(kBufferId))) | 906 .WillOnce(SetMemory(SizedResultHelper<GLuint>(kBufferId))) |
940 .WillOnce(SetMemory(SizedResultHelper<FourFloats>(current_attrib))) | 907 .WillOnce(SetMemory(SizedResultHelper<FourFloats>(current_attrib))) |
941 .RetiresOnSaturation(); | 908 .RetiresOnSaturation(); |
942 | 909 |
943 gl_->EnableVertexAttribArray(kAttribIndex1); | 910 gl_->EnableVertexAttribArray(kAttribIndex1); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
986 | 953 |
987 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 954 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
988 } | 955 } |
989 | 956 |
990 TEST_F(GLES2ImplementationTest, ReservedIds) { | 957 TEST_F(GLES2ImplementationTest, ReservedIds) { |
991 // Only the get error command should be issued. | 958 // Only the get error command should be issued. |
992 struct Cmds { | 959 struct Cmds { |
993 GetError get; | 960 GetError get; |
994 }; | 961 }; |
995 Cmds expected; | 962 Cmds expected; |
996 expected.get.Init(transfer_buffer_id_, 0); | 963 expected.get.Init(kTransferBufferId, 0); |
997 | 964 |
998 // One call to flush to wait for GetError | 965 // One call to flush to wait for GetError |
999 EXPECT_CALL(*command_buffer_, OnFlush(_)) | 966 EXPECT_CALL(*command_buffer_, OnFlush(_)) |
1000 .WillOnce(SetMemory(GLuint(GL_NO_ERROR))) | 967 .WillOnce(SetMemory(GLuint(GL_NO_ERROR))) |
1001 .RetiresOnSaturation(); | 968 .RetiresOnSaturation(); |
1002 | 969 |
1003 gl_->BindBuffer( | 970 gl_->BindBuffer( |
1004 GL_ARRAY_BUFFER, | 971 GL_ARRAY_BUFFER, |
1005 GLES2Implementation::kClientSideArrayId); | 972 GLES2Implementation::kClientSideArrayId); |
1006 gl_->BindBuffer( | 973 gl_->BindBuffer( |
(...skipping 17 matching lines...) Expand all Loading... |
1024 const GLint kWidth = | 991 const GLint kWidth = |
1025 (kTransferBufferSize - GLES2Implementation::kStartingOffset) / | 992 (kTransferBufferSize - GLES2Implementation::kStartingOffset) / |
1026 kBytesPerPixel; | 993 kBytesPerPixel; |
1027 const GLint kHeight = 2; | 994 const GLint kHeight = 2; |
1028 const GLenum kFormat = GL_RGBA; | 995 const GLenum kFormat = GL_RGBA; |
1029 const GLenum kType = GL_UNSIGNED_BYTE; | 996 const GLenum kType = GL_UNSIGNED_BYTE; |
1030 | 997 |
1031 Cmds expected; | 998 Cmds expected; |
1032 expected.read1.Init( | 999 expected.read1.Init( |
1033 0, 0, kWidth, kHeight / 2, kFormat, kType, | 1000 0, 0, kWidth, kHeight / 2, kFormat, kType, |
1034 transfer_buffer_id_, | 1001 kTransferBufferId, |
1035 AllocateTransferBuffer(kWidth * kHeight / 2 * kBytesPerPixel), | 1002 AllocateTransferBuffer(kWidth * kHeight / 2 * kBytesPerPixel), |
1036 transfer_buffer_id_, 0); | 1003 kTransferBufferId, 0); |
1037 expected.set_token1.Init(GetNextToken()); | 1004 expected.set_token1.Init(GetNextToken()); |
1038 expected.read2.Init( | 1005 expected.read2.Init( |
1039 0, kHeight / 2, kWidth, kHeight / 2, kFormat, kType, | 1006 0, kHeight / 2, kWidth, kHeight / 2, kFormat, kType, |
1040 transfer_buffer_id_, | 1007 kTransferBufferId, |
1041 AllocateTransferBuffer(kWidth * kHeight / 2 * kBytesPerPixel), | 1008 AllocateTransferBuffer(kWidth * kHeight / 2 * kBytesPerPixel), |
1042 transfer_buffer_id_, 0); | 1009 kTransferBufferId, 0); |
1043 expected.set_token2.Init(GetNextToken()); | 1010 expected.set_token2.Init(GetNextToken()); |
1044 scoped_array<int8> buffer(new int8[kWidth * kHeight * kBytesPerPixel]); | 1011 scoped_array<int8> buffer(new int8[kWidth * kHeight * kBytesPerPixel]); |
1045 | 1012 |
1046 EXPECT_CALL(*command_buffer_, OnFlush(_)) | 1013 EXPECT_CALL(*command_buffer_, OnFlush(_)) |
1047 .WillOnce(SetMemory(static_cast<uint32>(1))) | 1014 .WillOnce(SetMemory(static_cast<uint32>(1))) |
1048 .WillOnce(SetMemory(static_cast<uint32>(1))) | 1015 .WillOnce(SetMemory(static_cast<uint32>(1))) |
1049 .RetiresOnSaturation(); | 1016 .RetiresOnSaturation(); |
1050 | 1017 |
1051 gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, buffer.get()); | 1018 gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, buffer.get()); |
1052 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 1019 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
1053 } | 1020 } |
1054 | 1021 |
1055 TEST_F(GLES2ImplementationTest, ReadPixelsBadFormatType) { | 1022 TEST_F(GLES2ImplementationTest, ReadPixelsBadFormatType) { |
1056 struct Cmds { | 1023 struct Cmds { |
1057 ReadPixels read; | 1024 ReadPixels read; |
1058 cmd::SetToken set_token; | 1025 cmd::SetToken set_token; |
1059 }; | 1026 }; |
1060 const GLint kBytesPerPixel = 4; | 1027 const GLint kBytesPerPixel = 4; |
1061 const GLint kWidth = 2; | 1028 const GLint kWidth = 2; |
1062 const GLint kHeight = 2; | 1029 const GLint kHeight = 2; |
1063 const GLenum kFormat = 0; | 1030 const GLenum kFormat = 0; |
1064 const GLenum kType = 0; | 1031 const GLenum kType = 0; |
1065 | 1032 |
1066 Cmds expected; | 1033 Cmds expected; |
1067 expected.read.Init( | 1034 expected.read.Init( |
1068 0, 0, kWidth, kHeight / 2, kFormat, kType, | 1035 0, 0, kWidth, kHeight / 2, kFormat, kType, |
1069 transfer_buffer_id_, | 1036 kTransferBufferId, |
1070 AllocateTransferBuffer(kWidth * kHeight * kBytesPerPixel), | 1037 AllocateTransferBuffer(kWidth * kHeight * kBytesPerPixel), |
1071 transfer_buffer_id_, 0); | 1038 kTransferBufferId, 0); |
1072 expected.set_token.Init(GetNextToken()); | 1039 expected.set_token.Init(GetNextToken()); |
1073 scoped_array<int8> buffer(new int8[kWidth * kHeight * kBytesPerPixel]); | 1040 scoped_array<int8> buffer(new int8[kWidth * kHeight * kBytesPerPixel]); |
1074 | 1041 |
1075 EXPECT_CALL(*command_buffer_, OnFlush(_)) | 1042 EXPECT_CALL(*command_buffer_, OnFlush(_)) |
1076 .Times(1) | 1043 .Times(1) |
1077 .RetiresOnSaturation(); | 1044 .RetiresOnSaturation(); |
1078 | 1045 |
1079 gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, buffer.get()); | 1046 gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, buffer.get()); |
1080 } | 1047 } |
1081 | 1048 |
1082 TEST_F(GLES2ImplementationTest, FreeUnusedSharedMemory) { | 1049 TEST_F(GLES2ImplementationTest, FreeUnusedSharedMemory) { |
1083 struct Cmds { | 1050 struct Cmds { |
1084 BufferSubData buf; | 1051 BufferSubData buf; |
1085 cmd::SetToken set_token; | 1052 cmd::SetToken set_token; |
1086 }; | 1053 }; |
1087 const GLenum kTarget = GL_ELEMENT_ARRAY_BUFFER; | 1054 const GLenum kTarget = GL_ELEMENT_ARRAY_BUFFER; |
1088 const GLintptr kOffset = 15; | 1055 const GLintptr kOffset = 15; |
1089 const GLsizeiptr kSize = 16; | 1056 const GLsizeiptr kSize = 16; |
1090 | 1057 |
1091 uint32 offset = 0; | 1058 uint32 offset = 0; |
1092 Cmds expected; | 1059 Cmds expected; |
1093 expected.buf.Init( | 1060 expected.buf.Init( |
1094 kTarget, kOffset, kSize, transfer_buffer_id_, offset); | 1061 kTarget, kOffset, kSize, kTransferBufferId, offset); |
1095 expected.set_token.Init(GetNextToken()); | 1062 expected.set_token.Init(GetNextToken()); |
1096 | 1063 |
1097 void* mem = gl_->MapBufferSubDataCHROMIUM( | 1064 void* mem = gl_->MapBufferSubDataCHROMIUM( |
1098 kTarget, kOffset, kSize, GL_WRITE_ONLY); | 1065 kTarget, kOffset, kSize, GL_WRITE_ONLY); |
1099 ASSERT_TRUE(mem != NULL); | 1066 ASSERT_TRUE(mem != NULL); |
1100 gl_->UnmapBufferSubDataCHROMIUM(mem); | 1067 gl_->UnmapBufferSubDataCHROMIUM(mem); |
1101 EXPECT_CALL(*command_buffer_, DestroyTransferBuffer(_)) | 1068 EXPECT_CALL(*command_buffer_, DestroyTransferBuffer(_)) |
1102 .Times(1) | 1069 .Times(1) |
1103 .RetiresOnSaturation(); | 1070 .RetiresOnSaturation(); |
1104 gl_->FreeUnusedSharedMemory(); | 1071 gl_->FreeUnusedSharedMemory(); |
1105 } | 1072 } |
1106 | 1073 |
1107 TEST_F(GLES2ImplementationTest, MapUnmapBufferSubDataCHROMIUM) { | 1074 TEST_F(GLES2ImplementationTest, MapUnmapBufferSubDataCHROMIUM) { |
1108 struct Cmds { | 1075 struct Cmds { |
1109 BufferSubData buf; | 1076 BufferSubData buf; |
1110 cmd::SetToken set_token; | 1077 cmd::SetToken set_token; |
1111 }; | 1078 }; |
1112 const GLenum kTarget = GL_ELEMENT_ARRAY_BUFFER; | 1079 const GLenum kTarget = GL_ELEMENT_ARRAY_BUFFER; |
1113 const GLintptr kOffset = 15; | 1080 const GLintptr kOffset = 15; |
1114 const GLsizeiptr kSize = 16; | 1081 const GLsizeiptr kSize = 16; |
1115 | 1082 |
1116 uint32 offset = 0; | 1083 uint32 offset = 0; |
1117 Cmds expected; | 1084 Cmds expected; |
1118 expected.buf.Init( | 1085 expected.buf.Init( |
1119 kTarget, kOffset, kSize, GetNextFreeTransferBufferId(), offset); | 1086 kTarget, kOffset, kSize, kTransferBufferId, offset); |
1120 expected.set_token.Init(GetNextToken()); | 1087 expected.set_token.Init(GetNextToken()); |
1121 | 1088 |
1122 void* mem = gl_->MapBufferSubDataCHROMIUM( | 1089 void* mem = gl_->MapBufferSubDataCHROMIUM( |
1123 kTarget, kOffset, kSize, GL_WRITE_ONLY); | 1090 kTarget, kOffset, kSize, GL_WRITE_ONLY); |
1124 ASSERT_TRUE(mem != NULL); | 1091 ASSERT_TRUE(mem != NULL); |
1125 gl_->UnmapBufferSubDataCHROMIUM(mem); | 1092 gl_->UnmapBufferSubDataCHROMIUM(mem); |
1126 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 1093 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
1127 } | 1094 } |
1128 | 1095 |
1129 TEST_F(GLES2ImplementationTest, MapUnmapBufferSubDataCHROMIUMBadArgs) { | 1096 TEST_F(GLES2ImplementationTest, MapUnmapBufferSubDataCHROMIUMBadArgs) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1164 const GLint kYOffset = 3; | 1131 const GLint kYOffset = 3; |
1165 const GLint kWidth = 4; | 1132 const GLint kWidth = 4; |
1166 const GLint kHeight = 5; | 1133 const GLint kHeight = 5; |
1167 const GLenum kFormat = GL_RGBA; | 1134 const GLenum kFormat = GL_RGBA; |
1168 const GLenum kType = GL_UNSIGNED_BYTE; | 1135 const GLenum kType = GL_UNSIGNED_BYTE; |
1169 | 1136 |
1170 uint32 offset = 0; | 1137 uint32 offset = 0; |
1171 Cmds expected; | 1138 Cmds expected; |
1172 expected.tex.Init( | 1139 expected.tex.Init( |
1173 GL_TEXTURE_2D, kLevel, kXOffset, kYOffset, kWidth, kHeight, kFormat, | 1140 GL_TEXTURE_2D, kLevel, kXOffset, kYOffset, kWidth, kHeight, kFormat, |
1174 kType, GetNextFreeTransferBufferId(), offset, GL_FALSE); | 1141 kType, kTransferBufferId, offset, GL_FALSE); |
1175 expected.set_token.Init(GetNextToken()); | 1142 expected.set_token.Init(GetNextToken()); |
1176 | 1143 |
1177 void* mem = gl_->MapTexSubImage2DCHROMIUM( | 1144 void* mem = gl_->MapTexSubImage2DCHROMIUM( |
1178 GL_TEXTURE_2D, | 1145 GL_TEXTURE_2D, |
1179 kLevel, | 1146 kLevel, |
1180 kXOffset, | 1147 kXOffset, |
1181 kYOffset, | 1148 kYOffset, |
1182 kWidth, | 1149 kWidth, |
1183 kHeight, | 1150 kHeight, |
1184 kFormat, | 1151 kFormat, |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1299 GetMultipleIntegervCHROMIUM get_multiple; | 1266 GetMultipleIntegervCHROMIUM get_multiple; |
1300 cmd::SetToken set_token; | 1267 cmd::SetToken set_token; |
1301 }; | 1268 }; |
1302 const GLsizei kNumPnames = arraysize(pnames); | 1269 const GLsizei kNumPnames = arraysize(pnames); |
1303 const GLsizeiptr kResultsSize = num_results * sizeof(results[0]); | 1270 const GLsizeiptr kResultsSize = num_results * sizeof(results[0]); |
1304 const uint32 kPnamesOffset = | 1271 const uint32 kPnamesOffset = |
1305 AllocateTransferBuffer(kNumPnames * sizeof(pnames[0])); | 1272 AllocateTransferBuffer(kNumPnames * sizeof(pnames[0])); |
1306 const uint32 kResultsOffset = AllocateTransferBuffer(kResultsSize); | 1273 const uint32 kResultsOffset = AllocateTransferBuffer(kResultsSize); |
1307 Cmds expected; | 1274 Cmds expected; |
1308 expected.get_multiple.Init( | 1275 expected.get_multiple.Init( |
1309 transfer_buffer_id_, kPnamesOffset, kNumPnames, | 1276 kTransferBufferId, kPnamesOffset, kNumPnames, |
1310 transfer_buffer_id_, kResultsOffset, kResultsSize); | 1277 kTransferBufferId, kResultsOffset, kResultsSize); |
1311 expected.set_token.Init(GetNextToken()); | 1278 expected.set_token.Init(GetNextToken()); |
1312 | 1279 |
1313 const GLint kSentinel = 0x12345678; | 1280 const GLint kSentinel = 0x12345678; |
1314 memset(results, 0, sizeof(results)); | 1281 memset(results, 0, sizeof(results)); |
1315 results[num_results] = kSentinel; | 1282 results[num_results] = kSentinel; |
1316 const GLint returned_results[] = { | 1283 const GLint returned_results[] = { |
1317 1, 0, 1, 0, 1, -1, | 1284 1, 0, 1, 0, 1, -1, |
1318 }; | 1285 }; |
1319 // One call to flush to wait for results | 1286 // One call to flush to wait for results |
1320 EXPECT_CALL(*command_buffer_, OnFlush(_)) | 1287 EXPECT_CALL(*command_buffer_, OnFlush(_)) |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1409 cmd::SetBucketSize set_bucket_size1; | 1376 cmd::SetBucketSize set_bucket_size1; |
1410 GetProgramInfoCHROMIUM get_program_info; | 1377 GetProgramInfoCHROMIUM get_program_info; |
1411 cmd::GetBucketSize get_bucket_size; | 1378 cmd::GetBucketSize get_bucket_size; |
1412 cmd::GetBucketData get_bucket_data; | 1379 cmd::GetBucketData get_bucket_data; |
1413 cmd::SetToken set_token1; | 1380 cmd::SetToken set_token1; |
1414 cmd::SetBucketSize set_bucket_size2; | 1381 cmd::SetBucketSize set_bucket_size2; |
1415 }; | 1382 }; |
1416 Cmds expected; | 1383 Cmds expected; |
1417 expected.set_bucket_size1.Init(kBucketId, 0); | 1384 expected.set_bucket_size1.Init(kBucketId, 0); |
1418 expected.get_program_info.Init(kProgramId, kBucketId); | 1385 expected.get_program_info.Init(kProgramId, kBucketId); |
1419 expected.get_bucket_size.Init(kBucketId, transfer_buffer_id_, 0); | 1386 expected.get_bucket_size.Init(kBucketId, kTransferBufferId, 0); |
1420 expected.get_bucket_data.Init( | 1387 expected.get_bucket_data.Init( |
1421 kBucketId, 0, sizeof(kString), transfer_buffer_id_, offset); | 1388 kBucketId, 0, sizeof(kString), kTransferBufferId, offset); |
1422 expected.set_token1.Init(GetNextToken()); | 1389 expected.set_token1.Init(GetNextToken()); |
1423 expected.set_bucket_size2.Init(kBucketId, 0); | 1390 expected.set_bucket_size2.Init(kBucketId, 0); |
1424 gl_->GetProgramInfoCHROMIUM(kProgramId, sizeof(buf), &size, &buf); | 1391 gl_->GetProgramInfoCHROMIUM(kProgramId, sizeof(buf), &size, &buf); |
1425 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 1392 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
1426 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); | 1393 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); |
1427 EXPECT_EQ(sizeof(kString), static_cast<size_t>(size)); | 1394 EXPECT_EQ(sizeof(kString), static_cast<size_t>(size)); |
1428 EXPECT_STREQ(kString.str, buf); | 1395 EXPECT_STREQ(kString.str, buf); |
1429 EXPECT_EQ(buf[sizeof(kString)], kBad); | 1396 EXPECT_EQ(buf[sizeof(kString)], kBad); |
1430 } | 1397 } |
1431 | 1398 |
(...skipping 18 matching lines...) Expand all Loading... |
1450 cmd::SetBucketSize set_bucket_size1; | 1417 cmd::SetBucketSize set_bucket_size1; |
1451 GetProgramInfoCHROMIUM get_program_info; | 1418 GetProgramInfoCHROMIUM get_program_info; |
1452 cmd::GetBucketSize get_bucket_size; | 1419 cmd::GetBucketSize get_bucket_size; |
1453 cmd::GetBucketData get_bucket_data; | 1420 cmd::GetBucketData get_bucket_data; |
1454 cmd::SetToken set_token1; | 1421 cmd::SetToken set_token1; |
1455 cmd::SetBucketSize set_bucket_size2; | 1422 cmd::SetBucketSize set_bucket_size2; |
1456 }; | 1423 }; |
1457 Cmds expected; | 1424 Cmds expected; |
1458 expected.set_bucket_size1.Init(kBucketId, 0); | 1425 expected.set_bucket_size1.Init(kBucketId, 0); |
1459 expected.get_program_info.Init(kProgramId, kBucketId); | 1426 expected.get_program_info.Init(kProgramId, kBucketId); |
1460 expected.get_bucket_size.Init(kBucketId, transfer_buffer_id_, 0); | 1427 expected.get_bucket_size.Init(kBucketId, kTransferBufferId, 0); |
1461 expected.get_bucket_data.Init( | 1428 expected.get_bucket_data.Init( |
1462 kBucketId, 0, sizeof(kString), transfer_buffer_id_, offset); | 1429 kBucketId, 0, sizeof(kString), kTransferBufferId, offset); |
1463 expected.set_token1.Init(GetNextToken()); | 1430 expected.set_token1.Init(GetNextToken()); |
1464 expected.set_bucket_size2.Init(kBucketId, 0); | 1431 expected.set_bucket_size2.Init(kBucketId, 0); |
1465 gl_->GetProgramInfoCHROMIUM(kProgramId, 6, &size, &buf); | 1432 gl_->GetProgramInfoCHROMIUM(kProgramId, 6, &size, &buf); |
1466 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 1433 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
1467 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), gl_->GetError()); | 1434 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), gl_->GetError()); |
1468 ClearCommands(); | 1435 ClearCommands(); |
1469 | 1436 |
1470 // try bad bufsize | 1437 // try bad bufsize |
1471 gl_->GetProgramInfoCHROMIUM(kProgramId, -1, &size, &buf); | 1438 gl_->GetProgramInfoCHROMIUM(kProgramId, -1, &size, &buf); |
1472 EXPECT_TRUE(NoCommandsWritten()); | 1439 EXPECT_TRUE(NoCommandsWritten()); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1628 static uint8 pixels[] = { | 1595 static uint8 pixels[] = { |
1629 11, 12, 13, 13, 14, 15, 15, 16, 17, 101, 102, 103, | 1596 11, 12, 13, 13, 14, 15, 15, 16, 17, 101, 102, 103, |
1630 21, 22, 23, 23, 24, 25, 25, 26, 27, 201, 202, 203, | 1597 21, 22, 23, 23, 24, 25, 25, 26, 27, 201, 202, 203, |
1631 31, 32, 33, 33, 34, 35, 35, 36, 37, 123, 124, 125, | 1598 31, 32, 33, 33, 34, 35, 35, 36, 37, 123, 124, 125, |
1632 41, 42, 43, 43, 44, 45, 45, 46, 47, | 1599 41, 42, 43, 43, 44, 45, 45, 46, 47, |
1633 }; | 1600 }; |
1634 uint32 offset = AllocateTransferBuffer(sizeof(pixels)); | 1601 uint32 offset = AllocateTransferBuffer(sizeof(pixels)); |
1635 Cmds expected; | 1602 Cmds expected; |
1636 expected.tex_image_2d.Init( | 1603 expected.tex_image_2d.Init( |
1637 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, | 1604 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, |
1638 transfer_buffer_id_, offset); | 1605 kTransferBufferId, offset); |
1639 expected.set_token.Init(GetNextToken()); | 1606 expected.set_token.Init(GetNextToken()); |
1640 gl_->TexImage2D( | 1607 gl_->TexImage2D( |
1641 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, | 1608 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, |
1642 pixels); | 1609 pixels); |
1643 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 1610 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
1644 EXPECT_TRUE(CheckRect( | 1611 EXPECT_TRUE(CheckRect( |
1645 kWidth, kHeight, kFormat, kType, kPixelStoreUnpackAlignment, false, | 1612 kWidth, kHeight, kFormat, kType, kPixelStoreUnpackAlignment, false, |
1646 pixels, GetTransferAddressFromOffsetAs<uint8>(offset, sizeof(pixels)))); | 1613 pixels, GetTransferAddressFromOffsetAs<uint8>(offset, sizeof(pixels)))); |
1647 | 1614 |
1648 ClearCommands(); | 1615 ClearCommands(); |
1649 uint32 offset2 = AllocateTransferBuffer(sizeof(pixels)); | 1616 uint32 offset2 = AllocateTransferBuffer(sizeof(pixels)); |
1650 Cmds2 expected2; | 1617 Cmds2 expected2; |
1651 expected2.tex_image_2d.Init( | 1618 expected2.tex_image_2d.Init( |
1652 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, | 1619 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, |
1653 transfer_buffer_id_, offset2); | 1620 kTransferBufferId, offset2); |
1654 expected2.set_token.Init(GetNextToken()); | 1621 expected2.set_token.Init(GetNextToken()); |
1655 const void* commands2 = GetPut(); | 1622 const void* commands2 = GetPut(); |
1656 gl_->PixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE); | 1623 gl_->PixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE); |
1657 gl_->TexImage2D( | 1624 gl_->TexImage2D( |
1658 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, | 1625 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, |
1659 pixels); | 1626 pixels); |
1660 EXPECT_EQ(0, memcmp(&expected2, commands2, sizeof(expected2))); | 1627 EXPECT_EQ(0, memcmp(&expected2, commands2, sizeof(expected2))); |
1661 EXPECT_TRUE(CheckRect( | 1628 EXPECT_TRUE(CheckRect( |
1662 kWidth, kHeight, kFormat, kType, kPixelStoreUnpackAlignment, true, | 1629 kWidth, kHeight, kFormat, kType, kPixelStoreUnpackAlignment, true, |
1663 pixels, GetTransferAddressFromOffsetAs<uint8>(offset2, sizeof(pixels)))); | 1630 pixels, GetTransferAddressFromOffsetAs<uint8>(offset2, sizeof(pixels)))); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1700 pixels[ii] = static_cast<uint8>(ii); | 1667 pixels[ii] = static_cast<uint8>(ii); |
1701 } | 1668 } |
1702 uint32 offset1 = AllocateTransferBuffer(half_size); | 1669 uint32 offset1 = AllocateTransferBuffer(half_size); |
1703 uint32 offset2 = AllocateTransferBuffer(half_size); | 1670 uint32 offset2 = AllocateTransferBuffer(half_size); |
1704 Cmds expected; | 1671 Cmds expected; |
1705 expected.tex_image_2d.Init( | 1672 expected.tex_image_2d.Init( |
1706 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, | 1673 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, |
1707 0, 0); | 1674 0, 0); |
1708 expected.tex_sub_image_2d1.Init( | 1675 expected.tex_sub_image_2d1.Init( |
1709 kTarget, kLevel, 0, 0, kWidth, kHeight / 2, kFormat, kType, | 1676 kTarget, kLevel, 0, 0, kWidth, kHeight / 2, kFormat, kType, |
1710 transfer_buffer_id_, offset1, true); | 1677 kTransferBufferId, offset1, true); |
1711 expected.set_token1.Init(GetNextToken()); | 1678 expected.set_token1.Init(GetNextToken()); |
1712 expected.tex_sub_image_2d2.Init( | 1679 expected.tex_sub_image_2d2.Init( |
1713 kTarget, kLevel, 0, kHeight / 2, kWidth, kHeight / 2, kFormat, kType, | 1680 kTarget, kLevel, 0, kHeight / 2, kWidth, kHeight / 2, kFormat, kType, |
1714 transfer_buffer_id_, offset2, true); | 1681 kTransferBufferId, offset2, true); |
1715 expected.set_token2.Init(GetNextToken()); | 1682 expected.set_token2.Init(GetNextToken()); |
1716 | 1683 |
1717 // TODO(gman): Make it possible to run this test | 1684 // TODO(gman): Make it possible to run this test |
1718 // EXPECT_CALL(*command_buffer_, OnFlush(_)) | 1685 // EXPECT_CALL(*command_buffer_, OnFlush(_)) |
1719 // .WillOnce(CheckRectAction( | 1686 // .WillOnce(CheckRectAction( |
1720 // kWidth, kHeight / 2, kFormat, kType, kPixelStoreUnpackAlignment, | 1687 // kWidth, kHeight / 2, kFormat, kType, kPixelStoreUnpackAlignment, |
1721 // false, pixels.get(), | 1688 // false, pixels.get(), |
1722 // GetTransferAddressFromOffsetAs<uint8>(offset1, half_size))) | 1689 // GetTransferAddressFromOffsetAs<uint8>(offset1, half_size))) |
1723 // .RetiresOnSaturation(); | 1690 // .RetiresOnSaturation(); |
1724 | 1691 |
1725 gl_->TexImage2D( | 1692 gl_->TexImage2D( |
1726 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, | 1693 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, |
1727 pixels.get()); | 1694 pixels.get()); |
1728 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 1695 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
1729 EXPECT_TRUE(CheckRect( | 1696 EXPECT_TRUE(CheckRect( |
1730 kWidth, kHeight / 2, kFormat, kType, kPixelStoreUnpackAlignment, false, | 1697 kWidth, kHeight / 2, kFormat, kType, kPixelStoreUnpackAlignment, false, |
1731 pixels.get() + kHeight / 2 * padded_row_size, | 1698 pixels.get() + kHeight / 2 * padded_row_size, |
1732 GetTransferAddressFromOffsetAs<uint8>(offset2, half_size))); | 1699 GetTransferAddressFromOffsetAs<uint8>(offset2, half_size))); |
1733 | 1700 |
1734 ClearCommands(); | 1701 ClearCommands(); |
1735 const void* commands2 = GetPut(); | 1702 const void* commands2 = GetPut(); |
1736 uint32 offset3 = AllocateTransferBuffer(half_size); | 1703 uint32 offset3 = AllocateTransferBuffer(half_size); |
1737 uint32 offset4 = AllocateTransferBuffer(half_size); | 1704 uint32 offset4 = AllocateTransferBuffer(half_size); |
1738 expected.tex_image_2d.Init( | 1705 expected.tex_image_2d.Init( |
1739 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, | 1706 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, |
1740 0, 0); | 1707 0, 0); |
1741 expected.tex_sub_image_2d1.Init( | 1708 expected.tex_sub_image_2d1.Init( |
1742 kTarget, kLevel, 0, kHeight / 2, kWidth, kHeight / 2, kFormat, kType, | 1709 kTarget, kLevel, 0, kHeight / 2, kWidth, kHeight / 2, kFormat, kType, |
1743 transfer_buffer_id_, offset3, true); | 1710 kTransferBufferId, offset3, true); |
1744 expected.set_token1.Init(GetNextToken()); | 1711 expected.set_token1.Init(GetNextToken()); |
1745 expected.tex_sub_image_2d2.Init( | 1712 expected.tex_sub_image_2d2.Init( |
1746 kTarget, kLevel, 0, 0, kWidth, kHeight / 2, kFormat, kType, | 1713 kTarget, kLevel, 0, 0, kWidth, kHeight / 2, kFormat, kType, |
1747 transfer_buffer_id_, offset4, true); | 1714 kTransferBufferId, offset4, true); |
1748 expected.set_token2.Init(GetNextToken()); | 1715 expected.set_token2.Init(GetNextToken()); |
1749 | 1716 |
1750 // TODO(gman): Make it possible to run this test | 1717 // TODO(gman): Make it possible to run this test |
1751 // EXPECT_CALL(*command_buffer_, OnFlush(_)) | 1718 // EXPECT_CALL(*command_buffer_, OnFlush(_)) |
1752 // .WillOnce(CheckRectAction( | 1719 // .WillOnce(CheckRectAction( |
1753 // kWidth, kHeight / 2, kFormat, kType, kPixelStoreUnpackAlignment, | 1720 // kWidth, kHeight / 2, kFormat, kType, kPixelStoreUnpackAlignment, |
1754 // true, pixels.get(), | 1721 // true, pixels.get(), |
1755 // GetTransferAddressFromOffsetAs<uint8>(offset3, half_size))) | 1722 // GetTransferAddressFromOffsetAs<uint8>(offset3, half_size))) |
1756 // .RetiresOnSaturation(); | 1723 // .RetiresOnSaturation(); |
1757 | 1724 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1803 uint32 offset1 = AllocateTransferBuffer(part_size); | 1770 uint32 offset1 = AllocateTransferBuffer(part_size); |
1804 uint32 offset2 = AllocateTransferBuffer(part_size); | 1771 uint32 offset2 = AllocateTransferBuffer(part_size); |
1805 uint32 offset3 = AllocateTransferBuffer(part_size); | 1772 uint32 offset3 = AllocateTransferBuffer(part_size); |
1806 uint32 offset4 = AllocateTransferBuffer(part_size); | 1773 uint32 offset4 = AllocateTransferBuffer(part_size); |
1807 Cmds expected; | 1774 Cmds expected; |
1808 expected.tex_image_2d.Init( | 1775 expected.tex_image_2d.Init( |
1809 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, | 1776 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, |
1810 0, 0); | 1777 0, 0); |
1811 expected.tex_sub_image_2d1.Init( | 1778 expected.tex_sub_image_2d1.Init( |
1812 kTarget, kLevel, 0, 0, kWidth / 2, 1, kFormat, kType, | 1779 kTarget, kLevel, 0, 0, kWidth / 2, 1, kFormat, kType, |
1813 transfer_buffer_id_, offset1, true); | 1780 kTransferBufferId, offset1, true); |
1814 expected.set_token1.Init(GetNextToken()); | 1781 expected.set_token1.Init(GetNextToken()); |
1815 expected.tex_sub_image_2d2.Init( | 1782 expected.tex_sub_image_2d2.Init( |
1816 kTarget, kLevel, kWidth / 2, 0, kWidth / 2, 1, kFormat, kType, | 1783 kTarget, kLevel, kWidth / 2, 0, kWidth / 2, 1, kFormat, kType, |
1817 transfer_buffer_id_, offset2, true); | 1784 kTransferBufferId, offset2, true); |
1818 expected.set_token2.Init(GetNextToken()); | 1785 expected.set_token2.Init(GetNextToken()); |
1819 expected.tex_sub_image_2d3.Init( | 1786 expected.tex_sub_image_2d3.Init( |
1820 kTarget, kLevel, 0, 1, kWidth / 2, 1, kFormat, kType, | 1787 kTarget, kLevel, 0, 1, kWidth / 2, 1, kFormat, kType, |
1821 transfer_buffer_id_, offset3, true); | 1788 kTransferBufferId, offset3, true); |
1822 expected.set_token3.Init(GetNextToken()); | 1789 expected.set_token3.Init(GetNextToken()); |
1823 expected.tex_sub_image_2d4.Init( | 1790 expected.tex_sub_image_2d4.Init( |
1824 kTarget, kLevel, kWidth / 2, 1, kWidth / 2, 1, kFormat, kType, | 1791 kTarget, kLevel, kWidth / 2, 1, kWidth / 2, 1, kFormat, kType, |
1825 transfer_buffer_id_, offset4, true); | 1792 kTransferBufferId, offset4, true); |
1826 expected.set_token4.Init(GetNextToken()); | 1793 expected.set_token4.Init(GetNextToken()); |
1827 | 1794 |
1828 // TODO(gman): Make it possible to run this test | 1795 // TODO(gman): Make it possible to run this test |
1829 // EXPECT_CALL(*command_buffer_, OnFlush(_)) | 1796 // EXPECT_CALL(*command_buffer_, OnFlush(_)) |
1830 // .WillOnce(CheckRectAction( | 1797 // .WillOnce(CheckRectAction( |
1831 // kWidth / 2, 1, kFormat, kType, kPixelStoreUnpackAlignment, false, | 1798 // kWidth / 2, 1, kFormat, kType, kPixelStoreUnpackAlignment, false, |
1832 // pixels.get(), | 1799 // pixels.get(), |
1833 // GetTransferAddressFromOffsetAs<uint8>(offset1, part_size))) | 1800 // GetTransferAddressFromOffsetAs<uint8>(offset1, part_size))) |
1834 // .WillOnce(CheckRectAction( | 1801 // .WillOnce(CheckRectAction( |
1835 // kWidth / 2, 1, kFormat, kType, kPixelStoreUnpackAlignment, false, | 1802 // kWidth / 2, 1, kFormat, kType, kPixelStoreUnpackAlignment, false, |
(...skipping 18 matching lines...) Expand all Loading... |
1854 const void* commands2 = GetPut(); | 1821 const void* commands2 = GetPut(); |
1855 offset1 = AllocateTransferBuffer(part_size); | 1822 offset1 = AllocateTransferBuffer(part_size); |
1856 offset2 = AllocateTransferBuffer(part_size); | 1823 offset2 = AllocateTransferBuffer(part_size); |
1857 offset3 = AllocateTransferBuffer(part_size); | 1824 offset3 = AllocateTransferBuffer(part_size); |
1858 offset4 = AllocateTransferBuffer(part_size); | 1825 offset4 = AllocateTransferBuffer(part_size); |
1859 expected.tex_image_2d.Init( | 1826 expected.tex_image_2d.Init( |
1860 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, | 1827 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, |
1861 0, 0); | 1828 0, 0); |
1862 expected.tex_sub_image_2d1.Init( | 1829 expected.tex_sub_image_2d1.Init( |
1863 kTarget, kLevel, 0, 1, kWidth / 2, 1, kFormat, kType, | 1830 kTarget, kLevel, 0, 1, kWidth / 2, 1, kFormat, kType, |
1864 transfer_buffer_id_, offset1, true); | 1831 kTransferBufferId, offset1, true); |
1865 expected.set_token1.Init(GetNextToken()); | 1832 expected.set_token1.Init(GetNextToken()); |
1866 expected.tex_sub_image_2d2.Init( | 1833 expected.tex_sub_image_2d2.Init( |
1867 kTarget, kLevel, kWidth / 2, 1, kWidth / 2, 1, kFormat, kType, | 1834 kTarget, kLevel, kWidth / 2, 1, kWidth / 2, 1, kFormat, kType, |
1868 transfer_buffer_id_, offset2, true); | 1835 kTransferBufferId, offset2, true); |
1869 expected.set_token2.Init(GetNextToken()); | 1836 expected.set_token2.Init(GetNextToken()); |
1870 expected.tex_sub_image_2d3.Init( | 1837 expected.tex_sub_image_2d3.Init( |
1871 kTarget, kLevel, 0, 0, kWidth / 2, 1, kFormat, kType, | 1838 kTarget, kLevel, 0, 0, kWidth / 2, 1, kFormat, kType, |
1872 transfer_buffer_id_, offset3, true); | 1839 kTransferBufferId, offset3, true); |
1873 expected.set_token3.Init(GetNextToken()); | 1840 expected.set_token3.Init(GetNextToken()); |
1874 expected.tex_sub_image_2d4.Init( | 1841 expected.tex_sub_image_2d4.Init( |
1875 kTarget, kLevel, kWidth / 2, 0, kWidth / 2, 1, kFormat, kType, | 1842 kTarget, kLevel, kWidth / 2, 0, kWidth / 2, 1, kFormat, kType, |
1876 transfer_buffer_id_, offset4, true); | 1843 kTransferBufferId, offset4, true); |
1877 expected.set_token4.Init(GetNextToken()); | 1844 expected.set_token4.Init(GetNextToken()); |
1878 | 1845 |
1879 // TODO(gman): Make it possible to run this test | 1846 // TODO(gman): Make it possible to run this test |
1880 // EXPECT_CALL(*command_buffer_, OnFlush(_)) | 1847 // EXPECT_CALL(*command_buffer_, OnFlush(_)) |
1881 // .WillOnce(CheckRectAction( | 1848 // .WillOnce(CheckRectAction( |
1882 // kWidth / 2, 1, kFormat, kType, kPixelStoreUnpackAlignment, false, | 1849 // kWidth / 2, 1, kFormat, kType, kPixelStoreUnpackAlignment, false, |
1883 // pixels.get(), | 1850 // pixels.get(), |
1884 // GetTransferAddressFromOffsetAs<uint8>(offset1, part_size))) | 1851 // GetTransferAddressFromOffsetAs<uint8>(offset1, part_size))) |
1885 // .WillOnce(CheckRectAction( | 1852 // .WillOnce(CheckRectAction( |
1886 // kWidth / 2, 1, kFormat, kType, kPixelStoreUnpackAlignment, false, | 1853 // kWidth / 2, 1, kFormat, kType, kPixelStoreUnpackAlignment, false, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1934 uint32 offset1 = AllocateTransferBuffer(sub_2_high_size); | 1901 uint32 offset1 = AllocateTransferBuffer(sub_2_high_size); |
1935 uint32 offset2 = AllocateTransferBuffer(sub_2_high_size); | 1902 uint32 offset2 = AllocateTransferBuffer(sub_2_high_size); |
1936 | 1903 |
1937 Cmds expected; | 1904 Cmds expected; |
1938 expected.pixel_store_i1.Init(GL_UNPACK_ALIGNMENT, kPixelStoreUnpackAlignment); | 1905 expected.pixel_store_i1.Init(GL_UNPACK_ALIGNMENT, kPixelStoreUnpackAlignment); |
1939 expected.tex_image_2d.Init( | 1906 expected.tex_image_2d.Init( |
1940 kTarget, kLevel, kFormat, kTextureWidth, kTextureHeight, kBorder, kFormat, | 1907 kTarget, kLevel, kFormat, kTextureWidth, kTextureHeight, kBorder, kFormat, |
1941 kType, 0, NULL); | 1908 kType, 0, NULL); |
1942 expected.tex_sub_image_2d1.Init(kTarget, kLevel, kSubImageXOffset, | 1909 expected.tex_sub_image_2d1.Init(kTarget, kLevel, kSubImageXOffset, |
1943 kSubImageYOffset + 2, kSubImageWidth, 2, kFormat, kType, | 1910 kSubImageYOffset + 2, kSubImageWidth, 2, kFormat, kType, |
1944 transfer_buffer_id_, offset1, false); | 1911 kTransferBufferId, offset1, false); |
1945 expected.set_token1.Init(GetNextToken()); | 1912 expected.set_token1.Init(GetNextToken()); |
1946 expected.tex_sub_image_2d2.Init(kTarget, kLevel, kSubImageXOffset, | 1913 expected.tex_sub_image_2d2.Init(kTarget, kLevel, kSubImageXOffset, |
1947 kSubImageYOffset, kSubImageWidth , 2, kFormat, kType, transfer_buffer_id_, | 1914 kSubImageYOffset, kSubImageWidth , 2, kFormat, kType, kTransferBufferId, |
1948 offset2, false); | 1915 offset2, false); |
1949 expected.set_token2.Init(GetNextToken()); | 1916 expected.set_token2.Init(GetNextToken()); |
1950 | 1917 |
1951 gl_->PixelStorei(GL_UNPACK_ALIGNMENT, kPixelStoreUnpackAlignment); | 1918 gl_->PixelStorei(GL_UNPACK_ALIGNMENT, kPixelStoreUnpackAlignment); |
1952 gl_->TexImage2D( | 1919 gl_->TexImage2D( |
1953 kTarget, kLevel, kFormat, kTextureWidth, kTextureHeight, kBorder, kFormat, | 1920 kTarget, kLevel, kFormat, kTextureWidth, kTextureHeight, kBorder, kFormat, |
1954 kType, NULL); | 1921 kType, NULL); |
1955 // this call should not emit commands (handled client-side) | 1922 // this call should not emit commands (handled client-side) |
1956 gl_->PixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE); | 1923 gl_->PixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE); |
1957 scoped_array<uint32> pixels(new uint32[kSubImageWidth * kSubImageHeight]); | 1924 scoped_array<uint32> pixels(new uint32[kSubImageWidth * kSubImageHeight]); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2046 TEST_F(GLES2ImplementationTest, CreateStreamTextureCHROMIUM) { | 2013 TEST_F(GLES2ImplementationTest, CreateStreamTextureCHROMIUM) { |
2047 const GLuint kTextureId = 123; | 2014 const GLuint kTextureId = 123; |
2048 const GLuint kResult = 456; | 2015 const GLuint kResult = 456; |
2049 const uint32 kResultOffset = 0; | 2016 const uint32 kResultOffset = 0; |
2050 | 2017 |
2051 struct Cmds { | 2018 struct Cmds { |
2052 CreateStreamTextureCHROMIUM create_stream; | 2019 CreateStreamTextureCHROMIUM create_stream; |
2053 }; | 2020 }; |
2054 | 2021 |
2055 Cmds expected; | 2022 Cmds expected; |
2056 expected.create_stream.Init(kTextureId, transfer_buffer_id_, kResultOffset); | 2023 expected.create_stream.Init(kTextureId, kTransferBufferId, kResultOffset); |
2057 | 2024 |
2058 EXPECT_CALL(*command_buffer_, OnFlush(_)) | 2025 EXPECT_CALL(*command_buffer_, OnFlush(_)) |
2059 .WillOnce(SetMemoryAtOffset(kResultOffset, kResult)) | 2026 .WillOnce(SetMemoryAtOffset(kResultOffset, kResult)) |
2060 .WillOnce(SetMemory(GLuint(GL_NO_ERROR))) | 2027 .WillOnce(SetMemory(GLuint(GL_NO_ERROR))) |
2061 .RetiresOnSaturation(); | 2028 .RetiresOnSaturation(); |
2062 | 2029 |
2063 GLuint handle = gl_->CreateStreamTextureCHROMIUM(kTextureId); | 2030 GLuint handle = gl_->CreateStreamTextureCHROMIUM(kTextureId); |
2064 EXPECT_EQ(handle, kResult); | 2031 EXPECT_EQ(handle, kResult); |
2065 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); | 2032 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); |
2066 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 2033 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
(...skipping 10 matching lines...) Expand all Loading... |
2077 expected.destroy_stream.Init(kTextureHandle); | 2044 expected.destroy_stream.Init(kTextureHandle); |
2078 | 2045 |
2079 gl_->DestroyStreamTextureCHROMIUM(kTextureHandle); | 2046 gl_->DestroyStreamTextureCHROMIUM(kTextureHandle); |
2080 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 2047 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
2081 } | 2048 } |
2082 | 2049 |
2083 } // namespace gles2 | 2050 } // namespace gles2 |
2084 } // namespace gpu | 2051 } // namespace gpu |
2085 | 2052 |
2086 | 2053 |
OLD | NEW |