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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc

Issue 7304002: Correct reporting of compressed texture formats and shader binary formats (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 5 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 | Annotate | Revision Log
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 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include "base/atomicops.h" 7 #include "base/atomicops.h"
8 #include "gpu/command_buffer/common/gles2_cmd_format.h" 8 #include "gpu/command_buffer/common/gles2_cmd_format.h"
9 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 9 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
10 #include "gpu/command_buffer/common/gl_mock.h" 10 #include "gpu/command_buffer/common/gl_mock.h"
(...skipping 4193 matching lines...) Expand 10 before | Expand all | Expand 10 after
4204 .Times(1) 4204 .Times(1)
4205 .RetiresOnSaturation(); 4205 .RetiresOnSaturation();
4206 ReadPixels cmd; 4206 ReadPixels cmd;
4207 cmd.Init(x, y, width, height, kFormat, GL_UNSIGNED_BYTE, 4207 cmd.Init(x, y, width, height, kFormat, GL_UNSIGNED_BYTE,
4208 pixels_shm_id, pixels_shm_offset, 4208 pixels_shm_id, pixels_shm_offset,
4209 result_shm_id, result_shm_offset); 4209 result_shm_id, result_shm_offset);
4210 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 4210 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
4211 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); 4211 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError());
4212 } 4212 }
4213 4213
4214 static bool ValueInArray(GLint value, GLint* array, GLint count) {
4215 for (GLint ii = 0; ii < count; ++ii) {
4216 if (array[ii] == value) {
4217 return true;
4218 }
4219 }
4220 return false;
4221 }
4222
4223 TEST_F(GLES2DecoderManualInitTest, GetCompressedTextureFormats) {
4224 InitDecoder(
4225 "GL_EXT_texture_compression_s3tc", // extensions
4226 false, // has alpha
4227 false, // has depth
4228 false, // has stencil
4229 false, // request alpha
4230 false, // request depth
4231 false); // request stencil
4232
4233 EXPECT_CALL(*gl_, GetError())
4234 .WillOnce(Return(GL_NO_ERROR))
4235 .WillOnce(Return(GL_NO_ERROR))
4236 .WillOnce(Return(GL_NO_ERROR))
4237 .WillOnce(Return(GL_NO_ERROR))
4238 .RetiresOnSaturation();
4239
4240 typedef GetIntegerv::Result Result;
4241 Result* result = static_cast<Result*>(shared_memory_address_);
4242 GetIntegerv cmd;
4243 result->size = 0;
4244 EXPECT_CALL(*gl_, GetIntegerv(_, _))
4245 .Times(0)
4246 .RetiresOnSaturation();
4247 cmd.Init(
4248 GL_NUM_COMPRESSED_TEXTURE_FORMATS,
4249 shared_memory_id_, shared_memory_offset_);
4250 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
4251 EXPECT_EQ(1, result->GetNumResults());
4252 GLint num_formats = result->GetData()[0];
4253 EXPECT_EQ(4, num_formats);
4254 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4255
4256 result->size = 0;
4257 cmd.Init(
4258 GL_COMPRESSED_TEXTURE_FORMATS,
4259 shared_memory_id_, shared_memory_offset_);
4260 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
4261 EXPECT_EQ(num_formats, result->GetNumResults());
4262
4263 EXPECT_TRUE(ValueInArray(
4264 GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
4265 result->GetData(), result->GetNumResults()));
4266 EXPECT_TRUE(ValueInArray(
4267 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
4268 result->GetData(), result->GetNumResults()));
4269 EXPECT_TRUE(ValueInArray(
4270 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
4271 result->GetData(), result->GetNumResults()));
4272 EXPECT_TRUE(ValueInArray(
4273 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
4274 result->GetData(), result->GetNumResults()));
4275
4276 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4277 }
4278
4279 TEST_F(GLES2DecoderManualInitTest, GetNoCompressedTextureFormats) {
4280 InitDecoder(
4281 "", // extensions
4282 false, // has alpha
4283 false, // has depth
4284 false, // has stencil
4285 false, // request alpha
4286 false, // request depth
4287 false); // request stencil
4288
4289 EXPECT_CALL(*gl_, GetError())
4290 .WillOnce(Return(GL_NO_ERROR))
4291 .WillOnce(Return(GL_NO_ERROR))
4292 .WillOnce(Return(GL_NO_ERROR))
4293 .WillOnce(Return(GL_NO_ERROR))
4294 .RetiresOnSaturation();
4295
4296 typedef GetIntegerv::Result Result;
4297 Result* result = static_cast<Result*>(shared_memory_address_);
4298 GetIntegerv cmd;
4299 result->size = 0;
4300 EXPECT_CALL(*gl_, GetIntegerv(_, _))
4301 .Times(0)
4302 .RetiresOnSaturation();
4303 cmd.Init(
4304 GL_NUM_COMPRESSED_TEXTURE_FORMATS,
4305 shared_memory_id_, shared_memory_offset_);
4306 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
4307 EXPECT_EQ(1, result->GetNumResults());
4308 GLint num_formats = result->GetData()[0];
4309 EXPECT_EQ(0, num_formats);
4310 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4311
4312 result->size = 0;
4313 cmd.Init(
4314 GL_COMPRESSED_TEXTURE_FORMATS,
4315 shared_memory_id_, shared_memory_offset_);
4316 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
4317 EXPECT_EQ(num_formats, result->GetNumResults());
4318
4319 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4320 }
4321
4214 // TODO(gman): Complete this test. 4322 // TODO(gman): Complete this test.
4215 // TEST_F(GLES2DecoderTest, CompressedTexImage2DGLError) { 4323 // TEST_F(GLES2DecoderTest, CompressedTexImage2DGLError) {
4216 // } 4324 // }
4217 4325
4218 // TODO(gman): BufferData 4326 // TODO(gman): BufferData
4219 4327
4220 // TODO(gman): BufferDataImmediate 4328 // TODO(gman): BufferDataImmediate
4221 4329
4222 // TODO(gman): BufferSubData 4330 // TODO(gman): BufferSubData
4223 4331
(...skipping 16 matching lines...) Expand all
4240 // TODO(gman): TexImage2DImmediate 4348 // TODO(gman): TexImage2DImmediate
4241 4349
4242 // TODO(gman): TexSubImage2DImmediate 4350 // TODO(gman): TexSubImage2DImmediate
4243 4351
4244 // TODO(gman): UseProgram 4352 // TODO(gman): UseProgram
4245 4353
4246 // TODO(gman): SwapBuffers 4354 // TODO(gman): SwapBuffers
4247 4355
4248 } // namespace gles2 4356 } // namespace gles2
4249 } // namespace gpu 4357 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.cc ('k') | gpu/command_buffer/service/gles2_cmd_validation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698