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