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

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

Issue 242163002: Adding support for PVRTC, ATC, and ETC1 textures to the command buffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 7 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
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.cc ('k') | ui/gl/gl_bindings.h » ('j') | 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) 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 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "gpu/command_buffer/common/gles2_cmd_format.h" 9 #include "gpu/command_buffer/common/gles2_cmd_format.h"
10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 10 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 133
134 class GLES2DecoderManualInitTest : public GLES2DecoderWithShaderTest { 134 class GLES2DecoderManualInitTest : public GLES2DecoderWithShaderTest {
135 public: 135 public:
136 GLES2DecoderManualInitTest() { } 136 GLES2DecoderManualInitTest() { }
137 137
138 // Override default setup so nothing gets setup. 138 // Override default setup so nothing gets setup.
139 virtual void SetUp() { 139 virtual void SetUp() {
140 } 140 }
141 }; 141 };
142 142
143 class GLES2DecoderCompressedFormatsTest : public GLES2DecoderManualInitTest {
144 public:
145 GLES2DecoderCompressedFormatsTest() { }
146
147 static bool ValueInArray(GLint value, GLint* array, GLint count) {
148 for (GLint ii = 0; ii < count; ++ii) {
149 if (array[ii] == value) {
150 return true;
151 }
152 }
153 return false;
154 }
155
156 void CheckFormats(const char* extension, const GLenum* formats, int count) {
157 InitState init;
158 init.extensions = extension;
159 init.gl_version = "3.0";
160 init.bind_generates_resource = true;
161 InitDecoder(init);
162
163 EXPECT_CALL(*gl_, GetError())
164 .WillOnce(Return(GL_NO_ERROR))
165 .WillOnce(Return(GL_NO_ERROR))
166 .WillOnce(Return(GL_NO_ERROR))
167 .WillOnce(Return(GL_NO_ERROR))
168 .RetiresOnSaturation();
169
170 typedef GetIntegerv::Result Result;
171 Result* result = static_cast<Result*>(shared_memory_address_);
172 GetIntegerv cmd;
173 result->size = 0;
174 EXPECT_CALL(*gl_, GetIntegerv(_, _))
175 .Times(0)
176 .RetiresOnSaturation();
177 cmd.Init(
178 GL_NUM_COMPRESSED_TEXTURE_FORMATS,
179 shared_memory_id_, shared_memory_offset_);
180 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
181 EXPECT_EQ(1, result->GetNumResults());
182 GLint num_formats = result->GetData()[0];
183 EXPECT_EQ(count, num_formats);
184 EXPECT_EQ(GL_NO_ERROR, GetGLError());
185
186 result->size = 0;
187 cmd.Init(
188 GL_COMPRESSED_TEXTURE_FORMATS,
189 shared_memory_id_, shared_memory_offset_);
190 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
191 EXPECT_EQ(num_formats, result->GetNumResults());
192
193 for (int i = 0; i < count; ++i) {
194 EXPECT_TRUE(ValueInArray(
195 formats[i],
196 result->GetData(), result->GetNumResults()));
197 }
198
199 EXPECT_EQ(GL_NO_ERROR, GetGLError());
200 }
201 };
202
143 class GLES2DecoderRestoreStateTest : public GLES2DecoderManualInitTest { 203 class GLES2DecoderRestoreStateTest : public GLES2DecoderManualInitTest {
144 public: 204 public:
145 GLES2DecoderRestoreStateTest() { } 205 GLES2DecoderRestoreStateTest() { }
146 206
147 protected: 207 protected:
148 void AddExpectationsForActiveTexture(GLenum unit); 208 void AddExpectationsForActiveTexture(GLenum unit);
149 void AddExpectationsForBindTexture(GLenum target, GLuint id); 209 void AddExpectationsForBindTexture(GLenum target, GLuint id);
150 void InitializeContextState( 210 void InitializeContextState(
151 ContextState* state, uint32 non_default_unit, uint32 active_unit); 211 ContextState* state, uint32 non_default_unit, uint32 active_unit);
152 }; 212 };
(...skipping 4874 matching lines...) Expand 10 before | Expand all | Expand 10 after
5027 .RetiresOnSaturation(); 5087 .RetiresOnSaturation();
5028 ReadPixels cmd; 5088 ReadPixels cmd;
5029 cmd.Init(x, y, width, height, kFormat, GL_UNSIGNED_BYTE, 5089 cmd.Init(x, y, width, height, kFormat, GL_UNSIGNED_BYTE,
5030 pixels_shm_id, pixels_shm_offset, 5090 pixels_shm_id, pixels_shm_offset,
5031 result_shm_id, result_shm_offset, 5091 result_shm_id, result_shm_offset,
5032 false); 5092 false);
5033 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 5093 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
5034 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); 5094 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError());
5035 } 5095 }
5036 5096
5037 static bool ValueInArray(GLint value, GLint* array, GLint count) { 5097 TEST_F(GLES2DecoderCompressedFormatsTest, GetCompressedTextureFormatsS3TC) {
5038 for (GLint ii = 0; ii < count; ++ii) { 5098 const GLenum formats[] = {
5039 if (array[ii] == value) { 5099 GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
5040 return true; 5100 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
5041 } 5101 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
5042 } 5102 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
5043 return false; 5103 };
5104 CheckFormats("GL_EXT_texture_compression_s3tc", formats, 4);
5044 } 5105 }
5045 5106
5046 TEST_F(GLES2DecoderManualInitTest, GetCompressedTextureFormats) { 5107 TEST_F(GLES2DecoderCompressedFormatsTest, GetCompressedTextureFormatsATC) {
5047 InitState init; 5108 const GLenum formats[] = {
5048 init.extensions = "GL_EXT_texture_compression_s3tc"; 5109 GL_ATC_RGB_AMD,
5049 init.gl_version = "3.0"; 5110 GL_ATC_RGBA_EXPLICIT_ALPHA_AMD,
5050 init.bind_generates_resource = true; 5111 GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD
5051 InitDecoder(init); 5112 };
5113 CheckFormats("GL_AMD_compressed_ATC_texture", formats, 3);
5114 }
5052 5115
5053 EXPECT_CALL(*gl_, GetError()) 5116 TEST_F(GLES2DecoderCompressedFormatsTest, GetCompressedTextureFormatsPVRTC) {
5054 .WillOnce(Return(GL_NO_ERROR)) 5117 const GLenum formats[] = {
5055 .WillOnce(Return(GL_NO_ERROR)) 5118 GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG,
5056 .WillOnce(Return(GL_NO_ERROR)) 5119 GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG,
5057 .WillOnce(Return(GL_NO_ERROR)) 5120 GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
5058 .RetiresOnSaturation(); 5121 GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG
5122 };
5123 CheckFormats("GL_IMG_texture_compression_pvrtc", formats, 4);
5124 }
5059 5125
5060 typedef GetIntegerv::Result Result; 5126 TEST_F(GLES2DecoderCompressedFormatsTest, GetCompressedTextureFormatsETC1) {
5061 Result* result = static_cast<Result*>(shared_memory_address_); 5127 const GLenum formats[] = {
5062 GetIntegerv cmd; 5128 GL_ETC1_RGB8_OES
5063 result->size = 0; 5129 };
5064 EXPECT_CALL(*gl_, GetIntegerv(_, _)) 5130 CheckFormats("GL_OES_compressed_ETC1_RGB8_texture", formats, 1);
5065 .Times(0)
5066 .RetiresOnSaturation();
5067 cmd.Init(
5068 GL_NUM_COMPRESSED_TEXTURE_FORMATS,
5069 shared_memory_id_, shared_memory_offset_);
5070 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
5071 EXPECT_EQ(1, result->GetNumResults());
5072 GLint num_formats = result->GetData()[0];
5073 EXPECT_EQ(4, num_formats);
5074 EXPECT_EQ(GL_NO_ERROR, GetGLError());
5075
5076 result->size = 0;
5077 cmd.Init(
5078 GL_COMPRESSED_TEXTURE_FORMATS,
5079 shared_memory_id_, shared_memory_offset_);
5080 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
5081 EXPECT_EQ(num_formats, result->GetNumResults());
5082
5083 EXPECT_TRUE(ValueInArray(
5084 GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
5085 result->GetData(), result->GetNumResults()));
5086 EXPECT_TRUE(ValueInArray(
5087 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
5088 result->GetData(), result->GetNumResults()));
5089 EXPECT_TRUE(ValueInArray(
5090 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
5091 result->GetData(), result->GetNumResults()));
5092 EXPECT_TRUE(ValueInArray(
5093 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
5094 result->GetData(), result->GetNumResults()));
5095
5096 EXPECT_EQ(GL_NO_ERROR, GetGLError());
5097 } 5131 }
5098 5132
5099 TEST_F(GLES2DecoderManualInitTest, GetNoCompressedTextureFormats) { 5133 TEST_F(GLES2DecoderManualInitTest, GetNoCompressedTextureFormats) {
5100 InitState init; 5134 InitState init;
5101 init.gl_version = "3.0"; 5135 init.gl_version = "3.0";
5102 init.bind_generates_resource = true; 5136 init.bind_generates_resource = true;
5103 InitDecoder(init); 5137 InitDecoder(init);
5104 5138
5105 EXPECT_CALL(*gl_, GetError()) 5139 EXPECT_CALL(*gl_, GetError())
5106 .WillOnce(Return(GL_NO_ERROR)) 5140 .WillOnce(Return(GL_NO_ERROR))
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
5376 EXPECT_EQ(error::kNoError, ExecuteCmd(texsub_cmd)); 5410 EXPECT_EQ(error::kNoError, ExecuteCmd(texsub_cmd));
5377 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 5411 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
5378 5412
5379 // Test CopyTexSubImage not allowed for ETC1 compressed texture 5413 // Test CopyTexSubImage not allowed for ETC1 compressed texture
5380 CopyTexSubImage2D copy_cmd; 5414 CopyTexSubImage2D copy_cmd;
5381 copy_cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 4, 4); 5415 copy_cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 4, 4);
5382 EXPECT_EQ(error::kNoError, ExecuteCmd(copy_cmd)); 5416 EXPECT_EQ(error::kNoError, ExecuteCmd(copy_cmd));
5383 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 5417 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
5384 } 5418 }
5385 5419
5386 TEST_F(GLES2DecoderManualInitTest, GetCompressedTextureFormatsETC1) {
5387 InitState init;
5388 init.extensions = "GL_OES_compressed_ETC1_RGB8_texture";
5389 init.gl_version = "opengl es 2.0";
5390 init.bind_generates_resource = true;
5391 InitDecoder(init);
5392
5393 EXPECT_CALL(*gl_, GetError())
5394 .WillOnce(Return(GL_NO_ERROR))
5395 .WillOnce(Return(GL_NO_ERROR))
5396 .WillOnce(Return(GL_NO_ERROR))
5397 .WillOnce(Return(GL_NO_ERROR))
5398 .RetiresOnSaturation();
5399
5400 typedef GetIntegerv::Result Result;
5401 Result* result = static_cast<Result*>(shared_memory_address_);
5402 GetIntegerv cmd;
5403 result->size = 0;
5404 EXPECT_CALL(*gl_, GetIntegerv(_, _))
5405 .Times(0)
5406 .RetiresOnSaturation();
5407 cmd.Init(
5408 GL_NUM_COMPRESSED_TEXTURE_FORMATS,
5409 shared_memory_id_, shared_memory_offset_);
5410 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
5411 EXPECT_EQ(1, result->GetNumResults());
5412 GLint num_formats = result->GetData()[0];
5413 EXPECT_EQ(1, num_formats);
5414 EXPECT_EQ(GL_NO_ERROR, GetGLError());
5415
5416 result->size = 0;
5417 cmd.Init(
5418 GL_COMPRESSED_TEXTURE_FORMATS,
5419 shared_memory_id_, shared_memory_offset_);
5420 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
5421 EXPECT_EQ(num_formats, result->GetNumResults());
5422
5423 EXPECT_TRUE(ValueInArray(
5424 GL_ETC1_RGB8_OES,
5425 result->GetData(), result->GetNumResults()));
5426 EXPECT_EQ(GL_NO_ERROR, GetGLError());
5427 }
5428
5429 TEST_F(GLES2DecoderWithShaderTest, GetProgramInfoCHROMIUMValidArgs) { 5420 TEST_F(GLES2DecoderWithShaderTest, GetProgramInfoCHROMIUMValidArgs) {
5430 const uint32 kBucketId = 123; 5421 const uint32 kBucketId = 123;
5431 GetProgramInfoCHROMIUM cmd; 5422 GetProgramInfoCHROMIUM cmd;
5432 cmd.Init(client_program_id_, kBucketId); 5423 cmd.Init(client_program_id_, kBucketId);
5433 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 5424 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
5434 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId); 5425 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId);
5435 EXPECT_GT(bucket->size(), 0u); 5426 EXPECT_GT(bucket->size(), 0u);
5436 } 5427 }
5437 5428
5438 TEST_F(GLES2DecoderWithShaderTest, GetProgramInfoCHROMIUMInvalidArgs) { 5429 TEST_F(GLES2DecoderWithShaderTest, GetProgramInfoCHROMIUMInvalidArgs) {
(...skipping 4144 matching lines...) Expand 10 before | Expand all | Expand 10 after
9583 // TODO(gman): TexImage2DImmediate 9574 // TODO(gman): TexImage2DImmediate
9584 9575
9585 // TODO(gman): TexSubImage2DImmediate 9576 // TODO(gman): TexSubImage2DImmediate
9586 9577
9587 // TODO(gman): UseProgram 9578 // TODO(gman): UseProgram
9588 9579
9589 // TODO(gman): SwapBuffers 9580 // TODO(gman): SwapBuffers
9590 9581
9591 } // namespace gles2 9582 } // namespace gles2
9592 } // namespace gpu 9583 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.cc ('k') | ui/gl/gl_bindings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698