OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include <GLES2/gl2.h> | 5 #include <GLES2/gl2.h> |
6 #include <GLES2/gl2ext.h> | 6 #include <GLES2/gl2ext.h> |
| 7 #include <stdint.h> |
7 | 8 |
8 #include "gpu/command_buffer/tests/gl_manager.h" | 9 #include "gpu/command_buffer/tests/gl_manager.h" |
9 #include "gpu/command_buffer/tests/gl_test_utils.h" | 10 #include "gpu/command_buffer/tests/gl_test_utils.h" |
10 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
12 | 13 |
13 namespace gpu { | 14 namespace gpu { |
14 | 15 |
15 class TextureStorageTest : public testing::Test { | 16 class TextureStorageTest : public testing::Test { |
16 protected: | 17 protected: |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 if (!extension_available_) | 50 if (!extension_available_) |
50 return; | 51 return; |
51 | 52 |
52 glTexStorage2DEXT(GL_TEXTURE_2D, 2, GL_RGBA8_OES, 2, 2); | 53 glTexStorage2DEXT(GL_TEXTURE_2D, 2, GL_RGBA8_OES, 2, 2); |
53 | 54 |
54 // Mesa dirvers crash without rebinding to FBO. It's why | 55 // Mesa dirvers crash without rebinding to FBO. It's why |
55 // DISABLE_TEXTURE_STORAGE workaround is introduced. crbug.com/521904 | 56 // DISABLE_TEXTURE_STORAGE workaround is introduced. crbug.com/521904 |
56 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, | 57 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
57 tex_, 0); | 58 tex_, 0); |
58 | 59 |
59 uint8 source_pixels[16] = { | 60 uint8_t source_pixels[16] = {1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4}; |
60 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4 | |
61 }; | |
62 glTexSubImage2D(GL_TEXTURE_2D, | 61 glTexSubImage2D(GL_TEXTURE_2D, |
63 0, | 62 0, |
64 0, 0, | 63 0, 0, |
65 2, 2, | 64 2, 2, |
66 GL_RGBA, GL_UNSIGNED_BYTE, | 65 GL_RGBA, GL_UNSIGNED_BYTE, |
67 source_pixels); | 66 source_pixels); |
68 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 2, 2, 0, source_pixels)); | 67 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 2, 2, 0, source_pixels)); |
69 } | 68 } |
70 | 69 |
71 TEST_F(TextureStorageTest, IsImmutable) { | 70 TEST_F(TextureStorageTest, IsImmutable) { |
72 if (!extension_available_) | 71 if (!extension_available_) |
73 return; | 72 return; |
74 | 73 |
75 glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8_OES, 4, 4); | 74 glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8_OES, 4, 4); |
76 | 75 |
77 GLint param = 0; | 76 GLint param = 0; |
78 glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_IMMUTABLE_FORMAT_EXT, ¶m); | 77 glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_IMMUTABLE_FORMAT_EXT, ¶m); |
79 EXPECT_TRUE(param); | 78 EXPECT_TRUE(param); |
80 } | 79 } |
81 | 80 |
82 TEST_F(TextureStorageTest, OneLevel) { | 81 TEST_F(TextureStorageTest, OneLevel) { |
83 if (!extension_available_) | 82 if (!extension_available_) |
84 return; | 83 return; |
85 | 84 |
86 glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8_OES, 4, 4); | 85 glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8_OES, 4, 4); |
87 | 86 |
88 uint8 source_pixels[64] = { 0 }; | 87 uint8_t source_pixels[64] = {0}; |
89 | 88 |
90 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); | 89 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
91 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, | 90 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, |
92 GL_RGBA, GL_UNSIGNED_BYTE, source_pixels); | 91 GL_RGBA, GL_UNSIGNED_BYTE, source_pixels); |
93 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); | 92 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
94 glTexSubImage2D(GL_TEXTURE_2D, 1, 0, 0, 2, 2, | 93 glTexSubImage2D(GL_TEXTURE_2D, 1, 0, 0, 2, 2, |
95 GL_RGBA, GL_UNSIGNED_BYTE, source_pixels); | 94 GL_RGBA, GL_UNSIGNED_BYTE, source_pixels); |
96 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), glGetError()); | 95 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), glGetError()); |
97 } | 96 } |
98 | 97 |
99 TEST_F(TextureStorageTest, MultipleLevels) { | 98 TEST_F(TextureStorageTest, MultipleLevels) { |
100 if (!extension_available_) | 99 if (!extension_available_) |
101 return; | 100 return; |
102 | 101 |
103 glTexStorage2DEXT(GL_TEXTURE_2D, 2, GL_RGBA8_OES, 2, 2); | 102 glTexStorage2DEXT(GL_TEXTURE_2D, 2, GL_RGBA8_OES, 2, 2); |
104 | 103 |
105 uint8 source_pixels[16] = { 0 }; | 104 uint8_t source_pixels[16] = {0}; |
106 | 105 |
107 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); | 106 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
108 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 2, 2, | 107 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 2, 2, |
109 GL_RGBA, GL_UNSIGNED_BYTE, source_pixels); | 108 GL_RGBA, GL_UNSIGNED_BYTE, source_pixels); |
110 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); | 109 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
111 glTexSubImage2D(GL_TEXTURE_2D, 1, 0, 0, 1, 1, | 110 glTexSubImage2D(GL_TEXTURE_2D, 1, 0, 0, 1, 1, |
112 GL_RGBA, GL_UNSIGNED_BYTE, source_pixels); | 111 GL_RGBA, GL_UNSIGNED_BYTE, source_pixels); |
113 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); | 112 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
114 glTexSubImage2D(GL_TEXTURE_2D, 2, 0, 0, 1, 1, | 113 glTexSubImage2D(GL_TEXTURE_2D, 2, 0, 0, 1, 1, |
115 GL_RGBA, GL_UNSIGNED_BYTE, source_pixels); | 114 GL_RGBA, GL_UNSIGNED_BYTE, source_pixels); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 GL_RGBA, | 153 GL_RGBA, |
155 GL_UNSIGNED_BYTE, | 154 GL_UNSIGNED_BYTE, |
156 NULL); | 155 NULL); |
157 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), glGetError()); | 156 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), glGetError()); |
158 } | 157 } |
159 | 158 |
160 } // namespace gpu | 159 } // namespace gpu |
161 | 160 |
162 | 161 |
163 | 162 |
OLD | NEW |