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

Side by Side Diff: gpu/command_buffer/tests/gl_texture_storage_unittest.cc

Issue 2999923002: Revert of Allow creating GLImage-backed textures with glTexStorage2D. (Closed)
Patch Set: rebase Created 3 years, 4 months 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
OLDNEW
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 #include <stdint.h>
8 8
9 #include "gpu/GLES2/gl2extchromium.h"
10 #include "gpu/command_buffer/tests/gl_manager.h" 9 #include "gpu/command_buffer/tests/gl_manager.h"
11 #include "gpu/command_buffer/tests/gl_test_utils.h" 10 #include "gpu/command_buffer/tests/gl_test_utils.h"
12 #include "gpu/command_buffer/tests/texture_image_factory.h"
13 #include "testing/gmock/include/gmock/gmock.h" 11 #include "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
15 13
16 namespace gpu { 14 namespace gpu {
17 15
18 class TextureStorageTest : public testing::Test { 16 class TextureStorageTest : public testing::Test {
19 protected: 17 protected:
20 static const GLsizei kResolution = 64; 18 static const GLsizei kResolution = 64;
21 void SetUp() override { 19 void SetUp() override {
22 GLManager::Options options; 20 GLManager::Options options;
23 image_factory_.SetRequiredTextureType(GL_TEXTURE_2D);
24 options.size = gfx::Size(kResolution, kResolution); 21 options.size = gfx::Size(kResolution, kResolution);
25 options.image_factory = &image_factory_;
26 gl_.Initialize(options); 22 gl_.Initialize(options);
27 gl_.MakeCurrent(); 23 gl_.MakeCurrent();
28 24
29 glGenTextures(1, &tex_); 25 glGenTextures(1, &tex_);
30 glBindTexture(GL_TEXTURE_2D, tex_); 26 glBindTexture(GL_TEXTURE_2D, tex_);
31 27
32 glGenFramebuffers(1, &fbo_); 28 glGenFramebuffers(1, &fbo_);
33 glBindFramebuffer(GL_FRAMEBUFFER, fbo_); 29 glBindFramebuffer(GL_FRAMEBUFFER, fbo_);
34 glFramebufferTexture2D(GL_FRAMEBUFFER, 30 glFramebufferTexture2D(GL_FRAMEBUFFER,
35 GL_COLOR_ATTACHMENT0, 31 GL_COLOR_ATTACHMENT0,
36 GL_TEXTURE_2D, 32 GL_TEXTURE_2D,
37 tex_, 33 tex_,
38 0); 34 0);
39 35
40 const GLubyte* extensions = glGetString(GL_EXTENSIONS); 36 const GLubyte* extensions = glGetString(GL_EXTENSIONS);
41 extension_available_ = strstr(reinterpret_cast<const char*>( 37 extension_available_ = strstr(reinterpret_cast<const char*>(
42 extensions), "GL_EXT_texture_storage"); 38 extensions), "GL_EXT_texture_storage");
43 } 39 }
44 40
45 void TearDown() override { gl_.Destroy(); } 41 void TearDown() override { gl_.Destroy(); }
46 42
47 TextureImageFactory image_factory_;
48 GLManager gl_; 43 GLManager gl_;
49 GLuint tex_; 44 GLuint tex_;
50 GLuint fbo_; 45 GLuint fbo_;
51 bool extension_available_; 46 bool extension_available_;
52 }; 47 };
53 48
54 TEST_F(TextureStorageTest, CorrectPixels) { 49 TEST_F(TextureStorageTest, CorrectPixels) {
55 if (!extension_available_) 50 if (!extension_available_)
56 return; 51 return;
57 52
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 if (!extension_available_) 154 if (!extension_available_)
160 return; 155 return;
161 156
162 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); 157 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
163 // The context is ES2 context. 158 // The context is ES2 context.
164 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8_OES, 4, 4, 0, GL_RGBA, 159 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8_OES, 4, 4, 0, GL_RGBA,
165 GL_UNSIGNED_BYTE, nullptr); 160 GL_UNSIGNED_BYTE, nullptr);
166 EXPECT_NE(static_cast<GLenum>(GL_NO_ERROR), glGetError()); 161 EXPECT_NE(static_cast<GLenum>(GL_NO_ERROR), glGetError());
167 } 162 }
168 163
169 TEST_F(TextureStorageTest, CorrectImagePixels) {
170 if (!extension_available_)
171 return;
172 if (gl_.gpu_preferences().use_passthrough_cmd_decoder) {
173 // TODO(geofflang): crbug.com/754710
174 LOG(INFO) << "Passthrough command decoder unimplemented feature. Skipping "
175 "test...";
176 return;
177 }
178
179 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BUFFER_USAGE_CHROMIUM,
180 GL_TEXTURE_BUFFER_SCANOUT_CHROMIUM);
181
182 glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8_OES, 2, 2);
183
184 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
185 tex_, 0);
186
187 uint8_t source_pixels[16] = {1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4};
188 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE,
189 source_pixels);
190 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 2, 2, 0, source_pixels, nullptr));
191 }
192
193 } // namespace gpu 164 } // namespace gpu
194 165
195 166
196 167
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/texture_manager.cc ('k') | gpu/command_buffer/tests/texture_image_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698