Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: gpu/command_buffer/client/gles2_implementation_unittest.cc

Issue 8587040: Fix for GL_CHROMIUM_flipy in TexSubImage2D (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Tests for the Command Buffer Helper. 5 // Tests for the Command Buffer Helper.
6 6
7 #include "gpu/command_buffer/client/gles2_implementation.h" 7 #include "gpu/command_buffer/client/gles2_implementation.h"
8 8
9 #include <GLES2/gl2ext.h> 9 #include <GLES2/gl2ext.h>
10 #include "gpu/command_buffer/common/command_buffer.h" 10 #include "gpu/command_buffer/common/command_buffer.h"
(...skipping 1737 matching lines...) Expand 10 before | Expand all | Expand 10 after
1748 gl_->TexImage2D( 1748 gl_->TexImage2D(
1749 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, 1749 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType,
1750 pixels.get()); 1750 pixels.get());
1751 EXPECT_EQ(0, memcmp(&expected, commands2, sizeof(expected))); 1751 EXPECT_EQ(0, memcmp(&expected, commands2, sizeof(expected)));
1752 EXPECT_TRUE(CheckRect( 1752 EXPECT_TRUE(CheckRect(
1753 kWidth / 2, 1, kFormat, kType, kPixelStoreUnpackAlignment, false, 1753 kWidth / 2, 1, kFormat, kType, kPixelStoreUnpackAlignment, false,
1754 pixels.get() + padded_row_size + part_size, 1754 pixels.get() + padded_row_size + part_size,
1755 GetTransferAddressFromOffsetAs<uint8>(offset4, part_size))); 1755 GetTransferAddressFromOffsetAs<uint8>(offset4, part_size)));
1756 } 1756 }
1757 1757
1758 // Test TexSubImage2D with GL_PACK_FLIP_Y set and partial multirow transfers
1759 TEST_F(GLES2ImplementationTest, TexSubImage2DFlipY) {
1760 const GLsizei kTextureWidth = MaxTransferBufferSize() / 4;
1761 const GLsizei kTextureHeight = 7;
1762 const GLsizei kSubImageWidth = MaxTransferBufferSize() / 8;
1763 const GLsizei kSubImageHeight = 4;
1764 const GLint kSubImageXOffset = 1;
1765 const GLint kSubImageYOffset = 2;
1766 const GLenum kFormat = GL_RGBA;
1767 const GLenum kType = GL_UNSIGNED_BYTE;
1768 const GLenum kTarget = GL_TEXTURE_2D;
1769 const GLint kLevel = 0;
1770 const GLint kBorder = 0;
1771 const GLint kPixelStoreUnpackAlignment = 4;
1772
1773 struct Cmds {
1774 PixelStorei pixel_store_i1;
1775 TexImage2D tex_image_2d;
1776 TexSubImage2D tex_sub_image_2d1;
1777 cmd::SetToken set_token1;
1778 TexSubImage2D tex_sub_image_2d2;
1779 cmd::SetToken set_token2;
1780 };
1781
1782 uint32 sub_2_high_size = 0;
1783 ASSERT_TRUE(GLES2Util::ComputeImageDataSize(
1784 kSubImageWidth, 2, kFormat, kType, kPixelStoreUnpackAlignment,
1785 &sub_2_high_size));
1786 uint32 offset1 = AllocateTransferBuffer(sub_2_high_size);
1787 uint32 offset2 = AllocateTransferBuffer(sub_2_high_size);
1788
1789 Cmds expected;
1790 expected.pixel_store_i1.Init(GL_UNPACK_ALIGNMENT, kPixelStoreUnpackAlignment);
1791 expected.tex_image_2d.Init(
1792 kTarget, kLevel, kFormat, kTextureWidth, kTextureHeight, kBorder, kFormat,
1793 kType, 0, NULL);
1794 expected.tex_sub_image_2d1.Init(kTarget, kLevel, kSubImageXOffset,
1795 kSubImageYOffset + 2, kSubImageWidth, 2, kFormat, kType,
1796 kTransferBufferId, offset1, false);
1797 expected.set_token1.Init(GetNextToken());
1798 expected.tex_sub_image_2d2.Init(kTarget, kLevel, kSubImageXOffset,
1799 kSubImageYOffset, kSubImageWidth , 2, kFormat, kType, kTransferBufferId,
1800 offset2, false);
1801 expected.set_token2.Init(GetNextToken());
1802
1803 gl_->PixelStorei(GL_UNPACK_ALIGNMENT, kPixelStoreUnpackAlignment);
1804 gl_->TexImage2D(
1805 kTarget, kLevel, kFormat, kTextureWidth, kTextureHeight, kBorder, kFormat,
1806 kType, NULL);
1807 // this call should not emit commands (handled client-side)
1808 gl_->PixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE);
1809 scoped_array<uint32> pixels(new uint32[kSubImageWidth * kSubImageHeight]);
1810 for (int y = 0; y < kSubImageHeight; ++y) {
1811 for (int x = 0; x < kSubImageWidth; ++x) {
1812 pixels.get()[kSubImageWidth * y + x] = x | (y << 16);
1813 }
1814 }
1815 gl_->TexSubImage2D(
1816 GL_TEXTURE_2D, 0, kSubImageXOffset, kSubImageYOffset, kSubImageWidth,
1817 kSubImageHeight, GL_RGBA, GL_UNSIGNED_BYTE, pixels.get());
1818
1819 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1820 EXPECT_TRUE(CheckRect(
1821 kSubImageWidth, 2, kFormat, kType, kPixelStoreUnpackAlignment, true,
1822 reinterpret_cast<uint8*>(pixels.get() + 2 * kSubImageWidth),
1823 GetTransferAddressFromOffsetAs<uint8>(offset2, sub_2_high_size)));
1824 }
1825
1758 // Test that GenBuffer does not call GenSharedIds. 1826 // Test that GenBuffer does not call GenSharedIds.
1759 // This is because with client side arrays on we know the StrictSharedIdHandler 1827 // This is because with client side arrays on we know the StrictSharedIdHandler
1760 // for buffers has already gotten a set of ids 1828 // for buffers has already gotten a set of ids
1761 TEST_F(GLES2ImplementationStrictSharedTest, GenBuffer) { 1829 TEST_F(GLES2ImplementationStrictSharedTest, GenBuffer) {
1762 // Starts at + 2 because client side arrays take first 2 ids. 1830 // Starts at + 2 because client side arrays take first 2 ids.
1763 GLuint ids[3] = { kStartId + 2, kStartId + 3, kStartId + 4 }; 1831 GLuint ids[3] = { kStartId + 2, kStartId + 3, kStartId + 4 };
1764 struct Cmds { 1832 struct Cmds {
1765 GenBuffersImmediate gen; 1833 GenBuffersImmediate gen;
1766 GLuint data[3]; 1834 GLuint data[3];
1767 }; 1835 };
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1861 expected.destroy_stream.Init(kTextureHandle); 1929 expected.destroy_stream.Init(kTextureHandle);
1862 1930
1863 gl_->DestroyStreamTextureCHROMIUM(kTextureHandle); 1931 gl_->DestroyStreamTextureCHROMIUM(kTextureHandle);
1864 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); 1932 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1865 } 1933 }
1866 1934
1867 } // namespace gles2 1935 } // namespace gles2
1868 } // namespace gpu 1936 } // namespace gpu
1869 1937
1870 1938
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698