| 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 "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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 110 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 111 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 111 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 112 } | 112 } |
| 113 | 113 |
| 114 TEST_P(GLES2DecoderTest, FramebufferTexture2DWithNoBoundTarget) { | 114 TEST_P(GLES2DecoderTest, FramebufferTexture2DWithNoBoundTarget) { |
| 115 EXPECT_CALL(*gl_, FramebufferTexture2DEXT(_, _, _, _, _)).Times(0); | 115 EXPECT_CALL(*gl_, FramebufferTexture2DEXT(_, _, _, _, _)).Times(0); |
| 116 FramebufferTexture2D cmd; | 116 FramebufferTexture2D cmd; |
| 117 cmd.Init(GL_FRAMEBUFFER, | 117 cmd.Init(GL_FRAMEBUFFER, |
| 118 GL_COLOR_ATTACHMENT0, | 118 GL_COLOR_ATTACHMENT0, |
| 119 GL_TEXTURE_2D, | 119 GL_TEXTURE_2D, |
| 120 client_texture_id_); | 120 client_texture_id_, |
| 121 0); |
| 121 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 122 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 122 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 123 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 123 } | 124 } |
| 124 | 125 |
| 126 TEST_P(GLES3DecoderTest, FramebufferTexture2DWithNoBoundTarget) { |
| 127 EXPECT_CALL(*gl_, FramebufferTexture2DEXT(_, _, _, _, _)).Times(0); |
| 128 FramebufferTexture2D cmd; |
| 129 cmd.Init(GL_FRAMEBUFFER, |
| 130 GL_COLOR_ATTACHMENT0, |
| 131 GL_TEXTURE_2D, |
| 132 client_texture_id_, |
| 133 1); |
| 134 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 135 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 136 } |
| 137 |
| 138 TEST_P(GLES2DecoderTest, FramebufferTexture2DValidArgs) { |
| 139 EXPECT_CALL(*gl_, |
| 140 FramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
| 141 GL_TEXTURE_2D, kServiceTextureId, 0)); |
| 142 DoBindFramebuffer( |
| 143 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
| 144 EXPECT_CALL(*gl_, GetError()) |
| 145 .WillOnce(Return(GL_NO_ERROR)) |
| 146 .WillOnce(Return(GL_NO_ERROR)) |
| 147 .RetiresOnSaturation(); |
| 148 cmds::FramebufferTexture2D cmd; |
| 149 cmd.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 150 client_texture_id_, 0); |
| 151 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 152 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 153 } |
| 154 |
| 155 TEST_P(GLES3DecoderTest, FramebufferTexture2DValidArgs) { |
| 156 EXPECT_CALL(*gl_, |
| 157 FramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
| 158 GL_TEXTURE_2D, kServiceTextureId, 1)); |
| 159 DoBindFramebuffer( |
| 160 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
| 161 EXPECT_CALL(*gl_, GetError()) |
| 162 .WillOnce(Return(GL_NO_ERROR)) |
| 163 .WillOnce(Return(GL_NO_ERROR)) |
| 164 .RetiresOnSaturation(); |
| 165 cmds::FramebufferTexture2D cmd; |
| 166 cmd.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 167 client_texture_id_, 1); |
| 168 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 169 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 170 } |
| 171 |
| 172 TEST_P(GLES2DecoderTest, FramebufferTexture2DInvalidArgs0_0) { |
| 173 EXPECT_CALL(*gl_, FramebufferTexture2DEXT(_, _, _, _, _)).Times(0); |
| 174 DoBindFramebuffer( |
| 175 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
| 176 cmds::FramebufferTexture2D cmd; |
| 177 cmd.Init(GL_RENDERBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 178 client_texture_id_, 0); |
| 179 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 180 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 181 } |
| 182 |
| 183 TEST_P(GLES3DecoderTest, FramebufferTexture2DInvalidArgs0_0) { |
| 184 EXPECT_CALL(*gl_, FramebufferTexture2DEXT(_, _, _, _, _)).Times(0); |
| 185 DoBindFramebuffer( |
| 186 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
| 187 cmds::FramebufferTexture2D cmd; |
| 188 cmd.Init(GL_RENDERBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 189 client_texture_id_, 1); |
| 190 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 191 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 192 } |
| 193 |
| 194 TEST_P(GLES2DecoderTest, FramebufferTexture2DInvalidArgs2_0) { |
| 195 EXPECT_CALL(*gl_, FramebufferTexture2DEXT(_, _, _, _, _)).Times(0); |
| 196 DoBindFramebuffer( |
| 197 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
| 198 cmds::FramebufferTexture2D cmd; |
| 199 cmd.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_PROXY_TEXTURE_CUBE_MAP, |
| 200 client_texture_id_, 0); |
| 201 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 202 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 203 } |
| 204 |
| 205 TEST_P(GLES3DecoderTest, FramebufferTexture2DInvalidArgs2_0) { |
| 206 EXPECT_CALL(*gl_, FramebufferTexture2DEXT(_, _, _, _, _)).Times(0); |
| 207 DoBindFramebuffer( |
| 208 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
| 209 cmds::FramebufferTexture2D cmd; |
| 210 cmd.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_PROXY_TEXTURE_CUBE_MAP, |
| 211 client_texture_id_, 1); |
| 212 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 213 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 214 } |
| 215 |
| 216 TEST_P(GLES2DecoderTest, FramebufferTexture2DInvalidArgs4_0) { |
| 217 EXPECT_CALL(*gl_, FramebufferTexture2DEXT(_, _, _, _, _)).Times(0); |
| 218 DoBindFramebuffer( |
| 219 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
| 220 cmds::FramebufferTexture2D cmd; |
| 221 cmd.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 222 client_texture_id_, 1); |
| 223 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 224 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 225 } |
| 226 |
| 227 TEST_P(GLES3DecoderTest, FramebufferTexture2DValidArgs4_0) { |
| 228 EXPECT_CALL(*gl_, |
| 229 FramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
| 230 GL_TEXTURE_2D, kServiceTextureId, 0)); |
| 231 DoBindFramebuffer( |
| 232 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
| 233 EXPECT_CALL(*gl_, GetError()) |
| 234 .WillOnce(Return(GL_NO_ERROR)) |
| 235 .WillOnce(Return(GL_NO_ERROR)) |
| 236 .RetiresOnSaturation(); |
| 237 cmds::FramebufferTexture2D cmd; |
| 238 cmd.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 239 client_texture_id_, 0); |
| 240 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 241 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 242 } |
| 243 |
| 125 TEST_P(GLES2DecoderTest, GetFramebufferAttachmentParameterivWithNoBoundTarget) { | 244 TEST_P(GLES2DecoderTest, GetFramebufferAttachmentParameterivWithNoBoundTarget) { |
| 126 EXPECT_CALL(*gl_, GetError()) | 245 EXPECT_CALL(*gl_, GetError()) |
| 127 .WillOnce(Return(GL_NO_ERROR)) | 246 .WillOnce(Return(GL_NO_ERROR)) |
| 128 .WillOnce(Return(GL_NO_ERROR)) | 247 .WillOnce(Return(GL_NO_ERROR)) |
| 129 .RetiresOnSaturation(); | 248 .RetiresOnSaturation(); |
| 130 EXPECT_CALL(*gl_, GetFramebufferAttachmentParameterivEXT(_, _, _, _)) | 249 EXPECT_CALL(*gl_, GetFramebufferAttachmentParameterivEXT(_, _, _, _)) |
| 131 .Times(0); | 250 .Times(0); |
| 132 GetFramebufferAttachmentParameteriv cmd; | 251 GetFramebufferAttachmentParameteriv cmd; |
| 133 cmd.Init(GL_FRAMEBUFFER, | 252 cmd.Init(GL_FRAMEBUFFER, |
| 134 GL_COLOR_ATTACHMENT0, | 253 GL_COLOR_ATTACHMENT0, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 GetFramebufferAttachmentParameteriv::Result* result = | 308 GetFramebufferAttachmentParameteriv::Result* result = |
| 190 static_cast<GetFramebufferAttachmentParameteriv::Result*>( | 309 static_cast<GetFramebufferAttachmentParameteriv::Result*>( |
| 191 shared_memory_address_); | 310 shared_memory_address_); |
| 192 result->SetNumResults(0); | 311 result->SetNumResults(0); |
| 193 const GLint* result_value = result->GetData(); | 312 const GLint* result_value = result->GetData(); |
| 194 FramebufferTexture2D fbtex_cmd; | 313 FramebufferTexture2D fbtex_cmd; |
| 195 GetFramebufferAttachmentParameteriv cmd; | 314 GetFramebufferAttachmentParameteriv cmd; |
| 196 fbtex_cmd.Init(GL_FRAMEBUFFER, | 315 fbtex_cmd.Init(GL_FRAMEBUFFER, |
| 197 GL_COLOR_ATTACHMENT0, | 316 GL_COLOR_ATTACHMENT0, |
| 198 GL_TEXTURE_2D, | 317 GL_TEXTURE_2D, |
| 199 client_texture_id_); | 318 client_texture_id_, |
| 319 0); |
| 200 cmd.Init(GL_FRAMEBUFFER, | 320 cmd.Init(GL_FRAMEBUFFER, |
| 201 GL_COLOR_ATTACHMENT0, | 321 GL_COLOR_ATTACHMENT0, |
| 202 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, | 322 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, |
| 203 shared_memory_id_, | 323 shared_memory_id_, |
| 204 shared_memory_offset_); | 324 shared_memory_offset_); |
| 205 EXPECT_EQ(error::kNoError, ExecuteCmd(fbtex_cmd)); | 325 EXPECT_EQ(error::kNoError, ExecuteCmd(fbtex_cmd)); |
| 206 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 326 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 207 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 327 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 208 EXPECT_EQ(client_texture_id_, static_cast<GLuint>(*result_value)); | 328 EXPECT_EQ(client_texture_id_, static_cast<GLuint>(*result_value)); |
| 209 } | 329 } |
| (...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1329 GL_COLOR_ATTACHMENT0, | 1449 GL_COLOR_ATTACHMENT0, |
| 1330 GL_TEXTURE_2D, | 1450 GL_TEXTURE_2D, |
| 1331 kServiceTextureId, | 1451 kServiceTextureId, |
| 1332 0)) | 1452 0)) |
| 1333 .Times(1) | 1453 .Times(1) |
| 1334 .RetiresOnSaturation(); | 1454 .RetiresOnSaturation(); |
| 1335 FramebufferTexture2D fbtex_cmd; | 1455 FramebufferTexture2D fbtex_cmd; |
| 1336 fbtex_cmd.Init(GL_FRAMEBUFFER, | 1456 fbtex_cmd.Init(GL_FRAMEBUFFER, |
| 1337 GL_COLOR_ATTACHMENT0, | 1457 GL_COLOR_ATTACHMENT0, |
| 1338 GL_TEXTURE_2D, | 1458 GL_TEXTURE_2D, |
| 1339 client_texture_id_); | 1459 client_texture_id_, |
| 1460 0); |
| 1340 EXPECT_EQ(error::kNoError, ExecuteCmd(fbtex_cmd)); | 1461 EXPECT_EQ(error::kNoError, ExecuteCmd(fbtex_cmd)); |
| 1341 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); | 1462 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); |
| 1342 } | 1463 } |
| 1343 | 1464 |
| 1344 TEST_P(GLES2DecoderTest, RenderbufferStorageGLError) { | 1465 TEST_P(GLES2DecoderTest, RenderbufferStorageGLError) { |
| 1345 DoBindRenderbuffer( | 1466 DoBindRenderbuffer( |
| 1346 GL_RENDERBUFFER, client_renderbuffer_id_, kServiceRenderbufferId); | 1467 GL_RENDERBUFFER, client_renderbuffer_id_, kServiceRenderbufferId); |
| 1347 EnsureRenderbufferBound(false); | 1468 EnsureRenderbufferBound(false); |
| 1348 EXPECT_CALL(*gl_, GetError()) | 1469 EXPECT_CALL(*gl_, GetError()) |
| 1349 .WillOnce(Return(GL_NO_ERROR)) | 1470 .WillOnce(Return(GL_NO_ERROR)) |
| (...skipping 1446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2796 EXPECT_EQ(1, result->GetNumResults()); | 2917 EXPECT_EQ(1, result->GetNumResults()); |
| 2797 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 2918 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 2798 } | 2919 } |
| 2799 | 2920 |
| 2800 // TODO(gman): PixelStorei | 2921 // TODO(gman): PixelStorei |
| 2801 | 2922 |
| 2802 // TODO(gman): SwapBuffers | 2923 // TODO(gman): SwapBuffers |
| 2803 | 2924 |
| 2804 } // namespace gles2 | 2925 } // namespace gles2 |
| 2805 } // namespace gpu | 2926 } // namespace gpu |
| OLD | NEW |