| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Tests for GLES2Implementation. | 5 // Tests for GLES2Implementation. |
| 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/gl2.h> | 9 #include <GLES2/gl2.h> |
| 10 #include <GLES2/gl2ext.h> | 10 #include <GLES2/gl2ext.h> |
| 11 #include <GLES2/gl2extchromium.h> | 11 #include <GLES2/gl2extchromium.h> |
| 12 #include <GLES3/gl3.h> | 12 #include <GLES3/gl3.h> |
| 13 #include <stddef.h> |
| 14 #include <stdint.h> |
| 13 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 14 #include "gpu/command_buffer/client/client_test_helper.h" | 16 #include "gpu/command_buffer/client/client_test_helper.h" |
| 15 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 17 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
| 16 #include "gpu/command_buffer/client/program_info_manager.h" | 18 #include "gpu/command_buffer/client/program_info_manager.h" |
| 17 #include "gpu/command_buffer/client/query_tracker.h" | 19 #include "gpu/command_buffer/client/query_tracker.h" |
| 18 #include "gpu/command_buffer/client/ring_buffer.h" | 20 #include "gpu/command_buffer/client/ring_buffer.h" |
| 19 #include "gpu/command_buffer/client/transfer_buffer.h" | 21 #include "gpu/command_buffer/client/transfer_buffer.h" |
| 20 #include "gpu/command_buffer/common/command_buffer.h" | 22 #include "gpu/command_buffer/common/command_buffer.h" |
| 21 #include "gpu/command_buffer/common/sync_token.h" | 23 #include "gpu/command_buffer/common/sync_token.h" |
| 24 #include "testing/gmock/include/gmock/gmock.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 23 #include "testing/gmock/include/gmock/gmock.h" | |
| 24 | 26 |
| 25 #if !defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) | 27 #if !defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) |
| 26 #define GLES2_SUPPORT_CLIENT_SIDE_ARRAYS | 28 #define GLES2_SUPPORT_CLIENT_SIDE_ARRAYS |
| 27 #endif | 29 #endif |
| 28 | 30 |
| 29 using testing::_; | 31 using testing::_; |
| 30 using testing::AtLeast; | 32 using testing::AtLeast; |
| 31 using testing::AnyNumber; | 33 using testing::AnyNumber; |
| 32 using testing::DoAll; | 34 using testing::DoAll; |
| 33 using testing::InSequence; | 35 using testing::InSequence; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 52 // Used to help set the transfer buffer result to SizedResult of a single value. | 54 // Used to help set the transfer buffer result to SizedResult of a single value. |
| 53 template <typename T> | 55 template <typename T> |
| 54 class SizedResultHelper { | 56 class SizedResultHelper { |
| 55 public: | 57 public: |
| 56 explicit SizedResultHelper(T result) | 58 explicit SizedResultHelper(T result) |
| 57 : size_(sizeof(result)) { | 59 : size_(sizeof(result)) { |
| 58 memcpy(result_, &result, sizeof(T)); | 60 memcpy(result_, &result, sizeof(T)); |
| 59 } | 61 } |
| 60 | 62 |
| 61 private: | 63 private: |
| 62 uint32 size_; | 64 uint32_t size_; |
| 63 char result_[sizeof(T)]; | 65 char result_[sizeof(T)]; |
| 64 }; | 66 }; |
| 65 | 67 |
| 66 // Struct to make it easy to pass a vec4 worth of floats. | 68 // Struct to make it easy to pass a vec4 worth of floats. |
| 67 struct FourFloats { | 69 struct FourFloats { |
| 68 FourFloats(float _x, float _y, float _z, float _w) | 70 FourFloats(float _x, float _y, float _z, float _w) |
| 69 : x(_x), | 71 : x(_x), |
| 70 y(_y), | 72 y(_y), |
| 71 z(_z), | 73 z(_z), |
| 72 w(_w) { | 74 w(_w) { |
| 73 } | 75 } |
| 74 | 76 |
| 75 float x; | 77 float x; |
| 76 float y; | 78 float y; |
| 77 float z; | 79 float z; |
| 78 float w; | 80 float w; |
| 79 }; | 81 }; |
| 80 | 82 |
| 81 #pragma pack(push, 1) | 83 #pragma pack(push, 1) |
| 82 // Struct that holds 7 characters. | 84 // Struct that holds 7 characters. |
| 83 struct Str7 { | 85 struct Str7 { |
| 84 char str[7]; | 86 char str[7]; |
| 85 }; | 87 }; |
| 86 #pragma pack(pop) | 88 #pragma pack(pop) |
| 87 | 89 |
| 88 class MockTransferBuffer : public TransferBufferInterface { | 90 class MockTransferBuffer : public TransferBufferInterface { |
| 89 public: | 91 public: |
| 90 struct ExpectedMemoryInfo { | 92 struct ExpectedMemoryInfo { |
| 91 uint32 offset; | 93 uint32_t offset; |
| 92 int32 id; | 94 int32_t id; |
| 93 uint8* ptr; | 95 uint8_t* ptr; |
| 94 }; | 96 }; |
| 95 | 97 |
| 96 MockTransferBuffer( | 98 MockTransferBuffer( |
| 97 CommandBuffer* command_buffer, | 99 CommandBuffer* command_buffer, |
| 98 unsigned int size, | 100 unsigned int size, |
| 99 unsigned int result_size, | 101 unsigned int result_size, |
| 100 unsigned int alignment, | 102 unsigned int alignment, |
| 101 bool initialize_fail) | 103 bool initialize_fail) |
| 102 : command_buffer_(command_buffer), | 104 : command_buffer_(command_buffer), |
| 103 size_(size), | 105 size_(size), |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 153 |
| 152 bool InSync() { | 154 bool InSync() { |
| 153 return expected_buffer_index_ == actual_buffer_index_ && | 155 return expected_buffer_index_ == actual_buffer_index_ && |
| 154 expected_offset_ == actual_offset_; | 156 expected_offset_ == actual_offset_; |
| 155 } | 157 } |
| 156 | 158 |
| 157 ExpectedMemoryInfo GetExpectedMemory(size_t size) { | 159 ExpectedMemoryInfo GetExpectedMemory(size_t size) { |
| 158 ExpectedMemoryInfo mem; | 160 ExpectedMemoryInfo mem; |
| 159 mem.offset = AllocateExpectedTransferBuffer(size); | 161 mem.offset = AllocateExpectedTransferBuffer(size); |
| 160 mem.id = GetExpectedTransferBufferId(); | 162 mem.id = GetExpectedTransferBufferId(); |
| 161 mem.ptr = static_cast<uint8*>( | 163 mem.ptr = static_cast<uint8_t*>( |
| 162 GetExpectedTransferAddressFromOffset(mem.offset, size)); | 164 GetExpectedTransferAddressFromOffset(mem.offset, size)); |
| 163 return mem; | 165 return mem; |
| 164 } | 166 } |
| 165 | 167 |
| 166 ExpectedMemoryInfo GetExpectedResultMemory(size_t size) { | 168 ExpectedMemoryInfo GetExpectedResultMemory(size_t size) { |
| 167 ExpectedMemoryInfo mem; | 169 ExpectedMemoryInfo mem; |
| 168 mem.offset = GetExpectedResultBufferOffset(); | 170 mem.offset = GetExpectedResultBufferOffset(); |
| 169 mem.id = GetExpectedResultBufferId(); | 171 mem.id = GetExpectedResultBufferId(); |
| 170 mem.ptr = static_cast<uint8*>( | 172 mem.ptr = static_cast<uint8_t*>( |
| 171 GetExpectedTransferAddressFromOffset(mem.offset, size)); | 173 GetExpectedTransferAddressFromOffset(mem.offset, size)); |
| 172 return mem; | 174 return mem; |
| 173 } | 175 } |
| 174 | 176 |
| 175 private: | 177 private: |
| 176 static const int kNumBuffers = 2; | 178 static const int kNumBuffers = 2; |
| 177 | 179 |
| 178 uint8* actual_buffer() const { | 180 uint8_t* actual_buffer() const { |
| 179 return static_cast<uint8*>(buffers_[actual_buffer_index_]->memory()); | 181 return static_cast<uint8_t*>(buffers_[actual_buffer_index_]->memory()); |
| 180 } | 182 } |
| 181 | 183 |
| 182 uint8* expected_buffer() const { | 184 uint8_t* expected_buffer() const { |
| 183 return static_cast<uint8*>(buffers_[expected_buffer_index_]->memory()); | 185 return static_cast<uint8_t*>(buffers_[expected_buffer_index_]->memory()); |
| 184 } | 186 } |
| 185 | 187 |
| 186 uint32 AllocateExpectedTransferBuffer(size_t size) { | 188 uint32_t AllocateExpectedTransferBuffer(size_t size) { |
| 187 EXPECT_LE(size, MaxTransferBufferSize()); | 189 EXPECT_LE(size, MaxTransferBufferSize()); |
| 188 | 190 |
| 189 // Toggle which buffer we get each time to simulate the buffer being | 191 // Toggle which buffer we get each time to simulate the buffer being |
| 190 // reallocated. | 192 // reallocated. |
| 191 expected_buffer_index_ = (expected_buffer_index_ + 1) % kNumBuffers; | 193 expected_buffer_index_ = (expected_buffer_index_ + 1) % kNumBuffers; |
| 192 | 194 |
| 193 if (expected_offset_ + size > size_) { | 195 if (expected_offset_ + size > size_) { |
| 194 expected_offset_ = result_size_; | 196 expected_offset_ = result_size_; |
| 195 } | 197 } |
| 196 uint32 offset = expected_offset_; | 198 uint32_t offset = expected_offset_; |
| 197 expected_offset_ += RoundToAlignment(size); | 199 expected_offset_ += RoundToAlignment(size); |
| 198 | 200 |
| 199 // Make sure each buffer has a different offset. | 201 // Make sure each buffer has a different offset. |
| 200 return offset + expected_buffer_index_ * alignment_; | 202 return offset + expected_buffer_index_ * alignment_; |
| 201 } | 203 } |
| 202 | 204 |
| 203 void* GetExpectedTransferAddressFromOffset(uint32 offset, size_t size) { | 205 void* GetExpectedTransferAddressFromOffset(uint32_t offset, size_t size) { |
| 204 EXPECT_GE(offset, expected_buffer_index_ * alignment_); | 206 EXPECT_GE(offset, expected_buffer_index_ * alignment_); |
| 205 EXPECT_LE(offset + size, size_ + expected_buffer_index_ * alignment_); | 207 EXPECT_LE(offset + size, size_ + expected_buffer_index_ * alignment_); |
| 206 return expected_buffer() + offset; | 208 return expected_buffer() + offset; |
| 207 } | 209 } |
| 208 | 210 |
| 209 int GetExpectedResultBufferId() { | 211 int GetExpectedResultBufferId() { |
| 210 return buffer_ids_[expected_buffer_index_]; | 212 return buffer_ids_[expected_buffer_index_]; |
| 211 } | 213 } |
| 212 | 214 |
| 213 uint32 GetExpectedResultBufferOffset() { | 215 uint32_t GetExpectedResultBufferOffset() { |
| 214 return expected_buffer_index_ * alignment_; | 216 return expected_buffer_index_ * alignment_; |
| 215 } | 217 } |
| 216 | 218 |
| 217 int GetExpectedTransferBufferId() { | 219 int GetExpectedTransferBufferId() { |
| 218 return buffer_ids_[expected_buffer_index_]; | 220 return buffer_ids_[expected_buffer_index_]; |
| 219 } | 221 } |
| 220 | 222 |
| 221 CommandBuffer* command_buffer_; | 223 CommandBuffer* command_buffer_; |
| 222 size_t size_; | 224 size_t size_; |
| 223 size_t result_size_; | 225 size_t result_size_; |
| 224 uint32 alignment_; | 226 uint32_t alignment_; |
| 225 int buffer_ids_[kNumBuffers]; | 227 int buffer_ids_[kNumBuffers]; |
| 226 scoped_refptr<Buffer> buffers_[kNumBuffers]; | 228 scoped_refptr<Buffer> buffers_[kNumBuffers]; |
| 227 int actual_buffer_index_; | 229 int actual_buffer_index_; |
| 228 int expected_buffer_index_; | 230 int expected_buffer_index_; |
| 229 void* last_alloc_; | 231 void* last_alloc_; |
| 230 uint32 expected_offset_; | 232 uint32_t expected_offset_; |
| 231 uint32 actual_offset_; | 233 uint32_t actual_offset_; |
| 232 bool initialize_fail_; | 234 bool initialize_fail_; |
| 233 | 235 |
| 234 DISALLOW_COPY_AND_ASSIGN(MockTransferBuffer); | 236 DISALLOW_COPY_AND_ASSIGN(MockTransferBuffer); |
| 235 }; | 237 }; |
| 236 | 238 |
| 237 bool MockTransferBuffer::Initialize( | 239 bool MockTransferBuffer::Initialize( |
| 238 unsigned int starting_buffer_size, | 240 unsigned int starting_buffer_size, |
| 239 unsigned int result_size, | 241 unsigned int result_size, |
| 240 unsigned int /* min_buffer_size */, | 242 unsigned int /* min_buffer_size */, |
| 241 unsigned int /* max_buffer_size */, | 243 unsigned int /* max_buffer_size */, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 EXPECT_TRUE(last_alloc_ == NULL); | 275 EXPECT_TRUE(last_alloc_ == NULL); |
| 274 | 276 |
| 275 // Toggle which buffer we get each time to simulate the buffer being | 277 // Toggle which buffer we get each time to simulate the buffer being |
| 276 // reallocated. | 278 // reallocated. |
| 277 actual_buffer_index_ = (actual_buffer_index_ + 1) % kNumBuffers; | 279 actual_buffer_index_ = (actual_buffer_index_ + 1) % kNumBuffers; |
| 278 | 280 |
| 279 size = std::min(static_cast<size_t>(size), MaxTransferBufferSize()); | 281 size = std::min(static_cast<size_t>(size), MaxTransferBufferSize()); |
| 280 if (actual_offset_ + size > size_) { | 282 if (actual_offset_ + size > size_) { |
| 281 actual_offset_ = result_size_; | 283 actual_offset_ = result_size_; |
| 282 } | 284 } |
| 283 uint32 offset = actual_offset_; | 285 uint32_t offset = actual_offset_; |
| 284 actual_offset_ += RoundToAlignment(size); | 286 actual_offset_ += RoundToAlignment(size); |
| 285 *size_allocated = size; | 287 *size_allocated = size; |
| 286 | 288 |
| 287 // Make sure each buffer has a different offset. | 289 // Make sure each buffer has a different offset. |
| 288 last_alloc_ = actual_buffer() + offset + actual_buffer_index_ * alignment_; | 290 last_alloc_ = actual_buffer() + offset + actual_buffer_index_ * alignment_; |
| 289 return last_alloc_; | 291 return last_alloc_; |
| 290 } | 292 } |
| 291 | 293 |
| 292 void* MockTransferBuffer::Alloc(unsigned int size) { | 294 void* MockTransferBuffer::Alloc(unsigned int size) { |
| 293 EXPECT_LE(size, MaxTransferBufferSize()); | 295 EXPECT_LE(size, MaxTransferBufferSize()); |
| 294 unsigned int temp = 0; | 296 unsigned int temp = 0; |
| 295 void* p = AllocUpTo(size, &temp); | 297 void* p = AllocUpTo(size, &temp); |
| 296 EXPECT_EQ(temp, size); | 298 EXPECT_EQ(temp, size); |
| 297 return p; | 299 return p; |
| 298 } | 300 } |
| 299 | 301 |
| 300 RingBuffer::Offset MockTransferBuffer::GetOffset(void* pointer) const { | 302 RingBuffer::Offset MockTransferBuffer::GetOffset(void* pointer) const { |
| 301 // Make sure each buffer has a different offset. | 303 // Make sure each buffer has a different offset. |
| 302 return static_cast<uint8*>(pointer) - actual_buffer(); | 304 return static_cast<uint8_t*>(pointer) - actual_buffer(); |
| 303 } | 305 } |
| 304 | 306 |
| 305 void MockTransferBuffer::DiscardBlock(void* p) { | 307 void MockTransferBuffer::DiscardBlock(void* p) { |
| 306 EXPECT_EQ(last_alloc_, p); | 308 EXPECT_EQ(last_alloc_, p); |
| 307 last_alloc_ = NULL; | 309 last_alloc_ = NULL; |
| 308 } | 310 } |
| 309 | 311 |
| 310 void MockTransferBuffer::FreePendingToken(void* p, unsigned int /* token */) { | 312 void MockTransferBuffer::FreePendingToken(void* p, unsigned int /* token */) { |
| 311 EXPECT_EQ(last_alloc_, p); | 313 EXPECT_EQ(last_alloc_, p); |
| 312 last_alloc_ = NULL; | 314 last_alloc_ = NULL; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 static void Delete(GLES2Implementation* gl_impl, | 374 static void Delete(GLES2Implementation* gl_impl, |
| 373 GLsizei n, | 375 GLsizei n, |
| 374 const GLuint* ids) { | 376 const GLuint* ids) { |
| 375 gl_impl->DeleteTextures(n, ids); | 377 gl_impl->DeleteTextures(n, ids); |
| 376 } | 378 } |
| 377 }; | 379 }; |
| 378 | 380 |
| 379 class GLES2ImplementationTest : public testing::Test { | 381 class GLES2ImplementationTest : public testing::Test { |
| 380 protected: | 382 protected: |
| 381 static const int kNumTestContexts = 2; | 383 static const int kNumTestContexts = 2; |
| 382 static const uint8 kInitialValue = 0xBD; | 384 static const uint8_t kInitialValue = 0xBD; |
| 383 static const int32 kNumCommandEntries = 500; | 385 static const int32_t kNumCommandEntries = 500; |
| 384 static const int32 kCommandBufferSizeBytes = | 386 static const int32_t kCommandBufferSizeBytes = |
| 385 kNumCommandEntries * sizeof(CommandBufferEntry); | 387 kNumCommandEntries * sizeof(CommandBufferEntry); |
| 386 static const size_t kTransferBufferSize = 512; | 388 static const size_t kTransferBufferSize = 512; |
| 387 | 389 |
| 388 static const GLint kMaxCombinedTextureImageUnits = 8; | 390 static const GLint kMaxCombinedTextureImageUnits = 8; |
| 389 static const GLint kMaxCubeMapTextureSize = 64; | 391 static const GLint kMaxCubeMapTextureSize = 64; |
| 390 static const GLint kMaxFragmentUniformVectors = 16; | 392 static const GLint kMaxFragmentUniformVectors = 16; |
| 391 static const GLint kMaxRenderbufferSize = 64; | 393 static const GLint kMaxRenderbufferSize = 64; |
| 392 static const GLint kMaxTextureImageUnits = 8; | 394 static const GLint kMaxTextureImageUnits = 8; |
| 393 static const GLint kMaxTextureSize = 128; | 395 static const GLint kMaxTextureSize = 128; |
| 394 static const GLint kMaxVaryingVectors = 8; | 396 static const GLint kMaxVaryingVectors = 8; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 int token_; | 536 int token_; |
| 535 }; | 537 }; |
| 536 | 538 |
| 537 GLES2ImplementationTest() : commands_(NULL) {} | 539 GLES2ImplementationTest() : commands_(NULL) {} |
| 538 | 540 |
| 539 void SetUp() override; | 541 void SetUp() override; |
| 540 void TearDown() override; | 542 void TearDown() override; |
| 541 | 543 |
| 542 bool NoCommandsWritten() { | 544 bool NoCommandsWritten() { |
| 543 scoped_refptr<Buffer> ring_buffer = helper_->get_ring_buffer(); | 545 scoped_refptr<Buffer> ring_buffer = helper_->get_ring_buffer(); |
| 544 const uint8* cmds = reinterpret_cast<const uint8*>(ring_buffer->memory()); | 546 const uint8_t* cmds = |
| 545 const uint8* end = cmds + ring_buffer->size(); | 547 reinterpret_cast<const uint8_t*>(ring_buffer->memory()); |
| 548 const uint8_t* end = cmds + ring_buffer->size(); |
| 546 for (; cmds < end; ++cmds) { | 549 for (; cmds < end; ++cmds) { |
| 547 if (*cmds != kInitialValue) { | 550 if (*cmds != kInitialValue) { |
| 548 return false; | 551 return false; |
| 549 } | 552 } |
| 550 } | 553 } |
| 551 return true; | 554 return true; |
| 552 } | 555 } |
| 553 | 556 |
| 554 QueryTracker::Query* GetQuery(GLuint id) { | 557 QueryTracker::Query* GetQuery(GLuint id) { |
| 555 return gl_->query_tracker_->GetQuery(id); | 558 return gl_->query_tracker_->GetQuery(id); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 } | 636 } |
| 634 | 637 |
| 635 ExpectedMemoryInfo GetExpectedResultMemory(size_t size) { | 638 ExpectedMemoryInfo GetExpectedResultMemory(size_t size) { |
| 636 return transfer_buffer_->GetExpectedResultMemory(size); | 639 return transfer_buffer_->GetExpectedResultMemory(size); |
| 637 } | 640 } |
| 638 | 641 |
| 639 ExpectedMemoryInfo GetExpectedMappedMemory(size_t size) { | 642 ExpectedMemoryInfo GetExpectedMappedMemory(size_t size) { |
| 640 ExpectedMemoryInfo mem; | 643 ExpectedMemoryInfo mem; |
| 641 | 644 |
| 642 // Temporarily allocate memory and expect that memory block to be reused. | 645 // Temporarily allocate memory and expect that memory block to be reused. |
| 643 mem.ptr = static_cast<uint8*>(gl_->mapped_memory_->Alloc(size, | 646 mem.ptr = static_cast<uint8_t*>( |
| 644 &mem.id, | 647 gl_->mapped_memory_->Alloc(size, &mem.id, &mem.offset)); |
| 645 &mem.offset)); | |
| 646 gl_->mapped_memory_->Free(mem.ptr); | 648 gl_->mapped_memory_->Free(mem.ptr); |
| 647 | 649 |
| 648 return mem; | 650 return mem; |
| 649 } | 651 } |
| 650 | 652 |
| 651 // Sets the ProgramInfoManager. The manager will be owned | 653 // Sets the ProgramInfoManager. The manager will be owned |
| 652 // by the ShareGroup. | 654 // by the ShareGroup. |
| 653 void SetProgramInfoManager(ProgramInfoManager* manager) { | 655 void SetProgramInfoManager(ProgramInfoManager* manager) { |
| 654 gl_->share_group()->set_program_info_manager(manager); | 656 gl_->share_group()->set_program_info_manager(manager); |
| 655 } | 657 } |
| 656 | 658 |
| 657 int CheckError() { | 659 int CheckError() { |
| 658 ExpectedMemoryInfo result = | 660 ExpectedMemoryInfo result = |
| 659 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); | 661 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 660 EXPECT_CALL(*command_buffer(), OnFlush()) | 662 EXPECT_CALL(*command_buffer(), OnFlush()) |
| 661 .WillOnce(SetMemory(result.ptr, GLuint(GL_NO_ERROR))) | 663 .WillOnce(SetMemory(result.ptr, GLuint(GL_NO_ERROR))) |
| 662 .RetiresOnSaturation(); | 664 .RetiresOnSaturation(); |
| 663 return gl_->GetError(); | 665 return gl_->GetError(); |
| 664 } | 666 } |
| 665 | 667 |
| 666 const std::string& GetLastError() { | 668 const std::string& GetLastError() { |
| 667 return gl_->GetLastError(); | 669 return gl_->GetLastError(); |
| 668 } | 670 } |
| 669 | 671 |
| 670 bool GetBucketContents(uint32 bucket_id, std::vector<int8>* data) { | 672 bool GetBucketContents(uint32_t bucket_id, std::vector<int8_t>* data) { |
| 671 return gl_->GetBucketContents(bucket_id, data); | 673 return gl_->GetBucketContents(bucket_id, data); |
| 672 } | 674 } |
| 673 | 675 |
| 674 bool AllowExtraTransferBufferSize() { | 676 bool AllowExtraTransferBufferSize() { |
| 675 return gl_->max_extra_transfer_buffer_size_ > 0; | 677 return gl_->max_extra_transfer_buffer_size_ > 0; |
| 676 } | 678 } |
| 677 | 679 |
| 678 TestContext test_contexts_[kNumTestContexts]; | 680 TestContext test_contexts_[kNumTestContexts]; |
| 679 | 681 |
| 680 scoped_refptr<ShareGroup> share_group_; | 682 scoped_refptr<ShareGroup> share_group_; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 | 793 |
| 792 void GLES2ImplementationStrictSharedTest::SetUp() { | 794 void GLES2ImplementationStrictSharedTest::SetUp() { |
| 793 ContextInitOptions init_options; | 795 ContextInitOptions init_options; |
| 794 init_options.bind_generates_resource_client = false; | 796 init_options.bind_generates_resource_client = false; |
| 795 init_options.bind_generates_resource_service = false; | 797 init_options.bind_generates_resource_service = false; |
| 796 ASSERT_TRUE(Initialize(init_options)); | 798 ASSERT_TRUE(Initialize(init_options)); |
| 797 } | 799 } |
| 798 | 800 |
| 799 // GCC requires these declarations, but MSVC requires they not be present | 801 // GCC requires these declarations, but MSVC requires they not be present |
| 800 #ifndef _MSC_VER | 802 #ifndef _MSC_VER |
| 801 const uint8 GLES2ImplementationTest::kInitialValue; | 803 const uint8_t GLES2ImplementationTest::kInitialValue; |
| 802 const int32 GLES2ImplementationTest::kNumCommandEntries; | 804 const int32_t GLES2ImplementationTest::kNumCommandEntries; |
| 803 const int32 GLES2ImplementationTest::kCommandBufferSizeBytes; | 805 const int32_t GLES2ImplementationTest::kCommandBufferSizeBytes; |
| 804 const size_t GLES2ImplementationTest::kTransferBufferSize; | 806 const size_t GLES2ImplementationTest::kTransferBufferSize; |
| 805 const GLint GLES2ImplementationTest::kMaxCombinedTextureImageUnits; | 807 const GLint GLES2ImplementationTest::kMaxCombinedTextureImageUnits; |
| 806 const GLint GLES2ImplementationTest::kMaxCubeMapTextureSize; | 808 const GLint GLES2ImplementationTest::kMaxCubeMapTextureSize; |
| 807 const GLint GLES2ImplementationTest::kMaxFragmentUniformVectors; | 809 const GLint GLES2ImplementationTest::kMaxFragmentUniformVectors; |
| 808 const GLint GLES2ImplementationTest::kMaxRenderbufferSize; | 810 const GLint GLES2ImplementationTest::kMaxRenderbufferSize; |
| 809 const GLint GLES2ImplementationTest::kMaxTextureImageUnits; | 811 const GLint GLES2ImplementationTest::kMaxTextureImageUnits; |
| 810 const GLint GLES2ImplementationTest::kMaxTextureSize; | 812 const GLint GLES2ImplementationTest::kMaxTextureSize; |
| 811 const GLint GLES2ImplementationTest::kMaxVaryingVectors; | 813 const GLint GLES2ImplementationTest::kMaxVaryingVectors; |
| 812 const GLint GLES2ImplementationTest::kMaxVertexAttribs; | 814 const GLint GLES2ImplementationTest::kMaxVertexAttribs; |
| 813 const GLint GLES2ImplementationTest::kMaxVertexTextureImageUnits; | 815 const GLint GLES2ImplementationTest::kMaxVertexTextureImageUnits; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 825 const GLuint GLES2ImplementationTest::kQueriesStartId; | 827 const GLuint GLES2ImplementationTest::kQueriesStartId; |
| 826 const GLuint GLES2ImplementationTest::kVertexArraysStartId; | 828 const GLuint GLES2ImplementationTest::kVertexArraysStartId; |
| 827 const GLuint GLES2ImplementationTest::kValuebuffersStartId; | 829 const GLuint GLES2ImplementationTest::kValuebuffersStartId; |
| 828 #endif | 830 #endif |
| 829 | 831 |
| 830 TEST_F(GLES2ImplementationTest, Basic) { | 832 TEST_F(GLES2ImplementationTest, Basic) { |
| 831 EXPECT_TRUE(gl_->share_group() != NULL); | 833 EXPECT_TRUE(gl_->share_group() != NULL); |
| 832 } | 834 } |
| 833 | 835 |
| 834 TEST_F(GLES2ImplementationTest, GetBucketContents) { | 836 TEST_F(GLES2ImplementationTest, GetBucketContents) { |
| 835 const uint32 kBucketId = GLES2Implementation::kResultBucketId; | 837 const uint32_t kBucketId = GLES2Implementation::kResultBucketId; |
| 836 const uint32 kTestSize = MaxTransferBufferSize() + 32; | 838 const uint32_t kTestSize = MaxTransferBufferSize() + 32; |
| 837 | 839 |
| 838 scoped_ptr<uint8[]> buf(new uint8 [kTestSize]); | 840 scoped_ptr<uint8_t[]> buf(new uint8_t[kTestSize]); |
| 839 uint8* expected_data = buf.get(); | 841 uint8_t* expected_data = buf.get(); |
| 840 for (uint32 ii = 0; ii < kTestSize; ++ii) { | 842 for (uint32_t ii = 0; ii < kTestSize; ++ii) { |
| 841 expected_data[ii] = ii * 3; | 843 expected_data[ii] = ii * 3; |
| 842 } | 844 } |
| 843 | 845 |
| 844 struct Cmds { | 846 struct Cmds { |
| 845 cmd::GetBucketStart get_bucket_start; | 847 cmd::GetBucketStart get_bucket_start; |
| 846 cmd::SetToken set_token1; | 848 cmd::SetToken set_token1; |
| 847 cmd::GetBucketData get_bucket_data; | 849 cmd::GetBucketData get_bucket_data; |
| 848 cmd::SetToken set_token2; | 850 cmd::SetToken set_token2; |
| 849 cmd::SetBucketSize set_bucket_size2; | 851 cmd::SetBucketSize set_bucket_size2; |
| 850 }; | 852 }; |
| 851 | 853 |
| 852 ExpectedMemoryInfo mem1 = GetExpectedMemory(MaxTransferBufferSize()); | 854 ExpectedMemoryInfo mem1 = GetExpectedMemory(MaxTransferBufferSize()); |
| 853 ExpectedMemoryInfo result1 = GetExpectedResultMemory(sizeof(uint32)); | 855 ExpectedMemoryInfo result1 = GetExpectedResultMemory(sizeof(uint32_t)); |
| 854 ExpectedMemoryInfo mem2 = GetExpectedMemory( | 856 ExpectedMemoryInfo mem2 = GetExpectedMemory( |
| 855 kTestSize - MaxTransferBufferSize()); | 857 kTestSize - MaxTransferBufferSize()); |
| 856 | 858 |
| 857 Cmds expected; | 859 Cmds expected; |
| 858 expected.get_bucket_start.Init( | 860 expected.get_bucket_start.Init( |
| 859 kBucketId, result1.id, result1.offset, | 861 kBucketId, result1.id, result1.offset, |
| 860 MaxTransferBufferSize(), mem1.id, mem1.offset); | 862 MaxTransferBufferSize(), mem1.id, mem1.offset); |
| 861 expected.set_token1.Init(GetNextToken()); | 863 expected.set_token1.Init(GetNextToken()); |
| 862 expected.get_bucket_data.Init( | 864 expected.get_bucket_data.Init( |
| 863 kBucketId, MaxTransferBufferSize(), | 865 kBucketId, MaxTransferBufferSize(), |
| 864 kTestSize - MaxTransferBufferSize(), mem2.id, mem2.offset); | 866 kTestSize - MaxTransferBufferSize(), mem2.id, mem2.offset); |
| 865 expected.set_bucket_size2.Init(kBucketId, 0); | 867 expected.set_bucket_size2.Init(kBucketId, 0); |
| 866 expected.set_token2.Init(GetNextToken()); | 868 expected.set_token2.Init(GetNextToken()); |
| 867 | 869 |
| 868 EXPECT_CALL(*command_buffer(), OnFlush()) | 870 EXPECT_CALL(*command_buffer(), OnFlush()) |
| 869 .WillOnce(DoAll( | 871 .WillOnce(DoAll( |
| 870 SetMemory(result1.ptr, kTestSize), | 872 SetMemory(result1.ptr, kTestSize), |
| 871 SetMemoryFromArray( | 873 SetMemoryFromArray( |
| 872 mem1.ptr, expected_data, MaxTransferBufferSize()))) | 874 mem1.ptr, expected_data, MaxTransferBufferSize()))) |
| 873 .WillOnce(SetMemoryFromArray( | 875 .WillOnce(SetMemoryFromArray( |
| 874 mem2.ptr, expected_data + MaxTransferBufferSize(), | 876 mem2.ptr, expected_data + MaxTransferBufferSize(), |
| 875 kTestSize - MaxTransferBufferSize())) | 877 kTestSize - MaxTransferBufferSize())) |
| 876 .RetiresOnSaturation(); | 878 .RetiresOnSaturation(); |
| 877 | 879 |
| 878 std::vector<int8> data; | 880 std::vector<int8_t> data; |
| 879 GetBucketContents(kBucketId, &data); | 881 GetBucketContents(kBucketId, &data); |
| 880 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 882 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 881 ASSERT_EQ(kTestSize, data.size()); | 883 ASSERT_EQ(kTestSize, data.size()); |
| 882 EXPECT_EQ(0, memcmp(expected_data, &data[0], data.size())); | 884 EXPECT_EQ(0, memcmp(expected_data, &data[0], data.size())); |
| 883 } | 885 } |
| 884 | 886 |
| 885 TEST_F(GLES2ImplementationTest, GetShaderPrecisionFormat) { | 887 TEST_F(GLES2ImplementationTest, GetShaderPrecisionFormat) { |
| 886 struct Cmds { | 888 struct Cmds { |
| 887 cmds::GetShaderPrecisionFormat cmd; | 889 cmds::GetShaderPrecisionFormat cmd; |
| 888 }; | 890 }; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 953 gl_->GetShaderPrecisionFormat(GL_FRAGMENT_SHADER, GL_MEDIUM_FLOAT, range4, | 955 gl_->GetShaderPrecisionFormat(GL_FRAGMENT_SHADER, GL_MEDIUM_FLOAT, range4, |
| 954 &precision4); | 956 &precision4); |
| 955 const void* commands5 = GetPut(); | 957 const void* commands5 = GetPut(); |
| 956 EXPECT_EQ(commands4, commands5); | 958 EXPECT_EQ(commands4, commands5); |
| 957 EXPECT_EQ(range4[0], 3); | 959 EXPECT_EQ(range4[0], 3); |
| 958 EXPECT_EQ(range4[1], 5); | 960 EXPECT_EQ(range4[1], 5); |
| 959 EXPECT_EQ(precision4, 7); | 961 EXPECT_EQ(precision4, 7); |
| 960 } | 962 } |
| 961 | 963 |
| 962 TEST_F(GLES2ImplementationTest, GetShaderSource) { | 964 TEST_F(GLES2ImplementationTest, GetShaderSource) { |
| 963 const uint32 kBucketId = GLES2Implementation::kResultBucketId; | 965 const uint32_t kBucketId = GLES2Implementation::kResultBucketId; |
| 964 const GLuint kShaderId = 456; | 966 const GLuint kShaderId = 456; |
| 965 const Str7 kString = {"foobar"}; | 967 const Str7 kString = {"foobar"}; |
| 966 const char kBad = 0x12; | 968 const char kBad = 0x12; |
| 967 struct Cmds { | 969 struct Cmds { |
| 968 cmd::SetBucketSize set_bucket_size1; | 970 cmd::SetBucketSize set_bucket_size1; |
| 969 cmds::GetShaderSource get_shader_source; | 971 cmds::GetShaderSource get_shader_source; |
| 970 cmd::GetBucketStart get_bucket_start; | 972 cmd::GetBucketStart get_bucket_start; |
| 971 cmd::SetToken set_token1; | 973 cmd::SetToken set_token1; |
| 972 cmd::SetBucketSize set_bucket_size2; | 974 cmd::SetBucketSize set_bucket_size2; |
| 973 }; | 975 }; |
| 974 | 976 |
| 975 ExpectedMemoryInfo mem1 = GetExpectedMemory(MaxTransferBufferSize()); | 977 ExpectedMemoryInfo mem1 = GetExpectedMemory(MaxTransferBufferSize()); |
| 976 ExpectedMemoryInfo result1 = GetExpectedResultMemory(sizeof(uint32)); | 978 ExpectedMemoryInfo result1 = GetExpectedResultMemory(sizeof(uint32_t)); |
| 977 | 979 |
| 978 Cmds expected; | 980 Cmds expected; |
| 979 expected.set_bucket_size1.Init(kBucketId, 0); | 981 expected.set_bucket_size1.Init(kBucketId, 0); |
| 980 expected.get_shader_source.Init(kShaderId, kBucketId); | 982 expected.get_shader_source.Init(kShaderId, kBucketId); |
| 981 expected.get_bucket_start.Init( | 983 expected.get_bucket_start.Init( |
| 982 kBucketId, result1.id, result1.offset, | 984 kBucketId, result1.id, result1.offset, |
| 983 MaxTransferBufferSize(), mem1.id, mem1.offset); | 985 MaxTransferBufferSize(), mem1.id, mem1.offset); |
| 984 expected.set_token1.Init(GetNextToken()); | 986 expected.set_token1.Init(GetNextToken()); |
| 985 expected.set_bucket_size2.Init(kBucketId, 0); | 987 expected.set_bucket_size2.Init(kBucketId, 0); |
| 986 char buf[sizeof(kString) + 1]; | 988 char buf[sizeof(kString) + 1]; |
| 987 memset(buf, kBad, sizeof(buf)); | 989 memset(buf, kBad, sizeof(buf)); |
| 988 | 990 |
| 989 EXPECT_CALL(*command_buffer(), OnFlush()) | 991 EXPECT_CALL(*command_buffer(), OnFlush()) |
| 990 .WillOnce(DoAll(SetMemory(result1.ptr, uint32(sizeof(kString))), | 992 .WillOnce(DoAll(SetMemory(result1.ptr, uint32_t(sizeof(kString))), |
| 991 SetMemory(mem1.ptr, kString))) | 993 SetMemory(mem1.ptr, kString))) |
| 992 .RetiresOnSaturation(); | 994 .RetiresOnSaturation(); |
| 993 | 995 |
| 994 GLsizei length = 0; | 996 GLsizei length = 0; |
| 995 gl_->GetShaderSource(kShaderId, sizeof(buf), &length, buf); | 997 gl_->GetShaderSource(kShaderId, sizeof(buf), &length, buf); |
| 996 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 998 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 997 EXPECT_EQ(sizeof(kString) - 1, static_cast<size_t>(length)); | 999 EXPECT_EQ(sizeof(kString) - 1, static_cast<size_t>(length)); |
| 998 EXPECT_STREQ(kString.str, buf); | 1000 EXPECT_STREQ(kString.str, buf); |
| 999 EXPECT_EQ(buf[sizeof(kString)], kBad); | 1001 EXPECT_EQ(buf[sizeof(kString)], kBad); |
| 1000 } | 1002 } |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1136 gl_->DrawArraysInstancedANGLE(GL_POINTS, kFirst, kCount, 1); | 1138 gl_->DrawArraysInstancedANGLE(GL_POINTS, kFirst, kCount, 1); |
| 1137 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 1139 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1138 } | 1140 } |
| 1139 | 1141 |
| 1140 TEST_F(GLES2ImplementationTest, DrawElementsClientSideBuffers) { | 1142 TEST_F(GLES2ImplementationTest, DrawElementsClientSideBuffers) { |
| 1141 static const float verts[][4] = { | 1143 static const float verts[][4] = { |
| 1142 { 12.0f, 23.0f, 34.0f, 45.0f, }, | 1144 { 12.0f, 23.0f, 34.0f, 45.0f, }, |
| 1143 { 56.0f, 67.0f, 78.0f, 89.0f, }, | 1145 { 56.0f, 67.0f, 78.0f, 89.0f, }, |
| 1144 { 13.0f, 24.0f, 35.0f, 46.0f, }, | 1146 { 13.0f, 24.0f, 35.0f, 46.0f, }, |
| 1145 }; | 1147 }; |
| 1146 static const uint16 indices[] = { | 1148 static const uint16_t indices[] = { |
| 1147 1, 2, | 1149 1, 2, |
| 1148 }; | 1150 }; |
| 1149 struct Cmds { | 1151 struct Cmds { |
| 1150 cmds::EnableVertexAttribArray enable1; | 1152 cmds::EnableVertexAttribArray enable1; |
| 1151 cmds::EnableVertexAttribArray enable2; | 1153 cmds::EnableVertexAttribArray enable2; |
| 1152 cmds::BindBuffer bind_to_index_emu; | 1154 cmds::BindBuffer bind_to_index_emu; |
| 1153 cmds::BufferData set_index_size; | 1155 cmds::BufferData set_index_size; |
| 1154 cmds::BufferSubData copy_data0; | 1156 cmds::BufferSubData copy_data0; |
| 1155 cmd::SetToken set_token0; | 1157 cmd::SetToken set_token0; |
| 1156 cmds::BindBuffer bind_to_emu; | 1158 cmds::BindBuffer bind_to_emu; |
| 1157 cmds::BufferData set_size; | 1159 cmds::BufferData set_size; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1220 gl_->DrawElements(GL_POINTS, kCount, GL_UNSIGNED_SHORT, indices); | 1222 gl_->DrawElements(GL_POINTS, kCount, GL_UNSIGNED_SHORT, indices); |
| 1221 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 1223 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1222 } | 1224 } |
| 1223 | 1225 |
| 1224 TEST_F(GLES2ImplementationTest, DrawElementsClientSideBuffersIndexUint) { | 1226 TEST_F(GLES2ImplementationTest, DrawElementsClientSideBuffersIndexUint) { |
| 1225 static const float verts[][4] = { | 1227 static const float verts[][4] = { |
| 1226 { 12.0f, 23.0f, 34.0f, 45.0f, }, | 1228 { 12.0f, 23.0f, 34.0f, 45.0f, }, |
| 1227 { 56.0f, 67.0f, 78.0f, 89.0f, }, | 1229 { 56.0f, 67.0f, 78.0f, 89.0f, }, |
| 1228 { 13.0f, 24.0f, 35.0f, 46.0f, }, | 1230 { 13.0f, 24.0f, 35.0f, 46.0f, }, |
| 1229 }; | 1231 }; |
| 1230 static const uint32 indices[] = { | 1232 static const uint32_t indices[] = { |
| 1231 1, 2, | 1233 1, 2, |
| 1232 }; | 1234 }; |
| 1233 struct Cmds { | 1235 struct Cmds { |
| 1234 cmds::EnableVertexAttribArray enable1; | 1236 cmds::EnableVertexAttribArray enable1; |
| 1235 cmds::EnableVertexAttribArray enable2; | 1237 cmds::EnableVertexAttribArray enable2; |
| 1236 cmds::BindBuffer bind_to_index_emu; | 1238 cmds::BindBuffer bind_to_index_emu; |
| 1237 cmds::BufferData set_index_size; | 1239 cmds::BufferData set_index_size; |
| 1238 cmds::BufferSubData copy_data0; | 1240 cmds::BufferSubData copy_data0; |
| 1239 cmd::SetToken set_token0; | 1241 cmd::SetToken set_token0; |
| 1240 cmds::BindBuffer bind_to_emu; | 1242 cmds::BindBuffer bind_to_emu; |
| 1241 cmds::BufferData set_size; | 1243 cmds::BufferData set_size; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1304 gl_->DrawElements(GL_POINTS, kCount, GL_UNSIGNED_INT, indices); | 1306 gl_->DrawElements(GL_POINTS, kCount, GL_UNSIGNED_INT, indices); |
| 1305 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 1307 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1306 } | 1308 } |
| 1307 | 1309 |
| 1308 TEST_F(GLES2ImplementationTest, DrawElementsClientSideBuffersInvalidIndexUint) { | 1310 TEST_F(GLES2ImplementationTest, DrawElementsClientSideBuffersInvalidIndexUint) { |
| 1309 static const float verts[][4] = { | 1311 static const float verts[][4] = { |
| 1310 { 12.0f, 23.0f, 34.0f, 45.0f, }, | 1312 { 12.0f, 23.0f, 34.0f, 45.0f, }, |
| 1311 { 56.0f, 67.0f, 78.0f, 89.0f, }, | 1313 { 56.0f, 67.0f, 78.0f, 89.0f, }, |
| 1312 { 13.0f, 24.0f, 35.0f, 46.0f, }, | 1314 { 13.0f, 24.0f, 35.0f, 46.0f, }, |
| 1313 }; | 1315 }; |
| 1314 static const uint32 indices[] = { | 1316 static const uint32_t indices[] = {1, 0x90000000}; |
| 1315 1, 0x90000000 | |
| 1316 }; | |
| 1317 | 1317 |
| 1318 const GLuint kAttribIndex1 = 1; | 1318 const GLuint kAttribIndex1 = 1; |
| 1319 const GLuint kAttribIndex2 = 3; | 1319 const GLuint kAttribIndex2 = 3; |
| 1320 const GLint kNumComponents1 = 3; | 1320 const GLint kNumComponents1 = 3; |
| 1321 const GLint kNumComponents2 = 2; | 1321 const GLint kNumComponents2 = 2; |
| 1322 const GLsizei kClientStride = sizeof(verts[0]); | 1322 const GLsizei kClientStride = sizeof(verts[0]); |
| 1323 const GLsizei kCount = 2; | 1323 const GLsizei kCount = 2; |
| 1324 | 1324 |
| 1325 EXPECT_CALL(*command_buffer(), OnFlush()) | 1325 EXPECT_CALL(*command_buffer(), OnFlush()) |
| 1326 .Times(1) | 1326 .Times(1) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1371 const GLsizei kClientStride = sizeof(verts[0]); | 1371 const GLsizei kClientStride = sizeof(verts[0]); |
| 1372 const GLsizei kCount = 2; | 1372 const GLsizei kCount = 2; |
| 1373 const GLsizei kSize1 = | 1373 const GLsizei kSize1 = |
| 1374 arraysize(verts) * kNumComponents1 * sizeof(verts[0][0]); | 1374 arraysize(verts) * kNumComponents1 * sizeof(verts[0][0]); |
| 1375 const GLsizei kSize2 = | 1375 const GLsizei kSize2 = |
| 1376 arraysize(verts) * kNumComponents2 * sizeof(verts[0][0]); | 1376 arraysize(verts) * kNumComponents2 * sizeof(verts[0][0]); |
| 1377 const GLsizei kEmuOffset1 = 0; | 1377 const GLsizei kEmuOffset1 = 0; |
| 1378 const GLsizei kEmuOffset2 = kSize1; | 1378 const GLsizei kEmuOffset2 = kSize1; |
| 1379 const GLsizei kTotalSize = kSize1 + kSize2; | 1379 const GLsizei kTotalSize = kSize1 + kSize2; |
| 1380 | 1380 |
| 1381 ExpectedMemoryInfo mem1 = GetExpectedResultMemory(sizeof(uint32)); | 1381 ExpectedMemoryInfo mem1 = GetExpectedResultMemory(sizeof(uint32_t)); |
| 1382 ExpectedMemoryInfo mem2 = GetExpectedMemory(kSize1); | 1382 ExpectedMemoryInfo mem2 = GetExpectedMemory(kSize1); |
| 1383 ExpectedMemoryInfo mem3 = GetExpectedMemory(kSize2); | 1383 ExpectedMemoryInfo mem3 = GetExpectedMemory(kSize2); |
| 1384 | 1384 |
| 1385 | 1385 |
| 1386 Cmds expected; | 1386 Cmds expected; |
| 1387 expected.enable1.Init(kAttribIndex1); | 1387 expected.enable1.Init(kAttribIndex1); |
| 1388 expected.enable2.Init(kAttribIndex2); | 1388 expected.enable2.Init(kAttribIndex2); |
| 1389 expected.bind_to_index.Init(GL_ELEMENT_ARRAY_BUFFER, kClientIndexBufferId); | 1389 expected.bind_to_index.Init(GL_ELEMENT_ARRAY_BUFFER, kClientIndexBufferId); |
| 1390 expected.get_max.Init(kClientIndexBufferId, kCount, GL_UNSIGNED_SHORT, | 1390 expected.get_max.Init(kClientIndexBufferId, kCount, GL_UNSIGNED_SHORT, |
| 1391 kIndexOffset, mem1.id, mem1.offset); | 1391 kIndexOffset, mem1.id, mem1.offset); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1419 reinterpret_cast<const void*>(kIndexOffset)); | 1419 reinterpret_cast<const void*>(kIndexOffset)); |
| 1420 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 1420 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1421 } | 1421 } |
| 1422 | 1422 |
| 1423 TEST_F(GLES2ImplementationTest, DrawElementsInstancedANGLEClientSideBuffers) { | 1423 TEST_F(GLES2ImplementationTest, DrawElementsInstancedANGLEClientSideBuffers) { |
| 1424 static const float verts[][4] = { | 1424 static const float verts[][4] = { |
| 1425 { 12.0f, 23.0f, 34.0f, 45.0f, }, | 1425 { 12.0f, 23.0f, 34.0f, 45.0f, }, |
| 1426 { 56.0f, 67.0f, 78.0f, 89.0f, }, | 1426 { 56.0f, 67.0f, 78.0f, 89.0f, }, |
| 1427 { 13.0f, 24.0f, 35.0f, 46.0f, }, | 1427 { 13.0f, 24.0f, 35.0f, 46.0f, }, |
| 1428 }; | 1428 }; |
| 1429 static const uint16 indices[] = { | 1429 static const uint16_t indices[] = { |
| 1430 1, 2, | 1430 1, 2, |
| 1431 }; | 1431 }; |
| 1432 struct Cmds { | 1432 struct Cmds { |
| 1433 cmds::EnableVertexAttribArray enable1; | 1433 cmds::EnableVertexAttribArray enable1; |
| 1434 cmds::EnableVertexAttribArray enable2; | 1434 cmds::EnableVertexAttribArray enable2; |
| 1435 cmds::VertexAttribDivisorANGLE divisor; | 1435 cmds::VertexAttribDivisorANGLE divisor; |
| 1436 cmds::BindBuffer bind_to_index_emu; | 1436 cmds::BindBuffer bind_to_index_emu; |
| 1437 cmds::BufferData set_index_size; | 1437 cmds::BufferData set_index_size; |
| 1438 cmds::BufferSubData copy_data0; | 1438 cmds::BufferSubData copy_data0; |
| 1439 cmd::SetToken set_token0; | 1439 cmd::SetToken set_token0; |
| 1440 cmds::BindBuffer bind_to_emu; | 1440 cmds::BindBuffer bind_to_emu; |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1697 Cmds expected; | 1697 Cmds expected; |
| 1698 expected.read1.Init( | 1698 expected.read1.Init( |
| 1699 0, 0, kWidth, kHeight / 2, kFormat, kType, | 1699 0, 0, kWidth, kHeight / 2, kFormat, kType, |
| 1700 mem1.id, mem1.offset, result1.id, result1.offset, | 1700 mem1.id, mem1.offset, result1.id, result1.offset, |
| 1701 false); | 1701 false); |
| 1702 expected.set_token1.Init(GetNextToken()); | 1702 expected.set_token1.Init(GetNextToken()); |
| 1703 expected.read2.Init( | 1703 expected.read2.Init( |
| 1704 0, kHeight / 2, kWidth, kHeight / 2, kFormat, kType, | 1704 0, kHeight / 2, kWidth, kHeight / 2, kFormat, kType, |
| 1705 mem2.id, mem2.offset, result2.id, result2.offset, false); | 1705 mem2.id, mem2.offset, result2.id, result2.offset, false); |
| 1706 expected.set_token2.Init(GetNextToken()); | 1706 expected.set_token2.Init(GetNextToken()); |
| 1707 scoped_ptr<int8[]> buffer(new int8[kWidth * kHeight * kBytesPerPixel]); | 1707 scoped_ptr<int8_t[]> buffer(new int8_t[kWidth * kHeight * kBytesPerPixel]); |
| 1708 | 1708 |
| 1709 EXPECT_CALL(*command_buffer(), OnFlush()) | 1709 EXPECT_CALL(*command_buffer(), OnFlush()) |
| 1710 .WillOnce(SetMemory(result1.ptr, static_cast<uint32>(1))) | 1710 .WillOnce(SetMemory(result1.ptr, static_cast<uint32_t>(1))) |
| 1711 .WillOnce(SetMemory(result2.ptr, static_cast<uint32>(1))) | 1711 .WillOnce(SetMemory(result2.ptr, static_cast<uint32_t>(1))) |
| 1712 .RetiresOnSaturation(); | 1712 .RetiresOnSaturation(); |
| 1713 | 1713 |
| 1714 gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, buffer.get()); | 1714 gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, buffer.get()); |
| 1715 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 1715 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1716 } | 1716 } |
| 1717 | 1717 |
| 1718 TEST_F(GLES2ImplementationTest, ReadPixelsBadFormatType) { | 1718 TEST_F(GLES2ImplementationTest, ReadPixelsBadFormatType) { |
| 1719 struct Cmds { | 1719 struct Cmds { |
| 1720 cmds::ReadPixels read; | 1720 cmds::ReadPixels read; |
| 1721 cmd::SetToken set_token; | 1721 cmd::SetToken set_token; |
| 1722 }; | 1722 }; |
| 1723 const GLint kBytesPerPixel = 4; | 1723 const GLint kBytesPerPixel = 4; |
| 1724 const GLint kWidth = 2; | 1724 const GLint kWidth = 2; |
| 1725 const GLint kHeight = 2; | 1725 const GLint kHeight = 2; |
| 1726 const GLenum kFormat = 0; | 1726 const GLenum kFormat = 0; |
| 1727 const GLenum kType = 0; | 1727 const GLenum kType = 0; |
| 1728 | 1728 |
| 1729 ExpectedMemoryInfo mem1 = | 1729 ExpectedMemoryInfo mem1 = |
| 1730 GetExpectedMemory(kWidth * kHeight * kBytesPerPixel); | 1730 GetExpectedMemory(kWidth * kHeight * kBytesPerPixel); |
| 1731 ExpectedMemoryInfo result1 = | 1731 ExpectedMemoryInfo result1 = |
| 1732 GetExpectedResultMemory(sizeof(cmds::ReadPixels::Result)); | 1732 GetExpectedResultMemory(sizeof(cmds::ReadPixels::Result)); |
| 1733 | 1733 |
| 1734 Cmds expected; | 1734 Cmds expected; |
| 1735 expected.read.Init( | 1735 expected.read.Init( |
| 1736 0, 0, kWidth, kHeight, kFormat, kType, | 1736 0, 0, kWidth, kHeight, kFormat, kType, |
| 1737 mem1.id, mem1.offset, result1.id, result1.offset, false); | 1737 mem1.id, mem1.offset, result1.id, result1.offset, false); |
| 1738 expected.set_token.Init(GetNextToken()); | 1738 expected.set_token.Init(GetNextToken()); |
| 1739 scoped_ptr<int8[]> buffer(new int8[kWidth * kHeight * kBytesPerPixel]); | 1739 scoped_ptr<int8_t[]> buffer(new int8_t[kWidth * kHeight * kBytesPerPixel]); |
| 1740 | 1740 |
| 1741 EXPECT_CALL(*command_buffer(), OnFlush()) | 1741 EXPECT_CALL(*command_buffer(), OnFlush()) |
| 1742 .Times(1) | 1742 .Times(1) |
| 1743 .RetiresOnSaturation(); | 1743 .RetiresOnSaturation(); |
| 1744 | 1744 |
| 1745 gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, buffer.get()); | 1745 gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, buffer.get()); |
| 1746 } | 1746 } |
| 1747 | 1747 |
| 1748 TEST_F(GLES2ImplementationTest, FreeUnusedSharedMemory) { | 1748 TEST_F(GLES2ImplementationTest, FreeUnusedSharedMemory) { |
| 1749 struct Cmds { | 1749 struct Cmds { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1773 | 1773 |
| 1774 TEST_F(GLES2ImplementationTest, MapUnmapBufferSubDataCHROMIUM) { | 1774 TEST_F(GLES2ImplementationTest, MapUnmapBufferSubDataCHROMIUM) { |
| 1775 struct Cmds { | 1775 struct Cmds { |
| 1776 cmds::BufferSubData buf; | 1776 cmds::BufferSubData buf; |
| 1777 cmd::SetToken set_token; | 1777 cmd::SetToken set_token; |
| 1778 }; | 1778 }; |
| 1779 const GLenum kTarget = GL_ELEMENT_ARRAY_BUFFER; | 1779 const GLenum kTarget = GL_ELEMENT_ARRAY_BUFFER; |
| 1780 const GLintptr kOffset = 15; | 1780 const GLintptr kOffset = 15; |
| 1781 const GLsizeiptr kSize = 16; | 1781 const GLsizeiptr kSize = 16; |
| 1782 | 1782 |
| 1783 uint32 offset = 0; | 1783 uint32_t offset = 0; |
| 1784 Cmds expected; | 1784 Cmds expected; |
| 1785 expected.buf.Init( | 1785 expected.buf.Init( |
| 1786 kTarget, kOffset, kSize, | 1786 kTarget, kOffset, kSize, |
| 1787 command_buffer()->GetNextFreeTransferBufferId(), offset); | 1787 command_buffer()->GetNextFreeTransferBufferId(), offset); |
| 1788 expected.set_token.Init(GetNextToken()); | 1788 expected.set_token.Init(GetNextToken()); |
| 1789 | 1789 |
| 1790 void* mem = gl_->MapBufferSubDataCHROMIUM( | 1790 void* mem = gl_->MapBufferSubDataCHROMIUM( |
| 1791 kTarget, kOffset, kSize, GL_WRITE_ONLY); | 1791 kTarget, kOffset, kSize, GL_WRITE_ONLY); |
| 1792 ASSERT_TRUE(mem != NULL); | 1792 ASSERT_TRUE(mem != NULL); |
| 1793 gl_->UnmapBufferSubDataCHROMIUM(mem); | 1793 gl_->UnmapBufferSubDataCHROMIUM(mem); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1837 cmd::SetToken set_token; | 1837 cmd::SetToken set_token; |
| 1838 }; | 1838 }; |
| 1839 const GLint kLevel = 1; | 1839 const GLint kLevel = 1; |
| 1840 const GLint kXOffset = 2; | 1840 const GLint kXOffset = 2; |
| 1841 const GLint kYOffset = 3; | 1841 const GLint kYOffset = 3; |
| 1842 const GLint kWidth = 4; | 1842 const GLint kWidth = 4; |
| 1843 const GLint kHeight = 5; | 1843 const GLint kHeight = 5; |
| 1844 const GLenum kFormat = GL_RGBA; | 1844 const GLenum kFormat = GL_RGBA; |
| 1845 const GLenum kType = GL_UNSIGNED_BYTE; | 1845 const GLenum kType = GL_UNSIGNED_BYTE; |
| 1846 | 1846 |
| 1847 uint32 offset = 0; | 1847 uint32_t offset = 0; |
| 1848 Cmds expected; | 1848 Cmds expected; |
| 1849 expected.tex.Init( | 1849 expected.tex.Init( |
| 1850 GL_TEXTURE_2D, kLevel, kXOffset, kYOffset, kWidth, kHeight, kFormat, | 1850 GL_TEXTURE_2D, kLevel, kXOffset, kYOffset, kWidth, kHeight, kFormat, |
| 1851 kType, | 1851 kType, |
| 1852 command_buffer()->GetNextFreeTransferBufferId(), offset, GL_FALSE); | 1852 command_buffer()->GetNextFreeTransferBufferId(), offset, GL_FALSE); |
| 1853 expected.set_token.Init(GetNextToken()); | 1853 expected.set_token.Init(GetNextToken()); |
| 1854 | 1854 |
| 1855 void* mem = gl_->MapTexSubImage2DCHROMIUM( | 1855 void* mem = gl_->MapTexSubImage2DCHROMIUM( |
| 1856 GL_TEXTURE_2D, | 1856 GL_TEXTURE_2D, |
| 1857 kLevel, | 1857 kLevel, |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1974 kType, | 1974 kType, |
| 1975 GL_READ_ONLY); | 1975 GL_READ_ONLY); |
| 1976 EXPECT_TRUE(mem == NULL); | 1976 EXPECT_TRUE(mem == NULL); |
| 1977 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_ENUM), gl_->GetError()); | 1977 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_ENUM), gl_->GetError()); |
| 1978 const char* kPtr = "something"; | 1978 const char* kPtr = "something"; |
| 1979 gl_->UnmapTexSubImage2DCHROMIUM(kPtr); | 1979 gl_->UnmapTexSubImage2DCHROMIUM(kPtr); |
| 1980 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), gl_->GetError()); | 1980 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), gl_->GetError()); |
| 1981 } | 1981 } |
| 1982 | 1982 |
| 1983 TEST_F(GLES2ImplementationTest, GetProgramInfoCHROMIUMGoodArgs) { | 1983 TEST_F(GLES2ImplementationTest, GetProgramInfoCHROMIUMGoodArgs) { |
| 1984 const uint32 kBucketId = GLES2Implementation::kResultBucketId; | 1984 const uint32_t kBucketId = GLES2Implementation::kResultBucketId; |
| 1985 const GLuint kProgramId = 123; | 1985 const GLuint kProgramId = 123; |
| 1986 const char kBad = 0x12; | 1986 const char kBad = 0x12; |
| 1987 GLsizei size = 0; | 1987 GLsizei size = 0; |
| 1988 const Str7 kString = {"foobar"}; | 1988 const Str7 kString = {"foobar"}; |
| 1989 char buf[20]; | 1989 char buf[20]; |
| 1990 | 1990 |
| 1991 ExpectedMemoryInfo mem1 = | 1991 ExpectedMemoryInfo mem1 = |
| 1992 GetExpectedMemory(MaxTransferBufferSize()); | 1992 GetExpectedMemory(MaxTransferBufferSize()); |
| 1993 ExpectedMemoryInfo result1 = | 1993 ExpectedMemoryInfo result1 = |
| 1994 GetExpectedResultMemory(sizeof(cmd::GetBucketStart::Result)); | 1994 GetExpectedResultMemory(sizeof(cmd::GetBucketStart::Result)); |
| 1995 ExpectedMemoryInfo result2 = | 1995 ExpectedMemoryInfo result2 = |
| 1996 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); | 1996 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 1997 | 1997 |
| 1998 memset(buf, kBad, sizeof(buf)); | 1998 memset(buf, kBad, sizeof(buf)); |
| 1999 EXPECT_CALL(*command_buffer(), OnFlush()) | 1999 EXPECT_CALL(*command_buffer(), OnFlush()) |
| 2000 .WillOnce(DoAll(SetMemory(result1.ptr, uint32(sizeof(kString))), | 2000 .WillOnce(DoAll(SetMemory(result1.ptr, uint32_t(sizeof(kString))), |
| 2001 SetMemory(mem1.ptr, kString))) | 2001 SetMemory(mem1.ptr, kString))) |
| 2002 .WillOnce(SetMemory(result2.ptr, GLuint(GL_NO_ERROR))) | 2002 .WillOnce(SetMemory(result2.ptr, GLuint(GL_NO_ERROR))) |
| 2003 .RetiresOnSaturation(); | 2003 .RetiresOnSaturation(); |
| 2004 | 2004 |
| 2005 struct Cmds { | 2005 struct Cmds { |
| 2006 cmd::SetBucketSize set_bucket_size1; | 2006 cmd::SetBucketSize set_bucket_size1; |
| 2007 cmds::GetProgramInfoCHROMIUM get_program_info; | 2007 cmds::GetProgramInfoCHROMIUM get_program_info; |
| 2008 cmd::GetBucketStart get_bucket_start; | 2008 cmd::GetBucketStart get_bucket_start; |
| 2009 cmd::SetToken set_token1; | 2009 cmd::SetToken set_token1; |
| 2010 cmd::SetBucketSize set_bucket_size2; | 2010 cmd::SetBucketSize set_bucket_size2; |
| 2011 }; | 2011 }; |
| 2012 Cmds expected; | 2012 Cmds expected; |
| 2013 expected.set_bucket_size1.Init(kBucketId, 0); | 2013 expected.set_bucket_size1.Init(kBucketId, 0); |
| 2014 expected.get_program_info.Init(kProgramId, kBucketId); | 2014 expected.get_program_info.Init(kProgramId, kBucketId); |
| 2015 expected.get_bucket_start.Init( | 2015 expected.get_bucket_start.Init( |
| 2016 kBucketId, result1.id, result1.offset, | 2016 kBucketId, result1.id, result1.offset, |
| 2017 MaxTransferBufferSize(), mem1.id, mem1.offset); | 2017 MaxTransferBufferSize(), mem1.id, mem1.offset); |
| 2018 expected.set_token1.Init(GetNextToken()); | 2018 expected.set_token1.Init(GetNextToken()); |
| 2019 expected.set_bucket_size2.Init(kBucketId, 0); | 2019 expected.set_bucket_size2.Init(kBucketId, 0); |
| 2020 gl_->GetProgramInfoCHROMIUM(kProgramId, sizeof(buf), &size, &buf); | 2020 gl_->GetProgramInfoCHROMIUM(kProgramId, sizeof(buf), &size, &buf); |
| 2021 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 2021 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2022 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); | 2022 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); |
| 2023 EXPECT_EQ(sizeof(kString), static_cast<size_t>(size)); | 2023 EXPECT_EQ(sizeof(kString), static_cast<size_t>(size)); |
| 2024 EXPECT_STREQ(kString.str, buf); | 2024 EXPECT_STREQ(kString.str, buf); |
| 2025 EXPECT_EQ(buf[sizeof(kString)], kBad); | 2025 EXPECT_EQ(buf[sizeof(kString)], kBad); |
| 2026 } | 2026 } |
| 2027 | 2027 |
| 2028 TEST_F(GLES2ImplementationTest, GetProgramInfoCHROMIUMBadArgs) { | 2028 TEST_F(GLES2ImplementationTest, GetProgramInfoCHROMIUMBadArgs) { |
| 2029 const uint32 kBucketId = GLES2Implementation::kResultBucketId; | 2029 const uint32_t kBucketId = GLES2Implementation::kResultBucketId; |
| 2030 const GLuint kProgramId = 123; | 2030 const GLuint kProgramId = 123; |
| 2031 GLsizei size = 0; | 2031 GLsizei size = 0; |
| 2032 const Str7 kString = {"foobar"}; | 2032 const Str7 kString = {"foobar"}; |
| 2033 char buf[20]; | 2033 char buf[20]; |
| 2034 | 2034 |
| 2035 ExpectedMemoryInfo mem1 = GetExpectedMemory(MaxTransferBufferSize()); | 2035 ExpectedMemoryInfo mem1 = GetExpectedMemory(MaxTransferBufferSize()); |
| 2036 ExpectedMemoryInfo result1 = | 2036 ExpectedMemoryInfo result1 = |
| 2037 GetExpectedResultMemory(sizeof(cmd::GetBucketStart::Result)); | 2037 GetExpectedResultMemory(sizeof(cmd::GetBucketStart::Result)); |
| 2038 ExpectedMemoryInfo result2 = | 2038 ExpectedMemoryInfo result2 = |
| 2039 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); | 2039 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 2040 ExpectedMemoryInfo result3 = | 2040 ExpectedMemoryInfo result3 = |
| 2041 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); | 2041 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 2042 ExpectedMemoryInfo result4 = | 2042 ExpectedMemoryInfo result4 = |
| 2043 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); | 2043 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 2044 | 2044 |
| 2045 EXPECT_CALL(*command_buffer(), OnFlush()) | 2045 EXPECT_CALL(*command_buffer(), OnFlush()) |
| 2046 .WillOnce(DoAll(SetMemory(result1.ptr, uint32(sizeof(kString))), | 2046 .WillOnce(DoAll(SetMemory(result1.ptr, uint32_t(sizeof(kString))), |
| 2047 SetMemory(mem1.ptr, kString))) | 2047 SetMemory(mem1.ptr, kString))) |
| 2048 .WillOnce(SetMemory(result2.ptr, GLuint(GL_NO_ERROR))) | 2048 .WillOnce(SetMemory(result2.ptr, GLuint(GL_NO_ERROR))) |
| 2049 .WillOnce(SetMemory(result3.ptr, GLuint(GL_NO_ERROR))) | 2049 .WillOnce(SetMemory(result3.ptr, GLuint(GL_NO_ERROR))) |
| 2050 .WillOnce(SetMemory(result4.ptr, GLuint(GL_NO_ERROR))) | 2050 .WillOnce(SetMemory(result4.ptr, GLuint(GL_NO_ERROR))) |
| 2051 .RetiresOnSaturation(); | 2051 .RetiresOnSaturation(); |
| 2052 | 2052 |
| 2053 // try bufsize not big enough. | 2053 // try bufsize not big enough. |
| 2054 struct Cmds { | 2054 struct Cmds { |
| 2055 cmd::SetBucketSize set_bucket_size1; | 2055 cmd::SetBucketSize set_bucket_size1; |
| 2056 cmds::GetProgramInfoCHROMIUM get_program_info; | 2056 cmds::GetProgramInfoCHROMIUM get_program_info; |
| 2057 cmd::GetBucketStart get_bucket_start; | 2057 cmd::GetBucketStart get_bucket_start; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2076 EXPECT_TRUE(NoCommandsWritten()); | 2076 EXPECT_TRUE(NoCommandsWritten()); |
| 2077 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), gl_->GetError()); | 2077 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), gl_->GetError()); |
| 2078 ClearCommands(); | 2078 ClearCommands(); |
| 2079 // try no size ptr. | 2079 // try no size ptr. |
| 2080 gl_->GetProgramInfoCHROMIUM(kProgramId, sizeof(buf), NULL, &buf); | 2080 gl_->GetProgramInfoCHROMIUM(kProgramId, sizeof(buf), NULL, &buf); |
| 2081 EXPECT_TRUE(NoCommandsWritten()); | 2081 EXPECT_TRUE(NoCommandsWritten()); |
| 2082 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), gl_->GetError()); | 2082 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), gl_->GetError()); |
| 2083 } | 2083 } |
| 2084 | 2084 |
| 2085 TEST_F(GLES2ImplementationTest, GetUniformBlocksCHROMIUMGoodArgs) { | 2085 TEST_F(GLES2ImplementationTest, GetUniformBlocksCHROMIUMGoodArgs) { |
| 2086 const uint32 kBucketId = GLES2Implementation::kResultBucketId; | 2086 const uint32_t kBucketId = GLES2Implementation::kResultBucketId; |
| 2087 const GLuint kProgramId = 123; | 2087 const GLuint kProgramId = 123; |
| 2088 const char kBad = 0x12; | 2088 const char kBad = 0x12; |
| 2089 GLsizei size = 0; | 2089 GLsizei size = 0; |
| 2090 const Str7 kString = {"foobar"}; | 2090 const Str7 kString = {"foobar"}; |
| 2091 char buf[20]; | 2091 char buf[20]; |
| 2092 | 2092 |
| 2093 ExpectedMemoryInfo mem1 = | 2093 ExpectedMemoryInfo mem1 = |
| 2094 GetExpectedMemory(MaxTransferBufferSize()); | 2094 GetExpectedMemory(MaxTransferBufferSize()); |
| 2095 ExpectedMemoryInfo result1 = | 2095 ExpectedMemoryInfo result1 = |
| 2096 GetExpectedResultMemory(sizeof(cmd::GetBucketStart::Result)); | 2096 GetExpectedResultMemory(sizeof(cmd::GetBucketStart::Result)); |
| 2097 ExpectedMemoryInfo result2 = | 2097 ExpectedMemoryInfo result2 = |
| 2098 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); | 2098 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 2099 | 2099 |
| 2100 memset(buf, kBad, sizeof(buf)); | 2100 memset(buf, kBad, sizeof(buf)); |
| 2101 EXPECT_CALL(*command_buffer(), OnFlush()) | 2101 EXPECT_CALL(*command_buffer(), OnFlush()) |
| 2102 .WillOnce(DoAll(SetMemory(result1.ptr, uint32(sizeof(kString))), | 2102 .WillOnce(DoAll(SetMemory(result1.ptr, uint32_t(sizeof(kString))), |
| 2103 SetMemory(mem1.ptr, kString))) | 2103 SetMemory(mem1.ptr, kString))) |
| 2104 .WillOnce(SetMemory(result2.ptr, GLuint(GL_NO_ERROR))) | 2104 .WillOnce(SetMemory(result2.ptr, GLuint(GL_NO_ERROR))) |
| 2105 .RetiresOnSaturation(); | 2105 .RetiresOnSaturation(); |
| 2106 | 2106 |
| 2107 struct Cmds { | 2107 struct Cmds { |
| 2108 cmd::SetBucketSize set_bucket_size1; | 2108 cmd::SetBucketSize set_bucket_size1; |
| 2109 cmds::GetUniformBlocksCHROMIUM get_uniform_blocks; | 2109 cmds::GetUniformBlocksCHROMIUM get_uniform_blocks; |
| 2110 cmd::GetBucketStart get_bucket_start; | 2110 cmd::GetBucketStart get_bucket_start; |
| 2111 cmd::SetToken set_token1; | 2111 cmd::SetToken set_token1; |
| 2112 cmd::SetBucketSize set_bucket_size2; | 2112 cmd::SetBucketSize set_bucket_size2; |
| 2113 }; | 2113 }; |
| 2114 Cmds expected; | 2114 Cmds expected; |
| 2115 expected.set_bucket_size1.Init(kBucketId, 0); | 2115 expected.set_bucket_size1.Init(kBucketId, 0); |
| 2116 expected.get_uniform_blocks.Init(kProgramId, kBucketId); | 2116 expected.get_uniform_blocks.Init(kProgramId, kBucketId); |
| 2117 expected.get_bucket_start.Init( | 2117 expected.get_bucket_start.Init( |
| 2118 kBucketId, result1.id, result1.offset, | 2118 kBucketId, result1.id, result1.offset, |
| 2119 MaxTransferBufferSize(), mem1.id, mem1.offset); | 2119 MaxTransferBufferSize(), mem1.id, mem1.offset); |
| 2120 expected.set_token1.Init(GetNextToken()); | 2120 expected.set_token1.Init(GetNextToken()); |
| 2121 expected.set_bucket_size2.Init(kBucketId, 0); | 2121 expected.set_bucket_size2.Init(kBucketId, 0); |
| 2122 gl_->GetUniformBlocksCHROMIUM(kProgramId, sizeof(buf), &size, &buf); | 2122 gl_->GetUniformBlocksCHROMIUM(kProgramId, sizeof(buf), &size, &buf); |
| 2123 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 2123 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2124 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); | 2124 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); |
| 2125 EXPECT_EQ(sizeof(kString), static_cast<size_t>(size)); | 2125 EXPECT_EQ(sizeof(kString), static_cast<size_t>(size)); |
| 2126 EXPECT_STREQ(kString.str, buf); | 2126 EXPECT_STREQ(kString.str, buf); |
| 2127 EXPECT_EQ(buf[sizeof(kString)], kBad); | 2127 EXPECT_EQ(buf[sizeof(kString)], kBad); |
| 2128 } | 2128 } |
| 2129 | 2129 |
| 2130 TEST_F(GLES2ImplementationTest, GetUniformBlocksCHROMIUMBadArgs) { | 2130 TEST_F(GLES2ImplementationTest, GetUniformBlocksCHROMIUMBadArgs) { |
| 2131 const uint32 kBucketId = GLES2Implementation::kResultBucketId; | 2131 const uint32_t kBucketId = GLES2Implementation::kResultBucketId; |
| 2132 const GLuint kProgramId = 123; | 2132 const GLuint kProgramId = 123; |
| 2133 GLsizei size = 0; | 2133 GLsizei size = 0; |
| 2134 const Str7 kString = {"foobar"}; | 2134 const Str7 kString = {"foobar"}; |
| 2135 char buf[20]; | 2135 char buf[20]; |
| 2136 | 2136 |
| 2137 ExpectedMemoryInfo mem1 = GetExpectedMemory(MaxTransferBufferSize()); | 2137 ExpectedMemoryInfo mem1 = GetExpectedMemory(MaxTransferBufferSize()); |
| 2138 ExpectedMemoryInfo result1 = | 2138 ExpectedMemoryInfo result1 = |
| 2139 GetExpectedResultMemory(sizeof(cmd::GetBucketStart::Result)); | 2139 GetExpectedResultMemory(sizeof(cmd::GetBucketStart::Result)); |
| 2140 ExpectedMemoryInfo result2 = | 2140 ExpectedMemoryInfo result2 = |
| 2141 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); | 2141 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 2142 ExpectedMemoryInfo result3 = | 2142 ExpectedMemoryInfo result3 = |
| 2143 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); | 2143 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 2144 ExpectedMemoryInfo result4 = | 2144 ExpectedMemoryInfo result4 = |
| 2145 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); | 2145 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 2146 | 2146 |
| 2147 EXPECT_CALL(*command_buffer(), OnFlush()) | 2147 EXPECT_CALL(*command_buffer(), OnFlush()) |
| 2148 .WillOnce(DoAll(SetMemory(result1.ptr, uint32(sizeof(kString))), | 2148 .WillOnce(DoAll(SetMemory(result1.ptr, uint32_t(sizeof(kString))), |
| 2149 SetMemory(mem1.ptr, kString))) | 2149 SetMemory(mem1.ptr, kString))) |
| 2150 .WillOnce(SetMemory(result2.ptr, GLuint(GL_NO_ERROR))) | 2150 .WillOnce(SetMemory(result2.ptr, GLuint(GL_NO_ERROR))) |
| 2151 .WillOnce(SetMemory(result3.ptr, GLuint(GL_NO_ERROR))) | 2151 .WillOnce(SetMemory(result3.ptr, GLuint(GL_NO_ERROR))) |
| 2152 .WillOnce(SetMemory(result4.ptr, GLuint(GL_NO_ERROR))) | 2152 .WillOnce(SetMemory(result4.ptr, GLuint(GL_NO_ERROR))) |
| 2153 .RetiresOnSaturation(); | 2153 .RetiresOnSaturation(); |
| 2154 | 2154 |
| 2155 // try bufsize not big enough. | 2155 // try bufsize not big enough. |
| 2156 struct Cmds { | 2156 struct Cmds { |
| 2157 cmd::SetBucketSize set_bucket_size1; | 2157 cmd::SetBucketSize set_bucket_size1; |
| 2158 cmds::GetUniformBlocksCHROMIUM get_uniform_blocks; | 2158 cmds::GetUniformBlocksCHROMIUM get_uniform_blocks; |
| 2159 cmd::GetBucketStart get_bucket_start; | 2159 cmd::GetBucketStart get_bucket_start; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2297 | 2297 |
| 2298 ExpectedMemoryInfo result1 = | 2298 ExpectedMemoryInfo result1 = |
| 2299 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); | 2299 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 2300 | 2300 |
| 2301 EXPECT_CALL(*command_buffer(), OnFlush()) | 2301 EXPECT_CALL(*command_buffer(), OnFlush()) |
| 2302 .WillOnce(SetMemory(result1.ptr, GLuint(GL_NO_ERROR))) | 2302 .WillOnce(SetMemory(result1.ptr, GLuint(GL_NO_ERROR))) |
| 2303 .RetiresOnSaturation(); | 2303 .RetiresOnSaturation(); |
| 2304 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); | 2304 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); |
| 2305 } | 2305 } |
| 2306 | 2306 |
| 2307 static bool CheckRect( | 2307 static bool CheckRect(int width, |
| 2308 int width, int height, GLenum format, GLenum type, int alignment, | 2308 int height, |
| 2309 const uint8* r1, const uint8* r2) { | 2309 GLenum format, |
| 2310 uint32 size = 0; | 2310 GLenum type, |
| 2311 uint32 unpadded_row_size = 0; | 2311 int alignment, |
| 2312 uint32 padded_row_size = 0; | 2312 const uint8_t* r1, |
| 2313 const uint8_t* r2) { |
| 2314 uint32_t size = 0; |
| 2315 uint32_t unpadded_row_size = 0; |
| 2316 uint32_t padded_row_size = 0; |
| 2313 if (!GLES2Util::ComputeImageDataSizes( | 2317 if (!GLES2Util::ComputeImageDataSizes( |
| 2314 width, height, 1, format, type, alignment, &size, &unpadded_row_size, | 2318 width, height, 1, format, type, alignment, &size, &unpadded_row_size, |
| 2315 &padded_row_size)) { | 2319 &padded_row_size)) { |
| 2316 return false; | 2320 return false; |
| 2317 } | 2321 } |
| 2318 | 2322 |
| 2319 int r2_stride = static_cast<int>(padded_row_size); | 2323 int r2_stride = static_cast<int>(padded_row_size); |
| 2320 | 2324 |
| 2321 for (int y = 0; y < height; ++y) { | 2325 for (int y = 0; y < height; ++y) { |
| 2322 if (memcmp(r1, r2, unpadded_row_size) != 0) { | 2326 if (memcmp(r1, r2, unpadded_row_size) != 0) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2343 cmd::SetToken set_token; | 2347 cmd::SetToken set_token; |
| 2344 }; | 2348 }; |
| 2345 const GLenum kTarget = GL_TEXTURE_2D; | 2349 const GLenum kTarget = GL_TEXTURE_2D; |
| 2346 const GLint kLevel = 0; | 2350 const GLint kLevel = 0; |
| 2347 const GLenum kFormat = GL_RGB; | 2351 const GLenum kFormat = GL_RGB; |
| 2348 const GLsizei kWidth = 3; | 2352 const GLsizei kWidth = 3; |
| 2349 const GLsizei kHeight = 4; | 2353 const GLsizei kHeight = 4; |
| 2350 const GLint kBorder = 0; | 2354 const GLint kBorder = 0; |
| 2351 const GLenum kType = GL_UNSIGNED_BYTE; | 2355 const GLenum kType = GL_UNSIGNED_BYTE; |
| 2352 const GLint kPixelStoreUnpackAlignment = 4; | 2356 const GLint kPixelStoreUnpackAlignment = 4; |
| 2353 static uint8 pixels[] = { | 2357 static uint8_t pixels[] = { |
| 2354 11, 12, 13, 13, 14, 15, 15, 16, 17, 101, 102, 103, | 2358 11, 12, 13, 13, 14, 15, 15, 16, 17, 101, 102, 103, 21, 22, 23, |
| 2355 21, 22, 23, 23, 24, 25, 25, 26, 27, 201, 202, 203, | 2359 23, 24, 25, 25, 26, 27, 201, 202, 203, 31, 32, 33, 33, 34, 35, |
| 2356 31, 32, 33, 33, 34, 35, 35, 36, 37, 123, 124, 125, | 2360 35, 36, 37, 123, 124, 125, 41, 42, 43, 43, 44, 45, 45, 46, 47, |
| 2357 41, 42, 43, 43, 44, 45, 45, 46, 47, | |
| 2358 }; | 2361 }; |
| 2359 | 2362 |
| 2360 ExpectedMemoryInfo mem1 = GetExpectedMemory(sizeof(pixels)); | 2363 ExpectedMemoryInfo mem1 = GetExpectedMemory(sizeof(pixels)); |
| 2361 | 2364 |
| 2362 Cmds expected; | 2365 Cmds expected; |
| 2363 expected.tex_image_2d.Init( | 2366 expected.tex_image_2d.Init( |
| 2364 kTarget, kLevel, kFormat, kWidth, kHeight, kFormat, kType, | 2367 kTarget, kLevel, kFormat, kWidth, kHeight, kFormat, kType, |
| 2365 mem1.id, mem1.offset); | 2368 mem1.id, mem1.offset); |
| 2366 expected.set_token.Init(GetNextToken()); | 2369 expected.set_token.Init(GetNextToken()); |
| 2367 gl_->TexImage2D( | 2370 gl_->TexImage2D( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2384 cmd::SetToken set_token; | 2387 cmd::SetToken set_token; |
| 2385 }; | 2388 }; |
| 2386 const GLenum kTarget = GL_TEXTURE_2D; | 2389 const GLenum kTarget = GL_TEXTURE_2D; |
| 2387 const GLint kLevel = 0; | 2390 const GLint kLevel = 0; |
| 2388 const GLenum kFormat = GL_RGB; | 2391 const GLenum kFormat = GL_RGB; |
| 2389 const GLsizei kWidth = 3; | 2392 const GLsizei kWidth = 3; |
| 2390 const GLint kBorder = 0; | 2393 const GLint kBorder = 0; |
| 2391 const GLenum kType = GL_UNSIGNED_BYTE; | 2394 const GLenum kType = GL_UNSIGNED_BYTE; |
| 2392 const GLint kPixelStoreUnpackAlignment = 4; | 2395 const GLint kPixelStoreUnpackAlignment = 4; |
| 2393 | 2396 |
| 2394 uint32 size = 0; | 2397 uint32_t size = 0; |
| 2395 uint32 unpadded_row_size = 0; | 2398 uint32_t unpadded_row_size = 0; |
| 2396 uint32 padded_row_size = 0; | 2399 uint32_t padded_row_size = 0; |
| 2397 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( | 2400 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( |
| 2398 kWidth, 2, 1, kFormat, kType, kPixelStoreUnpackAlignment, | 2401 kWidth, 2, 1, kFormat, kType, kPixelStoreUnpackAlignment, |
| 2399 &size, &unpadded_row_size, &padded_row_size)); | 2402 &size, &unpadded_row_size, &padded_row_size)); |
| 2400 const GLsizei kMaxHeight = (MaxTransferBufferSize() / padded_row_size) * 2; | 2403 const GLsizei kMaxHeight = (MaxTransferBufferSize() / padded_row_size) * 2; |
| 2401 const GLsizei kHeight = kMaxHeight * 2; | 2404 const GLsizei kHeight = kMaxHeight * 2; |
| 2402 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( | 2405 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( |
| 2403 kWidth, kHeight, 1, kFormat, kType, kPixelStoreUnpackAlignment, | 2406 kWidth, kHeight, 1, kFormat, kType, kPixelStoreUnpackAlignment, |
| 2404 &size, &unpadded_row_size, &padded_row_size)); | 2407 &size, &unpadded_row_size, &padded_row_size)); |
| 2405 | 2408 |
| 2406 scoped_ptr<uint8[]> pixels(new uint8[size]); | 2409 scoped_ptr<uint8_t[]> pixels(new uint8_t[size]); |
| 2407 for (uint32 ii = 0; ii < size; ++ii) { | 2410 for (uint32_t ii = 0; ii < size; ++ii) { |
| 2408 pixels[ii] = static_cast<uint8>(ii); | 2411 pixels[ii] = static_cast<uint8_t>(ii); |
| 2409 } | 2412 } |
| 2410 | 2413 |
| 2411 ExpectedMemoryInfo mem1 = GetExpectedMappedMemory(size); | 2414 ExpectedMemoryInfo mem1 = GetExpectedMappedMemory(size); |
| 2412 | 2415 |
| 2413 Cmds expected; | 2416 Cmds expected; |
| 2414 expected.tex_image_2d.Init( | 2417 expected.tex_image_2d.Init( |
| 2415 kTarget, kLevel, kFormat, kWidth, kHeight, kFormat, kType, | 2418 kTarget, kLevel, kFormat, kWidth, kHeight, kFormat, kType, |
| 2416 mem1.id, mem1.offset); | 2419 mem1.id, mem1.offset); |
| 2417 expected.set_token.Init(GetNextToken()); | 2420 expected.set_token.Init(GetNextToken()); |
| 2418 gl_->TexImage2D( | 2421 gl_->TexImage2D( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2437 cmd::SetToken set_token2; | 2440 cmd::SetToken set_token2; |
| 2438 }; | 2441 }; |
| 2439 const GLenum kTarget = GL_TEXTURE_2D; | 2442 const GLenum kTarget = GL_TEXTURE_2D; |
| 2440 const GLint kLevel = 0; | 2443 const GLint kLevel = 0; |
| 2441 const GLenum kFormat = GL_RGB; | 2444 const GLenum kFormat = GL_RGB; |
| 2442 const GLint kBorder = 0; | 2445 const GLint kBorder = 0; |
| 2443 const GLenum kType = GL_UNSIGNED_BYTE; | 2446 const GLenum kType = GL_UNSIGNED_BYTE; |
| 2444 const GLint kPixelStoreUnpackAlignment = 4; | 2447 const GLint kPixelStoreUnpackAlignment = 4; |
| 2445 const GLsizei kWidth = 3; | 2448 const GLsizei kWidth = 3; |
| 2446 | 2449 |
| 2447 uint32 size = 0; | 2450 uint32_t size = 0; |
| 2448 uint32 unpadded_row_size = 0; | 2451 uint32_t unpadded_row_size = 0; |
| 2449 uint32 padded_row_size = 0; | 2452 uint32_t padded_row_size = 0; |
| 2450 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( | 2453 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( |
| 2451 kWidth, 2, 1, kFormat, kType, kPixelStoreUnpackAlignment, | 2454 kWidth, 2, 1, kFormat, kType, kPixelStoreUnpackAlignment, |
| 2452 &size, &unpadded_row_size, &padded_row_size)); | 2455 &size, &unpadded_row_size, &padded_row_size)); |
| 2453 const GLsizei kHeight = (MaxTransferBufferSize() / padded_row_size) * 2; | 2456 const GLsizei kHeight = (MaxTransferBufferSize() / padded_row_size) * 2; |
| 2454 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( | 2457 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( |
| 2455 kWidth, kHeight, 1, kFormat, kType, kPixelStoreUnpackAlignment, | 2458 kWidth, kHeight, 1, kFormat, kType, kPixelStoreUnpackAlignment, |
| 2456 &size, NULL, NULL)); | 2459 &size, NULL, NULL)); |
| 2457 uint32 half_size = 0; | 2460 uint32_t half_size = 0; |
| 2458 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( | 2461 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( |
| 2459 kWidth, kHeight / 2, 1, kFormat, kType, kPixelStoreUnpackAlignment, | 2462 kWidth, kHeight / 2, 1, kFormat, kType, kPixelStoreUnpackAlignment, |
| 2460 &half_size, NULL, NULL)); | 2463 &half_size, NULL, NULL)); |
| 2461 | 2464 |
| 2462 scoped_ptr<uint8[]> pixels(new uint8[size]); | 2465 scoped_ptr<uint8_t[]> pixels(new uint8_t[size]); |
| 2463 for (uint32 ii = 0; ii < size; ++ii) { | 2466 for (uint32_t ii = 0; ii < size; ++ii) { |
| 2464 pixels[ii] = static_cast<uint8>(ii); | 2467 pixels[ii] = static_cast<uint8_t>(ii); |
| 2465 } | 2468 } |
| 2466 | 2469 |
| 2467 ExpectedMemoryInfo mem1 = GetExpectedMemory(half_size); | 2470 ExpectedMemoryInfo mem1 = GetExpectedMemory(half_size); |
| 2468 ExpectedMemoryInfo mem2 = GetExpectedMemory(half_size); | 2471 ExpectedMemoryInfo mem2 = GetExpectedMemory(half_size); |
| 2469 | 2472 |
| 2470 Cmds expected; | 2473 Cmds expected; |
| 2471 expected.tex_image_2d.Init( | 2474 expected.tex_image_2d.Init( |
| 2472 kTarget, kLevel, kFormat, kWidth, kHeight, kFormat, kType, | 2475 kTarget, kLevel, kFormat, kWidth, kHeight, kFormat, kType, |
| 2473 0, 0); | 2476 0, 0); |
| 2474 expected.tex_sub_image_2d1.Init( | 2477 expected.tex_sub_image_2d1.Init( |
| 2475 kTarget, kLevel, 0, 0, kWidth, kHeight / 2, kFormat, kType, | 2478 kTarget, kLevel, 0, 0, kWidth, kHeight / 2, kFormat, kType, |
| 2476 mem1.id, mem1.offset, true); | 2479 mem1.id, mem1.offset, true); |
| 2477 expected.set_token1.Init(GetNextToken()); | 2480 expected.set_token1.Init(GetNextToken()); |
| 2478 expected.tex_sub_image_2d2.Init( | 2481 expected.tex_sub_image_2d2.Init( |
| 2479 kTarget, kLevel, 0, kHeight / 2, kWidth, kHeight / 2, kFormat, kType, | 2482 kTarget, kLevel, 0, kHeight / 2, kWidth, kHeight / 2, kFormat, kType, |
| 2480 mem2.id, mem2.offset, true); | 2483 mem2.id, mem2.offset, true); |
| 2481 expected.set_token2.Init(GetNextToken()); | 2484 expected.set_token2.Init(GetNextToken()); |
| 2482 | 2485 |
| 2483 // TODO(gman): Make it possible to run this test | 2486 // TODO(gman): Make it possible to run this test |
| 2484 // EXPECT_CALL(*command_buffer(), OnFlush()) | 2487 // EXPECT_CALL(*command_buffer(), OnFlush()) |
| 2485 // .WillOnce(CheckRectAction( | 2488 // .WillOnce(CheckRectAction( |
| 2486 // kWidth, kHeight / 2, kFormat, kType, kPixelStoreUnpackAlignment, | 2489 // kWidth, kHeight / 2, kFormat, kType, kPixelStoreUnpackAlignment, |
| 2487 // false, pixels.get(), | 2490 // false, pixels.get(), |
| 2488 // GetExpectedTransferAddressFromOffsetAs<uint8>(offset1, half_size))) | 2491 // GetExpectedTransferAddressFromOffsetAs<uint8_t>(offset1, |
| 2492 // half_size))) |
| 2489 // .RetiresOnSaturation(); | 2493 // .RetiresOnSaturation(); |
| 2490 | 2494 |
| 2491 gl_->TexImage2D( | 2495 gl_->TexImage2D( |
| 2492 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, | 2496 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, |
| 2493 pixels.get()); | 2497 pixels.get()); |
| 2494 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 2498 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2495 EXPECT_TRUE(CheckRect( | 2499 EXPECT_TRUE(CheckRect( |
| 2496 kWidth, kHeight / 2, kFormat, kType, kPixelStoreUnpackAlignment, | 2500 kWidth, kHeight / 2, kFormat, kType, kPixelStoreUnpackAlignment, |
| 2497 pixels.get() + kHeight / 2 * padded_row_size, mem2.ptr)); | 2501 pixels.get() + kHeight / 2 * padded_row_size, mem2.ptr)); |
| 2498 } | 2502 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2525 cmds::PixelStorei pixel_store_i; | 2529 cmds::PixelStorei pixel_store_i; |
| 2526 cmds::TexImage2D tex_image_2d; | 2530 cmds::TexImage2D tex_image_2d; |
| 2527 } texImageExpected; | 2531 } texImageExpected; |
| 2528 | 2532 |
| 2529 struct { | 2533 struct { |
| 2530 cmds::PixelStorei pixel_store_i; | 2534 cmds::PixelStorei pixel_store_i; |
| 2531 cmds::TexImage2D tex_image_2d; | 2535 cmds::TexImage2D tex_image_2d; |
| 2532 cmds::TexSubImage2D tex_sub_image_2d; | 2536 cmds::TexSubImage2D tex_sub_image_2d; |
| 2533 } texSubImageExpected; | 2537 } texSubImageExpected; |
| 2534 | 2538 |
| 2535 uint32 src_size; | 2539 uint32_t src_size; |
| 2536 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( | 2540 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( |
| 2537 kSrcWidth, kSrcSubImageY1, 1, kFormat, kType, 8, &src_size, NULL, NULL)); | 2541 kSrcWidth, kSrcSubImageY1, 1, kFormat, kType, 8, &src_size, NULL, NULL)); |
| 2538 scoped_ptr<uint8[]> src_pixels; | 2542 scoped_ptr<uint8_t[]> src_pixels; |
| 2539 src_pixels.reset(new uint8[src_size]); | 2543 src_pixels.reset(new uint8_t[src_size]); |
| 2540 for (size_t i = 0; i < src_size; ++i) { | 2544 for (size_t i = 0; i < src_size; ++i) { |
| 2541 src_pixels[i] = static_cast<int8>(i); | 2545 src_pixels[i] = static_cast<int8_t>(i); |
| 2542 } | 2546 } |
| 2543 | 2547 |
| 2544 for (int sub = 0; sub < 2; ++sub) { | 2548 for (int sub = 0; sub < 2; ++sub) { |
| 2545 for (size_t a = 0; a < arraysize(unpack_alignments); ++a) { | 2549 for (size_t a = 0; a < arraysize(unpack_alignments); ++a) { |
| 2546 GLint alignment = unpack_alignments[a]; | 2550 GLint alignment = unpack_alignments[a]; |
| 2547 uint32 size; | 2551 uint32_t size; |
| 2548 uint32 unpadded_row_size; | 2552 uint32_t unpadded_row_size; |
| 2549 uint32 padded_row_size; | 2553 uint32_t padded_row_size; |
| 2550 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( | 2554 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( |
| 2551 kSrcSubImageWidth, kSrcSubImageHeight, 1, kFormat, kType, alignment, | 2555 kSrcSubImageWidth, kSrcSubImageHeight, 1, kFormat, kType, alignment, |
| 2552 &size, &unpadded_row_size, &padded_row_size)); | 2556 &size, &unpadded_row_size, &padded_row_size)); |
| 2553 ASSERT_TRUE(size <= MaxTransferBufferSize()); | 2557 ASSERT_TRUE(size <= MaxTransferBufferSize()); |
| 2554 ExpectedMemoryInfo mem = GetExpectedMemory(size); | 2558 ExpectedMemoryInfo mem = GetExpectedMemory(size); |
| 2555 | 2559 |
| 2556 const void* commands = GetPut(); | 2560 const void* commands = GetPut(); |
| 2557 gl_->PixelStorei(GL_UNPACK_ALIGNMENT, alignment); | 2561 gl_->PixelStorei(GL_UNPACK_ALIGNMENT, alignment); |
| 2558 gl_->PixelStorei(GL_UNPACK_ROW_LENGTH_EXT, kSrcWidth); | 2562 gl_->PixelStorei(GL_UNPACK_ROW_LENGTH_EXT, kSrcWidth); |
| 2559 gl_->PixelStorei(GL_UNPACK_SKIP_PIXELS_EXT, kSrcSubImageX0); | 2563 gl_->PixelStorei(GL_UNPACK_SKIP_PIXELS_EXT, kSrcSubImageX0); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2582 GL_TEXTURE_2D, kLevel, kFormat, | 2586 GL_TEXTURE_2D, kLevel, kFormat, |
| 2583 kSrcSubImageWidth, kSrcSubImageHeight, kBorder, kFormat, kType, | 2587 kSrcSubImageWidth, kSrcSubImageHeight, kBorder, kFormat, kType, |
| 2584 src_pixels.get()); | 2588 src_pixels.get()); |
| 2585 texImageExpected.pixel_store_i.Init(GL_UNPACK_ALIGNMENT, alignment); | 2589 texImageExpected.pixel_store_i.Init(GL_UNPACK_ALIGNMENT, alignment); |
| 2586 texImageExpected.tex_image_2d.Init( | 2590 texImageExpected.tex_image_2d.Init( |
| 2587 GL_TEXTURE_2D, kLevel, kFormat, kSrcSubImageWidth, | 2591 GL_TEXTURE_2D, kLevel, kFormat, kSrcSubImageWidth, |
| 2588 kSrcSubImageHeight, kFormat, kType, mem.id, mem.offset); | 2592 kSrcSubImageHeight, kFormat, kType, mem.id, mem.offset); |
| 2589 EXPECT_EQ(0, memcmp( | 2593 EXPECT_EQ(0, memcmp( |
| 2590 &texImageExpected, commands, sizeof(texImageExpected))); | 2594 &texImageExpected, commands, sizeof(texImageExpected))); |
| 2591 } | 2595 } |
| 2592 uint32 src_padded_row_size; | 2596 uint32_t src_padded_row_size; |
| 2593 ASSERT_TRUE(GLES2Util::ComputeImagePaddedRowSize( | 2597 ASSERT_TRUE(GLES2Util::ComputeImagePaddedRowSize( |
| 2594 kSrcWidth, kFormat, kType, alignment, &src_padded_row_size)); | 2598 kSrcWidth, kFormat, kType, alignment, &src_padded_row_size)); |
| 2595 uint32 bytes_per_group = GLES2Util::ComputeImageGroupSize( | 2599 uint32_t bytes_per_group = |
| 2596 kFormat, kType); | 2600 GLES2Util::ComputeImageGroupSize(kFormat, kType); |
| 2597 for (int y = 0; y < kSrcSubImageHeight; ++y) { | 2601 for (int y = 0; y < kSrcSubImageHeight; ++y) { |
| 2598 const uint8* src_row = src_pixels.get() + | 2602 const uint8_t* src_row = src_pixels.get() + |
| 2599 (kSrcSubImageY0 + y) * src_padded_row_size + | 2603 (kSrcSubImageY0 + y) * src_padded_row_size + |
| 2600 bytes_per_group * kSrcSubImageX0; | 2604 bytes_per_group * kSrcSubImageX0; |
| 2601 const uint8* dst_row = mem.ptr + y * padded_row_size; | 2605 const uint8_t* dst_row = mem.ptr + y * padded_row_size; |
| 2602 EXPECT_EQ(0, memcmp(src_row, dst_row, unpadded_row_size)); | 2606 EXPECT_EQ(0, memcmp(src_row, dst_row, unpadded_row_size)); |
| 2603 } | 2607 } |
| 2604 ClearCommands(); | 2608 ClearCommands(); |
| 2605 } | 2609 } |
| 2606 } | 2610 } |
| 2607 } | 2611 } |
| 2608 | 2612 |
| 2609 // Test texture related calls with invalid arguments. | 2613 // Test texture related calls with invalid arguments. |
| 2610 TEST_F(GLES2ImplementationTest, TextureInvalidArguments) { | 2614 TEST_F(GLES2ImplementationTest, TextureInvalidArguments) { |
| 2611 struct Cmds { | 2615 struct Cmds { |
| 2612 cmds::TexImage2D tex_image_2d; | 2616 cmds::TexImage2D tex_image_2d; |
| 2613 cmd::SetToken set_token; | 2617 cmd::SetToken set_token; |
| 2614 }; | 2618 }; |
| 2615 const GLenum kTarget = GL_TEXTURE_2D; | 2619 const GLenum kTarget = GL_TEXTURE_2D; |
| 2616 const GLint kLevel = 0; | 2620 const GLint kLevel = 0; |
| 2617 const GLenum kFormat = GL_RGB; | 2621 const GLenum kFormat = GL_RGB; |
| 2618 const GLsizei kWidth = 3; | 2622 const GLsizei kWidth = 3; |
| 2619 const GLsizei kHeight = 4; | 2623 const GLsizei kHeight = 4; |
| 2620 const GLint kBorder = 0; | 2624 const GLint kBorder = 0; |
| 2621 const GLint kInvalidBorder = 1; | 2625 const GLint kInvalidBorder = 1; |
| 2622 const GLenum kType = GL_UNSIGNED_BYTE; | 2626 const GLenum kType = GL_UNSIGNED_BYTE; |
| 2623 const GLint kPixelStoreUnpackAlignment = 4; | 2627 const GLint kPixelStoreUnpackAlignment = 4; |
| 2624 static uint8 pixels[] = { | 2628 static uint8_t pixels[] = { |
| 2625 11, 12, 13, 13, 14, 15, 15, 16, 17, 101, 102, 103, | 2629 11, 12, 13, 13, 14, 15, 15, 16, 17, 101, 102, 103, 21, 22, 23, |
| 2626 21, 22, 23, 23, 24, 25, 25, 26, 27, 201, 202, 203, | 2630 23, 24, 25, 25, 26, 27, 201, 202, 203, 31, 32, 33, 33, 34, 35, |
| 2627 31, 32, 33, 33, 34, 35, 35, 36, 37, 123, 124, 125, | 2631 35, 36, 37, 123, 124, 125, 41, 42, 43, 43, 44, 45, 45, 46, 47, |
| 2628 41, 42, 43, 43, 44, 45, 45, 46, 47, | |
| 2629 }; | 2632 }; |
| 2630 | 2633 |
| 2631 // Verify that something works. | 2634 // Verify that something works. |
| 2632 | 2635 |
| 2633 ExpectedMemoryInfo mem1 = GetExpectedMemory(sizeof(pixels)); | 2636 ExpectedMemoryInfo mem1 = GetExpectedMemory(sizeof(pixels)); |
| 2634 | 2637 |
| 2635 Cmds expected; | 2638 Cmds expected; |
| 2636 expected.tex_image_2d.Init( | 2639 expected.tex_image_2d.Init( |
| 2637 kTarget, kLevel, kFormat, kWidth, kHeight, kFormat, kType, | 2640 kTarget, kLevel, kFormat, kWidth, kHeight, kFormat, kType, |
| 2638 mem1.id, mem1.offset); | 2641 mem1.id, mem1.offset); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2689 }; | 2692 }; |
| 2690 const GLenum kTarget = GL_TEXTURE_3D; | 2693 const GLenum kTarget = GL_TEXTURE_3D; |
| 2691 const GLint kLevel = 0; | 2694 const GLint kLevel = 0; |
| 2692 const GLint kBorder = 0; | 2695 const GLint kBorder = 0; |
| 2693 const GLenum kFormat = GL_RGB; | 2696 const GLenum kFormat = GL_RGB; |
| 2694 const GLenum kType = GL_UNSIGNED_BYTE; | 2697 const GLenum kType = GL_UNSIGNED_BYTE; |
| 2695 const GLint kPixelStoreUnpackAlignment = 4; | 2698 const GLint kPixelStoreUnpackAlignment = 4; |
| 2696 const GLsizei kWidth = 3; | 2699 const GLsizei kWidth = 3; |
| 2697 const GLsizei kDepth = 2; | 2700 const GLsizei kDepth = 2; |
| 2698 | 2701 |
| 2699 uint32 size = 0; | 2702 uint32_t size = 0; |
| 2700 uint32 unpadded_row_size = 0; | 2703 uint32_t unpadded_row_size = 0; |
| 2701 uint32 padded_row_size = 0; | 2704 uint32_t padded_row_size = 0; |
| 2702 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( | 2705 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( |
| 2703 kWidth, 2, kDepth, kFormat, kType, kPixelStoreUnpackAlignment, | 2706 kWidth, 2, kDepth, kFormat, kType, kPixelStoreUnpackAlignment, |
| 2704 &size, &unpadded_row_size, &padded_row_size)); | 2707 &size, &unpadded_row_size, &padded_row_size)); |
| 2705 // Makes sure we can just send over the data in one command. | 2708 // Makes sure we can just send over the data in one command. |
| 2706 const GLsizei kHeight = MaxTransferBufferSize() / padded_row_size / kDepth; | 2709 const GLsizei kHeight = MaxTransferBufferSize() / padded_row_size / kDepth; |
| 2707 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( | 2710 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( |
| 2708 kWidth, kHeight, kDepth, kFormat, kType, kPixelStoreUnpackAlignment, | 2711 kWidth, kHeight, kDepth, kFormat, kType, kPixelStoreUnpackAlignment, |
| 2709 &size, NULL, NULL)); | 2712 &size, NULL, NULL)); |
| 2710 | 2713 |
| 2711 scoped_ptr<uint8[]> pixels(new uint8[size]); | 2714 scoped_ptr<uint8_t[]> pixels(new uint8_t[size]); |
| 2712 for (uint32 ii = 0; ii < size; ++ii) { | 2715 for (uint32_t ii = 0; ii < size; ++ii) { |
| 2713 pixels[ii] = static_cast<uint8>(ii); | 2716 pixels[ii] = static_cast<uint8_t>(ii); |
| 2714 } | 2717 } |
| 2715 | 2718 |
| 2716 ExpectedMemoryInfo mem = GetExpectedMemory(size); | 2719 ExpectedMemoryInfo mem = GetExpectedMemory(size); |
| 2717 | 2720 |
| 2718 Cmds expected; | 2721 Cmds expected; |
| 2719 expected.tex_image_3d.Init( | 2722 expected.tex_image_3d.Init( |
| 2720 kTarget, kLevel, kFormat, kWidth, kHeight, kDepth, | 2723 kTarget, kLevel, kFormat, kWidth, kHeight, kDepth, |
| 2721 kFormat, kType, mem.id, mem.offset); | 2724 kFormat, kType, mem.id, mem.offset); |
| 2722 | 2725 |
| 2723 gl_->TexImage3D( | 2726 gl_->TexImage3D( |
| 2724 kTarget, kLevel, kFormat, kWidth, kHeight, kDepth, kBorder, | 2727 kTarget, kLevel, kFormat, kWidth, kHeight, kDepth, kBorder, |
| 2725 kFormat, kType, pixels.get()); | 2728 kFormat, kType, pixels.get()); |
| 2726 | 2729 |
| 2727 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 2730 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2728 EXPECT_TRUE(CheckRect( | 2731 EXPECT_TRUE(CheckRect(kWidth, kHeight * kDepth, kFormat, kType, |
| 2729 kWidth, kHeight * kDepth, kFormat, kType, kPixelStoreUnpackAlignment, | 2732 kPixelStoreUnpackAlignment, |
| 2730 reinterpret_cast<uint8*>(pixels.get()), mem.ptr)); | 2733 reinterpret_cast<uint8_t*>(pixels.get()), mem.ptr)); |
| 2731 } | 2734 } |
| 2732 | 2735 |
| 2733 TEST_F(GLES2ImplementationTest, TexImage3DViaMappedMem) { | 2736 TEST_F(GLES2ImplementationTest, TexImage3DViaMappedMem) { |
| 2734 if (!AllowExtraTransferBufferSize()) { | 2737 if (!AllowExtraTransferBufferSize()) { |
| 2735 LOG(WARNING) << "Low memory device do not support MappedMem. Skipping test"; | 2738 LOG(WARNING) << "Low memory device do not support MappedMem. Skipping test"; |
| 2736 return; | 2739 return; |
| 2737 } | 2740 } |
| 2738 | 2741 |
| 2739 struct Cmds { | 2742 struct Cmds { |
| 2740 cmds::TexImage3D tex_image_3d; | 2743 cmds::TexImage3D tex_image_3d; |
| 2741 }; | 2744 }; |
| 2742 const GLenum kTarget = GL_TEXTURE_3D; | 2745 const GLenum kTarget = GL_TEXTURE_3D; |
| 2743 const GLint kLevel = 0; | 2746 const GLint kLevel = 0; |
| 2744 const GLint kBorder = 0; | 2747 const GLint kBorder = 0; |
| 2745 const GLenum kFormat = GL_RGB; | 2748 const GLenum kFormat = GL_RGB; |
| 2746 const GLenum kType = GL_UNSIGNED_BYTE; | 2749 const GLenum kType = GL_UNSIGNED_BYTE; |
| 2747 const GLint kPixelStoreUnpackAlignment = 4; | 2750 const GLint kPixelStoreUnpackAlignment = 4; |
| 2748 const GLsizei kWidth = 3; | 2751 const GLsizei kWidth = 3; |
| 2749 const GLsizei kDepth = 2; | 2752 const GLsizei kDepth = 2; |
| 2750 | 2753 |
| 2751 uint32 size = 0; | 2754 uint32_t size = 0; |
| 2752 uint32 unpadded_row_size = 0; | 2755 uint32_t unpadded_row_size = 0; |
| 2753 uint32 padded_row_size = 0; | 2756 uint32_t padded_row_size = 0; |
| 2754 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( | 2757 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( |
| 2755 kWidth, 2, kDepth, kFormat, kType, kPixelStoreUnpackAlignment, | 2758 kWidth, 2, kDepth, kFormat, kType, kPixelStoreUnpackAlignment, |
| 2756 &size, &unpadded_row_size, &padded_row_size)); | 2759 &size, &unpadded_row_size, &padded_row_size)); |
| 2757 // Makes sure we can just send over the data in one command. | 2760 // Makes sure we can just send over the data in one command. |
| 2758 const GLsizei kMaxHeight = MaxTransferBufferSize() / padded_row_size / kDepth; | 2761 const GLsizei kMaxHeight = MaxTransferBufferSize() / padded_row_size / kDepth; |
| 2759 const GLsizei kHeight = kMaxHeight * 2; | 2762 const GLsizei kHeight = kMaxHeight * 2; |
| 2760 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( | 2763 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( |
| 2761 kWidth, kHeight, kDepth, kFormat, kType, kPixelStoreUnpackAlignment, | 2764 kWidth, kHeight, kDepth, kFormat, kType, kPixelStoreUnpackAlignment, |
| 2762 &size, NULL, NULL)); | 2765 &size, NULL, NULL)); |
| 2763 | 2766 |
| 2764 scoped_ptr<uint8[]> pixels(new uint8[size]); | 2767 scoped_ptr<uint8_t[]> pixels(new uint8_t[size]); |
| 2765 for (uint32 ii = 0; ii < size; ++ii) { | 2768 for (uint32_t ii = 0; ii < size; ++ii) { |
| 2766 pixels[ii] = static_cast<uint8>(ii); | 2769 pixels[ii] = static_cast<uint8_t>(ii); |
| 2767 } | 2770 } |
| 2768 | 2771 |
| 2769 ExpectedMemoryInfo mem = GetExpectedMappedMemory(size); | 2772 ExpectedMemoryInfo mem = GetExpectedMappedMemory(size); |
| 2770 | 2773 |
| 2771 Cmds expected; | 2774 Cmds expected; |
| 2772 expected.tex_image_3d.Init( | 2775 expected.tex_image_3d.Init( |
| 2773 kTarget, kLevel, kFormat, kWidth, kHeight, kDepth, | 2776 kTarget, kLevel, kFormat, kWidth, kHeight, kDepth, |
| 2774 kFormat, kType, mem.id, mem.offset); | 2777 kFormat, kType, mem.id, mem.offset); |
| 2775 | 2778 |
| 2776 gl_->TexImage3D( | 2779 gl_->TexImage3D( |
| 2777 kTarget, kLevel, kFormat, kWidth, kHeight, kDepth, kBorder, | 2780 kTarget, kLevel, kFormat, kWidth, kHeight, kDepth, kBorder, |
| 2778 kFormat, kType, pixels.get()); | 2781 kFormat, kType, pixels.get()); |
| 2779 | 2782 |
| 2780 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 2783 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2781 EXPECT_TRUE(CheckRect( | 2784 EXPECT_TRUE(CheckRect(kWidth, kHeight * kDepth, kFormat, kType, |
| 2782 kWidth, kHeight * kDepth, kFormat, kType, kPixelStoreUnpackAlignment, | 2785 kPixelStoreUnpackAlignment, |
| 2783 reinterpret_cast<uint8*>(pixels.get()), mem.ptr)); | 2786 reinterpret_cast<uint8_t*>(pixels.get()), mem.ptr)); |
| 2784 } | 2787 } |
| 2785 | 2788 |
| 2786 TEST_F(GLES2ImplementationTest, TexImage3DViaTexSubImage3D) { | 2789 TEST_F(GLES2ImplementationTest, TexImage3DViaTexSubImage3D) { |
| 2787 // Set limit to 1 to effectively disable mapped memory. | 2790 // Set limit to 1 to effectively disable mapped memory. |
| 2788 SetMappedMemoryLimit(1); | 2791 SetMappedMemoryLimit(1); |
| 2789 | 2792 |
| 2790 struct Cmds { | 2793 struct Cmds { |
| 2791 cmds::TexImage3D tex_image_3d; | 2794 cmds::TexImage3D tex_image_3d; |
| 2792 cmds::TexSubImage3D tex_sub_image_3d1; | 2795 cmds::TexSubImage3D tex_sub_image_3d1; |
| 2793 cmd::SetToken set_token; | 2796 cmd::SetToken set_token; |
| 2794 cmds::TexSubImage3D tex_sub_image_3d2; | 2797 cmds::TexSubImage3D tex_sub_image_3d2; |
| 2795 }; | 2798 }; |
| 2796 const GLenum kTarget = GL_TEXTURE_3D; | 2799 const GLenum kTarget = GL_TEXTURE_3D; |
| 2797 const GLint kLevel = 0; | 2800 const GLint kLevel = 0; |
| 2798 const GLint kBorder = 0; | 2801 const GLint kBorder = 0; |
| 2799 const GLenum kFormat = GL_RGB; | 2802 const GLenum kFormat = GL_RGB; |
| 2800 const GLenum kType = GL_UNSIGNED_BYTE; | 2803 const GLenum kType = GL_UNSIGNED_BYTE; |
| 2801 const GLint kPixelStoreUnpackAlignment = 4; | 2804 const GLint kPixelStoreUnpackAlignment = 4; |
| 2802 const GLsizei kWidth = 3; | 2805 const GLsizei kWidth = 3; |
| 2803 | 2806 |
| 2804 uint32 size = 0; | 2807 uint32_t size = 0; |
| 2805 uint32 unpadded_row_size = 0; | 2808 uint32_t unpadded_row_size = 0; |
| 2806 uint32 padded_row_size = 0; | 2809 uint32_t padded_row_size = 0; |
| 2807 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( | 2810 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( |
| 2808 kWidth, 2, 1, kFormat, kType, kPixelStoreUnpackAlignment, | 2811 kWidth, 2, 1, kFormat, kType, kPixelStoreUnpackAlignment, |
| 2809 &size, &unpadded_row_size, &padded_row_size)); | 2812 &size, &unpadded_row_size, &padded_row_size)); |
| 2810 // Makes sure the data is more than one command can hold. | 2813 // Makes sure the data is more than one command can hold. |
| 2811 const GLsizei kHeight = MaxTransferBufferSize() / padded_row_size + 3; | 2814 const GLsizei kHeight = MaxTransferBufferSize() / padded_row_size + 3; |
| 2812 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( | 2815 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( |
| 2813 kWidth, kHeight, 1, kFormat, kType, kPixelStoreUnpackAlignment, | 2816 kWidth, kHeight, 1, kFormat, kType, kPixelStoreUnpackAlignment, |
| 2814 &size, NULL, NULL)); | 2817 &size, NULL, NULL)); |
| 2815 uint32 first_size = padded_row_size * (kHeight - 3); | 2818 uint32_t first_size = padded_row_size * (kHeight - 3); |
| 2816 uint32 second_size = | 2819 uint32_t second_size = |
| 2817 padded_row_size * 3 - (padded_row_size - unpadded_row_size); | 2820 padded_row_size * 3 - (padded_row_size - unpadded_row_size); |
| 2818 EXPECT_EQ(size, first_size + second_size); | 2821 EXPECT_EQ(size, first_size + second_size); |
| 2819 ExpectedMemoryInfo mem1 = GetExpectedMemory(first_size); | 2822 ExpectedMemoryInfo mem1 = GetExpectedMemory(first_size); |
| 2820 ExpectedMemoryInfo mem2 = GetExpectedMemory(second_size); | 2823 ExpectedMemoryInfo mem2 = GetExpectedMemory(second_size); |
| 2821 scoped_ptr<uint8[]> pixels(new uint8[size]); | 2824 scoped_ptr<uint8_t[]> pixels(new uint8_t[size]); |
| 2822 for (uint32 ii = 0; ii < size; ++ii) { | 2825 for (uint32_t ii = 0; ii < size; ++ii) { |
| 2823 pixels[ii] = static_cast<uint8>(ii); | 2826 pixels[ii] = static_cast<uint8_t>(ii); |
| 2824 } | 2827 } |
| 2825 | 2828 |
| 2826 Cmds expected; | 2829 Cmds expected; |
| 2827 expected.tex_image_3d.Init( | 2830 expected.tex_image_3d.Init( |
| 2828 kTarget, kLevel, kFormat, kWidth, kHeight, 1, kFormat, kType, 0, 0); | 2831 kTarget, kLevel, kFormat, kWidth, kHeight, 1, kFormat, kType, 0, 0); |
| 2829 expected.tex_sub_image_3d1.Init( | 2832 expected.tex_sub_image_3d1.Init( |
| 2830 kTarget, kLevel, 0, 0, 0, kWidth, kHeight - 3, 1, kFormat, kType, | 2833 kTarget, kLevel, 0, 0, 0, kWidth, kHeight - 3, 1, kFormat, kType, |
| 2831 mem1.id, mem1.offset, GL_TRUE); | 2834 mem1.id, mem1.offset, GL_TRUE); |
| 2832 expected.tex_sub_image_3d2.Init( | 2835 expected.tex_sub_image_3d2.Init( |
| 2833 kTarget, kLevel, 0, kHeight - 3, 0, kWidth, 3, 1, kFormat, kType, | 2836 kTarget, kLevel, 0, kHeight - 3, 0, kWidth, 3, 1, kFormat, kType, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2855 const GLint kLevel = 0; | 2858 const GLint kLevel = 0; |
| 2856 const GLint kXOffset = 0; | 2859 const GLint kXOffset = 0; |
| 2857 const GLint kYOffset = 0; | 2860 const GLint kYOffset = 0; |
| 2858 const GLint kZOffset = 0; | 2861 const GLint kZOffset = 0; |
| 2859 const GLenum kFormat = GL_RGB; | 2862 const GLenum kFormat = GL_RGB; |
| 2860 const GLenum kType = GL_UNSIGNED_BYTE; | 2863 const GLenum kType = GL_UNSIGNED_BYTE; |
| 2861 const GLint kPixelStoreUnpackAlignment = 4; | 2864 const GLint kPixelStoreUnpackAlignment = 4; |
| 2862 const GLsizei kWidth = 3; | 2865 const GLsizei kWidth = 3; |
| 2863 const GLsizei kDepth = 2; | 2866 const GLsizei kDepth = 2; |
| 2864 | 2867 |
| 2865 uint32 size = 0; | 2868 uint32_t size = 0; |
| 2866 uint32 unpadded_row_size = 0; | 2869 uint32_t unpadded_row_size = 0; |
| 2867 uint32 padded_row_size = 0; | 2870 uint32_t padded_row_size = 0; |
| 2868 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( | 2871 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( |
| 2869 kWidth, 2, 1, kFormat, kType, kPixelStoreUnpackAlignment, | 2872 kWidth, 2, 1, kFormat, kType, kPixelStoreUnpackAlignment, |
| 2870 &size, &unpadded_row_size, &padded_row_size)); | 2873 &size, &unpadded_row_size, &padded_row_size)); |
| 2871 const GLsizei kHeight = MaxTransferBufferSize() / padded_row_size + 2; | 2874 const GLsizei kHeight = MaxTransferBufferSize() / padded_row_size + 2; |
| 2872 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( | 2875 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( |
| 2873 kWidth, kHeight, kDepth, kFormat, kType, kPixelStoreUnpackAlignment, | 2876 kWidth, kHeight, kDepth, kFormat, kType, kPixelStoreUnpackAlignment, |
| 2874 &size, NULL, NULL)); | 2877 &size, NULL, NULL)); |
| 2875 uint32 first_size = (kHeight - 2) * padded_row_size; | 2878 uint32_t first_size = (kHeight - 2) * padded_row_size; |
| 2876 uint32 second_size = 2 * padded_row_size; | 2879 uint32_t second_size = 2 * padded_row_size; |
| 2877 uint32 third_size = first_size; | 2880 uint32_t third_size = first_size; |
| 2878 uint32 fourth_size = second_size - (padded_row_size - unpadded_row_size); | 2881 uint32_t fourth_size = second_size - (padded_row_size - unpadded_row_size); |
| 2879 EXPECT_EQ(size, first_size + second_size + third_size + fourth_size); | 2882 EXPECT_EQ(size, first_size + second_size + third_size + fourth_size); |
| 2880 | 2883 |
| 2881 scoped_ptr<uint8[]> pixels(new uint8[size]); | 2884 scoped_ptr<uint8_t[]> pixels(new uint8_t[size]); |
| 2882 for (uint32 ii = 0; ii < size; ++ii) { | 2885 for (uint32_t ii = 0; ii < size; ++ii) { |
| 2883 pixels[ii] = static_cast<uint8>(ii); | 2886 pixels[ii] = static_cast<uint8_t>(ii); |
| 2884 } | 2887 } |
| 2885 | 2888 |
| 2886 ExpectedMemoryInfo mem1_1 = GetExpectedMemory(first_size); | 2889 ExpectedMemoryInfo mem1_1 = GetExpectedMemory(first_size); |
| 2887 ExpectedMemoryInfo mem1_2 = GetExpectedMemory(second_size); | 2890 ExpectedMemoryInfo mem1_2 = GetExpectedMemory(second_size); |
| 2888 ExpectedMemoryInfo mem2_1 = GetExpectedMemory(third_size); | 2891 ExpectedMemoryInfo mem2_1 = GetExpectedMemory(third_size); |
| 2889 ExpectedMemoryInfo mem2_2 = GetExpectedMemory(fourth_size); | 2892 ExpectedMemoryInfo mem2_2 = GetExpectedMemory(fourth_size); |
| 2890 | 2893 |
| 2891 Cmds expected; | 2894 Cmds expected; |
| 2892 expected.tex_sub_image_3d1_1.Init( | 2895 expected.tex_sub_image_3d1_1.Init( |
| 2893 kTarget, kLevel, kXOffset, kYOffset, kZOffset, | 2896 kTarget, kLevel, kXOffset, kYOffset, kZOffset, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2905 kWidth, 2, 1, kFormat, kType, mem2_2.id, mem2_2.offset, GL_FALSE); | 2908 kWidth, 2, 1, kFormat, kType, mem2_2.id, mem2_2.offset, GL_FALSE); |
| 2906 expected.set_token1.Init(GetNextToken()); | 2909 expected.set_token1.Init(GetNextToken()); |
| 2907 expected.set_token2.Init(GetNextToken()); | 2910 expected.set_token2.Init(GetNextToken()); |
| 2908 expected.set_token3.Init(GetNextToken()); | 2911 expected.set_token3.Init(GetNextToken()); |
| 2909 | 2912 |
| 2910 gl_->TexSubImage3D( | 2913 gl_->TexSubImage3D( |
| 2911 kTarget, kLevel, kXOffset, kYOffset, kZOffset, kWidth, kHeight, kDepth, | 2914 kTarget, kLevel, kXOffset, kYOffset, kZOffset, kWidth, kHeight, kDepth, |
| 2912 kFormat, kType, pixels.get()); | 2915 kFormat, kType, pixels.get()); |
| 2913 | 2916 |
| 2914 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 2917 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2915 uint32 offset_to_last = first_size + second_size + third_size; | 2918 uint32_t offset_to_last = first_size + second_size + third_size; |
| 2916 EXPECT_TRUE(CheckRect( | 2919 EXPECT_TRUE(CheckRect( |
| 2917 kWidth, 2, kFormat, kType, kPixelStoreUnpackAlignment, | 2920 kWidth, 2, kFormat, kType, kPixelStoreUnpackAlignment, |
| 2918 reinterpret_cast<uint8*>(pixels.get()) + offset_to_last, mem2_2.ptr)); | 2921 reinterpret_cast<uint8_t*>(pixels.get()) + offset_to_last, mem2_2.ptr)); |
| 2919 } | 2922 } |
| 2920 | 2923 |
| 2921 // glGen* Ids must not be reused until glDelete* commands have been | 2924 // glGen* Ids must not be reused until glDelete* commands have been |
| 2922 // flushed by glFlush. | 2925 // flushed by glFlush. |
| 2923 TEST_F(GLES2ImplementationStrictSharedTest, FlushGenerationTestBuffers) { | 2926 TEST_F(GLES2ImplementationStrictSharedTest, FlushGenerationTestBuffers) { |
| 2924 FlushGenerationTest<GenBuffersAPI>(); | 2927 FlushGenerationTest<GenBuffersAPI>(); |
| 2925 } | 2928 } |
| 2926 TEST_F(GLES2ImplementationStrictSharedTest, FlushGenerationTestFramebuffers) { | 2929 TEST_F(GLES2ImplementationStrictSharedTest, FlushGenerationTestFramebuffers) { |
| 2927 FlushGenerationTest<GenFramebuffersAPI>(); | 2930 FlushGenerationTest<GenFramebuffersAPI>(); |
| 2928 } | 2931 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2964 TEST_F(GLES2ImplementationStrictSharedTest, | 2967 TEST_F(GLES2ImplementationStrictSharedTest, |
| 2965 CrossContextGenerationAutoFlushTestRenderbuffers) { | 2968 CrossContextGenerationAutoFlushTestRenderbuffers) { |
| 2966 CrossContextGenerationAutoFlushTest<GenRenderbuffersAPI>(); | 2969 CrossContextGenerationAutoFlushTest<GenRenderbuffersAPI>(); |
| 2967 } | 2970 } |
| 2968 TEST_F(GLES2ImplementationStrictSharedTest, | 2971 TEST_F(GLES2ImplementationStrictSharedTest, |
| 2969 CrossContextGenerationAutoFlushTestTextures) { | 2972 CrossContextGenerationAutoFlushTestTextures) { |
| 2970 CrossContextGenerationAutoFlushTest<GenTexturesAPI>(); | 2973 CrossContextGenerationAutoFlushTest<GenTexturesAPI>(); |
| 2971 } | 2974 } |
| 2972 | 2975 |
| 2973 TEST_F(GLES2ImplementationTest, GetString) { | 2976 TEST_F(GLES2ImplementationTest, GetString) { |
| 2974 const uint32 kBucketId = GLES2Implementation::kResultBucketId; | 2977 const uint32_t kBucketId = GLES2Implementation::kResultBucketId; |
| 2975 const Str7 kString = {"foobar"}; | 2978 const Str7 kString = {"foobar"}; |
| 2976 // GL_CHROMIUM_map_sub is hard coded into GLES2Implementation. | 2979 // GL_CHROMIUM_map_sub is hard coded into GLES2Implementation. |
| 2977 const char* expected_str = | 2980 const char* expected_str = |
| 2978 "foobar " | 2981 "foobar " |
| 2979 "GL_EXT_unpack_subimage " | 2982 "GL_EXT_unpack_subimage " |
| 2980 "GL_CHROMIUM_map_sub"; | 2983 "GL_CHROMIUM_map_sub"; |
| 2981 const char kBad = 0x12; | 2984 const char kBad = 0x12; |
| 2982 struct Cmds { | 2985 struct Cmds { |
| 2983 cmd::SetBucketSize set_bucket_size1; | 2986 cmd::SetBucketSize set_bucket_size1; |
| 2984 cmds::GetString get_string; | 2987 cmds::GetString get_string; |
| 2985 cmd::GetBucketStart get_bucket_start; | 2988 cmd::GetBucketStart get_bucket_start; |
| 2986 cmd::SetToken set_token1; | 2989 cmd::SetToken set_token1; |
| 2987 cmd::SetBucketSize set_bucket_size2; | 2990 cmd::SetBucketSize set_bucket_size2; |
| 2988 }; | 2991 }; |
| 2989 ExpectedMemoryInfo mem1 = GetExpectedMemory(MaxTransferBufferSize()); | 2992 ExpectedMemoryInfo mem1 = GetExpectedMemory(MaxTransferBufferSize()); |
| 2990 ExpectedMemoryInfo result1 = | 2993 ExpectedMemoryInfo result1 = |
| 2991 GetExpectedResultMemory(sizeof(cmd::GetBucketStart::Result)); | 2994 GetExpectedResultMemory(sizeof(cmd::GetBucketStart::Result)); |
| 2992 Cmds expected; | 2995 Cmds expected; |
| 2993 expected.set_bucket_size1.Init(kBucketId, 0); | 2996 expected.set_bucket_size1.Init(kBucketId, 0); |
| 2994 expected.get_string.Init(GL_EXTENSIONS, kBucketId); | 2997 expected.get_string.Init(GL_EXTENSIONS, kBucketId); |
| 2995 expected.get_bucket_start.Init( | 2998 expected.get_bucket_start.Init( |
| 2996 kBucketId, result1.id, result1.offset, | 2999 kBucketId, result1.id, result1.offset, |
| 2997 MaxTransferBufferSize(), mem1.id, mem1.offset); | 3000 MaxTransferBufferSize(), mem1.id, mem1.offset); |
| 2998 expected.set_token1.Init(GetNextToken()); | 3001 expected.set_token1.Init(GetNextToken()); |
| 2999 expected.set_bucket_size2.Init(kBucketId, 0); | 3002 expected.set_bucket_size2.Init(kBucketId, 0); |
| 3000 char buf[sizeof(kString) + 1]; | 3003 char buf[sizeof(kString) + 1]; |
| 3001 memset(buf, kBad, sizeof(buf)); | 3004 memset(buf, kBad, sizeof(buf)); |
| 3002 | 3005 |
| 3003 EXPECT_CALL(*command_buffer(), OnFlush()) | 3006 EXPECT_CALL(*command_buffer(), OnFlush()) |
| 3004 .WillOnce(DoAll(SetMemory(result1.ptr, uint32(sizeof(kString))), | 3007 .WillOnce(DoAll(SetMemory(result1.ptr, uint32_t(sizeof(kString))), |
| 3005 SetMemory(mem1.ptr, kString))) | 3008 SetMemory(mem1.ptr, kString))) |
| 3006 .RetiresOnSaturation(); | 3009 .RetiresOnSaturation(); |
| 3007 | 3010 |
| 3008 const GLubyte* result = gl_->GetString(GL_EXTENSIONS); | 3011 const GLubyte* result = gl_->GetString(GL_EXTENSIONS); |
| 3009 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 3012 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 3010 EXPECT_STREQ(expected_str, reinterpret_cast<const char*>(result)); | 3013 EXPECT_STREQ(expected_str, reinterpret_cast<const char*>(result)); |
| 3011 } | 3014 } |
| 3012 | 3015 |
| 3013 TEST_F(GLES2ImplementationTest, PixelStoreiGLPackReverseRowOrderANGLE) { | 3016 TEST_F(GLES2ImplementationTest, PixelStoreiGLPackReverseRowOrderANGLE) { |
| 3014 const uint32 kBucketId = GLES2Implementation::kResultBucketId; | 3017 const uint32_t kBucketId = GLES2Implementation::kResultBucketId; |
| 3015 const Str7 kString = {"foobar"}; | 3018 const Str7 kString = {"foobar"}; |
| 3016 struct Cmds { | 3019 struct Cmds { |
| 3017 cmd::SetBucketSize set_bucket_size1; | 3020 cmd::SetBucketSize set_bucket_size1; |
| 3018 cmds::GetString get_string; | 3021 cmds::GetString get_string; |
| 3019 cmd::GetBucketStart get_bucket_start; | 3022 cmd::GetBucketStart get_bucket_start; |
| 3020 cmd::SetToken set_token1; | 3023 cmd::SetToken set_token1; |
| 3021 cmd::SetBucketSize set_bucket_size2; | 3024 cmd::SetBucketSize set_bucket_size2; |
| 3022 cmds::PixelStorei pixel_store; | 3025 cmds::PixelStorei pixel_store; |
| 3023 }; | 3026 }; |
| 3024 | 3027 |
| 3025 ExpectedMemoryInfo mem1 = GetExpectedMemory(MaxTransferBufferSize()); | 3028 ExpectedMemoryInfo mem1 = GetExpectedMemory(MaxTransferBufferSize()); |
| 3026 ExpectedMemoryInfo result1 = | 3029 ExpectedMemoryInfo result1 = |
| 3027 GetExpectedResultMemory(sizeof(cmd::GetBucketStart::Result)); | 3030 GetExpectedResultMemory(sizeof(cmd::GetBucketStart::Result)); |
| 3028 | 3031 |
| 3029 Cmds expected; | 3032 Cmds expected; |
| 3030 expected.set_bucket_size1.Init(kBucketId, 0); | 3033 expected.set_bucket_size1.Init(kBucketId, 0); |
| 3031 expected.get_string.Init(GL_EXTENSIONS, kBucketId); | 3034 expected.get_string.Init(GL_EXTENSIONS, kBucketId); |
| 3032 expected.get_bucket_start.Init( | 3035 expected.get_bucket_start.Init( |
| 3033 kBucketId, result1.id, result1.offset, | 3036 kBucketId, result1.id, result1.offset, |
| 3034 MaxTransferBufferSize(), mem1.id, mem1.offset); | 3037 MaxTransferBufferSize(), mem1.id, mem1.offset); |
| 3035 expected.set_token1.Init(GetNextToken()); | 3038 expected.set_token1.Init(GetNextToken()); |
| 3036 expected.set_bucket_size2.Init(kBucketId, 0); | 3039 expected.set_bucket_size2.Init(kBucketId, 0); |
| 3037 expected.pixel_store.Init(GL_PACK_REVERSE_ROW_ORDER_ANGLE, 1); | 3040 expected.pixel_store.Init(GL_PACK_REVERSE_ROW_ORDER_ANGLE, 1); |
| 3038 | 3041 |
| 3039 EXPECT_CALL(*command_buffer(), OnFlush()) | 3042 EXPECT_CALL(*command_buffer(), OnFlush()) |
| 3040 .WillOnce(DoAll(SetMemory(result1.ptr, uint32(sizeof(kString))), | 3043 .WillOnce(DoAll(SetMemory(result1.ptr, uint32_t(sizeof(kString))), |
| 3041 SetMemory(mem1.ptr, kString))) | 3044 SetMemory(mem1.ptr, kString))) |
| 3042 .RetiresOnSaturation(); | 3045 .RetiresOnSaturation(); |
| 3043 | 3046 |
| 3044 gl_->PixelStorei(GL_PACK_REVERSE_ROW_ORDER_ANGLE, 1); | 3047 gl_->PixelStorei(GL_PACK_REVERSE_ROW_ORDER_ANGLE, 1); |
| 3045 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 3048 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 3046 } | 3049 } |
| 3047 | 3050 |
| 3048 TEST_F(GLES2ImplementationTest, CreateProgram) { | 3051 TEST_F(GLES2ImplementationTest, CreateProgram) { |
| 3049 struct Cmds { | 3052 struct Cmds { |
| 3050 cmds::CreateProgram cmd; | 3053 cmds::CreateProgram cmd; |
| 3051 }; | 3054 }; |
| 3052 | 3055 |
| 3053 Cmds expected; | 3056 Cmds expected; |
| 3054 expected.cmd.Init(kProgramsAndShadersStartId); | 3057 expected.cmd.Init(kProgramsAndShadersStartId); |
| 3055 GLuint id = gl_->CreateProgram(); | 3058 GLuint id = gl_->CreateProgram(); |
| 3056 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 3059 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 3057 EXPECT_EQ(kProgramsAndShadersStartId, id); | 3060 EXPECT_EQ(kProgramsAndShadersStartId, id); |
| 3058 } | 3061 } |
| 3059 | 3062 |
| 3060 TEST_F(GLES2ImplementationTest, BufferDataLargerThanTransferBuffer) { | 3063 TEST_F(GLES2ImplementationTest, BufferDataLargerThanTransferBuffer) { |
| 3061 struct Cmds { | 3064 struct Cmds { |
| 3062 cmds::BufferData set_size; | 3065 cmds::BufferData set_size; |
| 3063 cmds::BufferSubData copy_data1; | 3066 cmds::BufferSubData copy_data1; |
| 3064 cmd::SetToken set_token1; | 3067 cmd::SetToken set_token1; |
| 3065 cmds::BufferSubData copy_data2; | 3068 cmds::BufferSubData copy_data2; |
| 3066 cmd::SetToken set_token2; | 3069 cmd::SetToken set_token2; |
| 3067 }; | 3070 }; |
| 3068 const unsigned kUsableSize = | 3071 const unsigned kUsableSize = |
| 3069 kTransferBufferSize - GLES2Implementation::kStartingOffset; | 3072 kTransferBufferSize - GLES2Implementation::kStartingOffset; |
| 3070 uint8 buf[kUsableSize * 2] = { 0, }; | 3073 uint8_t buf[kUsableSize * 2] = { |
| 3074 0, |
| 3075 }; |
| 3071 | 3076 |
| 3072 ExpectedMemoryInfo mem1 = GetExpectedMemory(kUsableSize); | 3077 ExpectedMemoryInfo mem1 = GetExpectedMemory(kUsableSize); |
| 3073 ExpectedMemoryInfo mem2 = GetExpectedMemory(kUsableSize); | 3078 ExpectedMemoryInfo mem2 = GetExpectedMemory(kUsableSize); |
| 3074 | 3079 |
| 3075 Cmds expected; | 3080 Cmds expected; |
| 3076 expected.set_size.Init( | 3081 expected.set_size.Init( |
| 3077 GL_ARRAY_BUFFER, arraysize(buf), 0, 0, GL_DYNAMIC_DRAW); | 3082 GL_ARRAY_BUFFER, arraysize(buf), 0, 0, GL_DYNAMIC_DRAW); |
| 3078 expected.copy_data1.Init( | 3083 expected.copy_data1.Init( |
| 3079 GL_ARRAY_BUFFER, 0, kUsableSize, mem1.id, mem1.offset); | 3084 GL_ARRAY_BUFFER, 0, kUsableSize, mem1.id, mem1.offset); |
| 3080 expected.set_token1.Init(GetNextToken()); | 3085 expected.set_token1.Init(GetNextToken()); |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3582 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 3587 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 3583 } | 3588 } |
| 3584 | 3589 |
| 3585 TEST_F(GLES2ImplementationTest, LimitSizeAndOffsetTo32Bit) { | 3590 TEST_F(GLES2ImplementationTest, LimitSizeAndOffsetTo32Bit) { |
| 3586 GLsizeiptr size; | 3591 GLsizeiptr size; |
| 3587 GLintptr offset; | 3592 GLintptr offset; |
| 3588 if (sizeof(size) <= 4 || sizeof(offset) <= 4) | 3593 if (sizeof(size) <= 4 || sizeof(offset) <= 4) |
| 3589 return; | 3594 return; |
| 3590 // The below two casts should be no-op, as we return early if | 3595 // The below two casts should be no-op, as we return early if |
| 3591 // it's 32-bit system. | 3596 // it's 32-bit system. |
| 3592 int64 value64 = 0x100000000; | 3597 int64_t value64 = 0x100000000; |
| 3593 size = static_cast<GLsizeiptr>(value64); | 3598 size = static_cast<GLsizeiptr>(value64); |
| 3594 offset = static_cast<GLintptr>(value64); | 3599 offset = static_cast<GLintptr>(value64); |
| 3595 | 3600 |
| 3596 const char kSizeOverflowMessage[] = "size more than 32-bit"; | 3601 const char kSizeOverflowMessage[] = "size more than 32-bit"; |
| 3597 const char kOffsetOverflowMessage[] = "offset more than 32-bit"; | 3602 const char kOffsetOverflowMessage[] = "offset more than 32-bit"; |
| 3598 | 3603 |
| 3599 const GLfloat buf[] = { 1.0, 1.0, 1.0, 1.0 }; | 3604 const GLfloat buf[] = { 1.0, 1.0, 1.0, 1.0 }; |
| 3600 const GLubyte indices[] = { 0 }; | 3605 const GLubyte indices[] = { 0 }; |
| 3601 | 3606 |
| 3602 const GLuint kClientArrayBufferId = 0x789; | 3607 const GLuint kClientArrayBufferId = 0x789; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3680 | 3685 |
| 3681 // VertexAttribPointer: offset | 3686 // VertexAttribPointer: offset |
| 3682 gl_->VertexAttribPointer( | 3687 gl_->VertexAttribPointer( |
| 3683 kAttribIndex, 1, GL_FLOAT, GL_FALSE, kStride, | 3688 kAttribIndex, 1, GL_FLOAT, GL_FALSE, kStride, |
| 3684 reinterpret_cast<void*>(offset)); | 3689 reinterpret_cast<void*>(offset)); |
| 3685 EXPECT_EQ(GL_INVALID_OPERATION, CheckError()); | 3690 EXPECT_EQ(GL_INVALID_OPERATION, CheckError()); |
| 3686 EXPECT_STREQ(kOffsetOverflowMessage, GetLastError().c_str()); | 3691 EXPECT_STREQ(kOffsetOverflowMessage, GetLastError().c_str()); |
| 3687 } | 3692 } |
| 3688 | 3693 |
| 3689 TEST_F(GLES2ImplementationTest, TraceBeginCHROMIUM) { | 3694 TEST_F(GLES2ImplementationTest, TraceBeginCHROMIUM) { |
| 3690 const uint32 kCategoryBucketId = GLES2Implementation::kResultBucketId; | 3695 const uint32_t kCategoryBucketId = GLES2Implementation::kResultBucketId; |
| 3691 const uint32 kNameBucketId = GLES2Implementation::kResultBucketId + 1; | 3696 const uint32_t kNameBucketId = GLES2Implementation::kResultBucketId + 1; |
| 3692 const std::string category_name = "test category"; | 3697 const std::string category_name = "test category"; |
| 3693 const std::string trace_name = "test trace"; | 3698 const std::string trace_name = "test trace"; |
| 3694 const size_t kPaddedString1Size = | 3699 const size_t kPaddedString1Size = |
| 3695 transfer_buffer_->RoundToAlignment(category_name.size() + 1); | 3700 transfer_buffer_->RoundToAlignment(category_name.size() + 1); |
| 3696 const size_t kPaddedString2Size = | 3701 const size_t kPaddedString2Size = |
| 3697 transfer_buffer_->RoundToAlignment(trace_name.size() + 1); | 3702 transfer_buffer_->RoundToAlignment(trace_name.size() + 1); |
| 3698 | 3703 |
| 3699 gl_->TraceBeginCHROMIUM(category_name.c_str(), trace_name.c_str()); | 3704 gl_->TraceBeginCHROMIUM(category_name.c_str(), trace_name.c_str()); |
| 3700 EXPECT_EQ(GL_NO_ERROR, CheckError()); | 3705 EXPECT_EQ(GL_NO_ERROR, CheckError()); |
| 3701 | 3706 |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4249 init_options.bind_generates_resource_service = false; | 4254 init_options.bind_generates_resource_service = false; |
| 4250 EXPECT_FALSE(Initialize(init_options)); | 4255 EXPECT_FALSE(Initialize(init_options)); |
| 4251 } | 4256 } |
| 4252 | 4257 |
| 4253 TEST_F(GLES2ImplementationManualInitTest, FailInitOnTransferBufferFail) { | 4258 TEST_F(GLES2ImplementationManualInitTest, FailInitOnTransferBufferFail) { |
| 4254 ContextInitOptions init_options; | 4259 ContextInitOptions init_options; |
| 4255 init_options.transfer_buffer_initialize_fail = true; | 4260 init_options.transfer_buffer_initialize_fail = true; |
| 4256 EXPECT_FALSE(Initialize(init_options)); | 4261 EXPECT_FALSE(Initialize(init_options)); |
| 4257 } | 4262 } |
| 4258 | 4263 |
| 4264 #include "base/macros.h" |
| 4259 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" | 4265 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" |
| 4260 | 4266 |
| 4261 } // namespace gles2 | 4267 } // namespace gles2 |
| 4262 } // namespace gpu | 4268 } // namespace gpu |
| OLD | NEW |