Chromium Code Reviews| 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 "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1068 0, 0, 0, | 1068 0, 0, 0, |
| 1069 kWidth, | 1069 kWidth, |
| 1070 kHeight, | 1070 kHeight, |
| 1071 kDepth, | 1071 kDepth, |
| 1072 kInternalFormat, | 1072 kInternalFormat, |
| 1073 kBucketId); | 1073 kBucketId); |
| 1074 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd)); | 1074 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd)); |
| 1075 } | 1075 } |
| 1076 } | 1076 } |
| 1077 | 1077 |
| 1078 TEST_P(GLES2DecoderTest, CopyTexSubImage3DFailsOnES2) { | |
| 1079 const GLenum kTarget = GL_TEXTURE_2D_ARRAY; | |
| 1080 const GLint kLevel = 0; | |
| 1081 const GLsizei kWidth = 4; | |
| 1082 const GLsizei kHeight = 4; | |
| 1083 | |
| 1084 CopyTexSubImage3D cmd; | |
| 1085 cmd.Init(kTarget, | |
| 1086 kLevel, | |
| 1087 0, 0, 0, | |
| 1088 0, 0, | |
| 1089 kWidth, | |
| 1090 kHeight); | |
| 1091 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd)); | |
| 1092 } | |
| 1093 | |
| 1094 TEST_P(GLES3DecoderTest, CopyTexSubImage3DFaiures) { | |
| 1095 const GLenum kTarget = GL_TEXTURE_3D; | |
| 1096 const GLsizei kWidth = 2; | |
| 1097 const GLsizei kHeight = 2; | |
| 1098 | |
| 1099 CopyTexSubImage3D cmd; | |
| 1100 | |
| 1101 // No texture bound | |
| 1102 cmd.Init(kTarget, 0, 0, 0, 0, 0, 0, kWidth, kHeight); | |
| 1103 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1104 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 1105 | |
| 1106 // Incompatible format / type | |
| 1107 const GLint kLevel = 1; | |
| 1108 const GLint kInternalFormat = GL_RGBA8; | |
| 1109 const GLsizei kDepth = 2; | |
| 1110 const GLenum kFormat = GL_RGBA; | |
| 1111 const GLenum kType = GL_UNSIGNED_BYTE; | |
| 1112 DoBindTexture(kTarget, client_texture_id_, kServiceTextureId); | |
| 1113 DoTexImage3D(kTarget, kLevel, kInternalFormat, kWidth, kHeight, kDepth, 0, | |
| 1114 kFormat, kType, kSharedMemoryId, kSharedMemoryOffset); | |
| 1115 | |
| 1116 cmd.Init(kTarget, 1, 0, 0, 0, 0, 0, kWidth, kHeight); | |
|
Zhenyao Mo
2016/07/28 00:10:54
Here you need a comment that the FBO is RGB and UN
Zhenyao Mo
2016/07/28 00:10:54
Same here, use kLevel etc
yunchao
2016/07/28 00:41:04
Done.
yunchao
2016/07/28 00:41:04
Done.
| |
| 1117 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1118 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 1119 } | |
| 1120 | |
| 1121 TEST_P(GLES3DecoderTest, CopyTexSubImage3DCheckArgs) { | |
| 1122 const GLenum kTarget = GL_TEXTURE_3D; | |
| 1123 const GLint kLevel = 1; | |
| 1124 const GLint kInternalFormat = GL_RGB8; | |
| 1125 const GLint kXoffset = 0; | |
| 1126 const GLint kYoffset = 0; | |
| 1127 const GLint kZoffset = 0; | |
| 1128 const GLint kX = 0; | |
| 1129 const GLint kY = 0; | |
| 1130 const GLsizei kWidth = 2; | |
| 1131 const GLsizei kHeight = 2; | |
| 1132 const GLsizei kDepth = 2; | |
| 1133 const GLsizei kBorder = 0; | |
| 1134 const GLenum kFormat = GL_RGB; | |
| 1135 const GLenum kType = GL_UNSIGNED_BYTE; | |
| 1136 | |
| 1137 DoBindTexture(kTarget, client_texture_id_, kServiceTextureId); | |
| 1138 DoTexImage3D(kTarget, kLevel, kInternalFormat, kWidth, kHeight, kDepth, | |
| 1139 kBorder, kFormat, kType, kSharedMemoryId, kSharedMemoryOffset); | |
| 1140 | |
| 1141 // Valid args | |
| 1142 EXPECT_CALL(*gl_, | |
| 1143 CopyTexSubImage3D(kTarget, kLevel, kXoffset, kYoffset, kZoffset, | |
| 1144 kX, kY, kWidth, kHeight)) | |
| 1145 .Times(1) | |
| 1146 .RetiresOnSaturation(); | |
| 1147 CopyTexSubImage3D cmd; | |
| 1148 cmd.Init(kTarget, kLevel, kXoffset, kYoffset, kZoffset, | |
| 1149 kX, kY, kWidth, kHeight); | |
| 1150 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1151 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 1152 | |
| 1153 // Bad target | |
| 1154 cmd.Init(GL_TEXTURE_2D, kLevel, kXoffset, kYoffset, kZoffset, | |
| 1155 kX, kY, kWidth, kHeight); | |
| 1156 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1157 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | |
| 1158 | |
| 1159 // Bad Level | |
| 1160 cmd.Init(kTarget, -1, kXoffset, kYoffset, kZoffset, | |
| 1161 kX, kY, kWidth, kHeight); | |
| 1162 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1163 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 1164 cmd.Init(kTarget, 0, kXoffset, kYoffset, kZoffset, | |
| 1165 kX, kY, kWidth, kHeight); | |
| 1166 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1167 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 1168 | |
| 1169 // Bad xoffest / yoffset of 3D texture | |
| 1170 cmd.Init(kTarget, kLevel, -1, kYoffset, kZoffset, | |
| 1171 kX, kY, kWidth, kHeight); | |
| 1172 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1173 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 1174 cmd.Init(kTarget, kLevel, 1, kYoffset, kZoffset, | |
| 1175 kX, kY, kWidth, kHeight); | |
| 1176 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1177 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 1178 cmd.Init(kTarget, kLevel, kXoffset, -1, kZoffset, | |
| 1179 kX, kY, kWidth, kHeight); | |
| 1180 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1181 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 1182 cmd.Init(kTarget, kLevel, kXoffset, 1, kZoffset, | |
| 1183 kX, kY, kWidth, kHeight); | |
| 1184 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1185 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 1186 | |
| 1187 // Bad zoffset: zoffset specifies the layer of the 3D texture to be replaced | |
| 1188 cmd.Init(kTarget, kLevel, kXoffset, kYoffset, -1, | |
| 1189 kX, kY, kWidth, kHeight); | |
| 1190 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1191 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 1192 cmd.Init(kTarget, kLevel, kXoffset, kYoffset, 2, | |
|
Zhenyao Mo
2016/07/28 00:10:54
nit: use kDepth instead of 2 is better.
yunchao
2016/07/28 00:41:04
Done.
| |
| 1193 kX, kY, kWidth, kHeight); | |
| 1194 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1195 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 1196 | |
| 1197 // Bad width / height | |
| 1198 cmd.Init(kTarget, kLevel, kXoffset, kYoffset, kZoffset, | |
| 1199 kX, kY, kWidth + 1, kHeight); | |
| 1200 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1201 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 1202 cmd.Init(kTarget, kLevel, kXoffset, kYoffset, kZoffset, | |
| 1203 kX, kY, kWidth, kHeight + 1); | |
| 1204 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1205 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 1206 } | |
| 1207 | |
| 1078 TEST_P(GLES3DecoderTest, CompressedTexImage3DFailsWithBadImageSize) { | 1208 TEST_P(GLES3DecoderTest, CompressedTexImage3DFailsWithBadImageSize) { |
| 1079 const uint32_t kBucketId = 123; | 1209 const uint32_t kBucketId = 123; |
| 1080 const GLenum kTarget = GL_TEXTURE_2D_ARRAY; | 1210 const GLenum kTarget = GL_TEXTURE_2D_ARRAY; |
| 1081 const GLint kLevel = 0; | 1211 const GLint kLevel = 0; |
| 1082 const GLenum kInternalFormat = GL_COMPRESSED_RGBA8_ETC2_EAC; | 1212 const GLenum kInternalFormat = GL_COMPRESSED_RGBA8_ETC2_EAC; |
| 1083 const GLsizei kWidth = 4; | 1213 const GLsizei kWidth = 4; |
| 1084 const GLsizei kHeight = 8; | 1214 const GLsizei kHeight = 8; |
| 1085 const GLsizei kDepth = 4; | 1215 const GLsizei kDepth = 4; |
| 1086 CommonDecoder::Bucket* bucket = decoder_->CreateBucket(kBucketId); | 1216 CommonDecoder::Bucket* bucket = decoder_->CreateBucket(kBucketId); |
| 1087 ASSERT_TRUE(bucket != NULL); | 1217 ASSERT_TRUE(bucket != NULL); |
| (...skipping 2993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4081 // TODO(gman): CompressedTexSubImage2DImmediate | 4211 // TODO(gman): CompressedTexSubImage2DImmediate |
| 4082 | 4212 |
| 4083 // TODO(gman): TexImage2D | 4213 // TODO(gman): TexImage2D |
| 4084 | 4214 |
| 4085 // TODO(gman): TexImage2DImmediate | 4215 // TODO(gman): TexImage2DImmediate |
| 4086 | 4216 |
| 4087 // TODO(gman): TexSubImage2DImmediate | 4217 // TODO(gman): TexSubImage2DImmediate |
| 4088 | 4218 |
| 4089 } // namespace gles2 | 4219 } // namespace gles2 |
| 4090 } // namespace gpu | 4220 } // namespace gpu |
| OLD | NEW |