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" |
11 #include "gpu/command_buffer/common/id_allocator.h" | 11 #include "gpu/command_buffer/common/id_allocator.h" |
12 #include "gpu/command_buffer/service/async_pixel_transfer_delegate_mock.h" | 12 #include "gpu/command_buffer/service/async_pixel_transfer_delegate_mock.h" |
13 #include "gpu/command_buffer/service/async_pixel_transfer_manager.h" | 13 #include "gpu/command_buffer/service/async_pixel_transfer_manager.h" |
14 #include "gpu/command_buffer/service/async_pixel_transfer_manager_mock.h" | 14 #include "gpu/command_buffer/service/async_pixel_transfer_manager_mock.h" |
15 #include "gpu/command_buffer/service/cmd_buffer_engine.h" | 15 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
16 #include "gpu/command_buffer/service/context_group.h" | 16 #include "gpu/command_buffer/service/context_group.h" |
17 #include "gpu/command_buffer/service/context_state.h" | 17 #include "gpu/command_buffer/service/context_state.h" |
18 #include "gpu/command_buffer/service/gl_surface_mock.h" | 18 #include "gpu/command_buffer/service/gl_surface_mock.h" |
19 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h" | 19 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h" |
20 | |
21 #include "gpu/command_buffer/service/gpu_switches.h" | |
22 #include "gpu/command_buffer/service/image_manager.h" | 20 #include "gpu/command_buffer/service/image_manager.h" |
23 #include "gpu/command_buffer/service/mailbox_manager.h" | 21 #include "gpu/command_buffer/service/mailbox_manager.h" |
24 #include "gpu/command_buffer/service/mocks.h" | 22 #include "gpu/command_buffer/service/mocks.h" |
25 #include "gpu/command_buffer/service/program_manager.h" | 23 #include "gpu/command_buffer/service/program_manager.h" |
26 #include "gpu/command_buffer/service/test_helper.h" | 24 #include "gpu/command_buffer/service/test_helper.h" |
| 25 #include "gpu/config/gpu_switches.h" |
27 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
28 #include "ui/gl/gl_image_stub.h" | 27 #include "ui/gl/gl_image_stub.h" |
29 #include "ui/gl/gl_implementation.h" | 28 #include "ui/gl/gl_implementation.h" |
30 #include "ui/gl/gl_mock.h" | 29 #include "ui/gl/gl_mock.h" |
31 #include "ui/gl/gl_surface_stub.h" | 30 #include "ui/gl/gl_surface_stub.h" |
32 | 31 |
33 #if !defined(GL_DEPTH24_STENCIL8) | 32 #if !defined(GL_DEPTH24_STENCIL8) |
34 #define GL_DEPTH24_STENCIL8 0x88F0 | 33 #define GL_DEPTH24_STENCIL8 0x88F0 |
35 #endif | 34 #endif |
36 | 35 |
(...skipping 1995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2032 ProduceTextureDirectCHROMIUMImmediate& produce_cmd = | 2031 ProduceTextureDirectCHROMIUMImmediate& produce_cmd = |
2033 *GetImmediateAs<ProduceTextureDirectCHROMIUMImmediate>(); | 2032 *GetImmediateAs<ProduceTextureDirectCHROMIUMImmediate>(); |
2034 produce_cmd.Init(client_texture_id_, GL_TEXTURE_2D, mailbox.name); | 2033 produce_cmd.Init(client_texture_id_, GL_TEXTURE_2D, mailbox.name); |
2035 EXPECT_EQ(error::kNoError, | 2034 EXPECT_EQ(error::kNoError, |
2036 ExecuteImmediateCmd(produce_cmd, sizeof(mailbox.name))); | 2035 ExecuteImmediateCmd(produce_cmd, sizeof(mailbox.name))); |
2037 | 2036 |
2038 // ProduceTexture should fail it the texture and produce targets don't match. | 2037 // ProduceTexture should fail it the texture and produce targets don't match. |
2039 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 2038 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
2040 } | 2039 } |
2041 | 2040 |
| 2041 TEST_P(GLES2DecoderTest, CreateAndConsumeTextureCHROMIUMInvalidMailbox) { |
| 2042 // Attempt to consume the mailbox when no texture has been produced with it. |
| 2043 Mailbox mailbox = Mailbox::Generate(); |
| 2044 GLuint new_texture_id = kNewClientId; |
| 2045 |
| 2046 EXPECT_CALL(*gl_, GenTextures(1, _)) |
| 2047 .WillOnce(SetArgumentPointee<1>(kNewServiceId)) |
| 2048 .RetiresOnSaturation(); |
| 2049 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, _)) |
| 2050 .Times(2) |
| 2051 .RetiresOnSaturation(); |
| 2052 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)) |
| 2053 .Times(1) |
| 2054 .RetiresOnSaturation(); |
| 2055 |
| 2056 CreateAndConsumeTextureCHROMIUMImmediate& consume_cmd = |
| 2057 *GetImmediateAs<CreateAndConsumeTextureCHROMIUMImmediate>(); |
| 2058 consume_cmd.Init(GL_TEXTURE_2D, new_texture_id, mailbox.name); |
| 2059 EXPECT_EQ(error::kNoError, |
| 2060 ExecuteImmediateCmd(consume_cmd, sizeof(mailbox.name))); |
| 2061 |
| 2062 // CreateAndConsumeTexture should fail if the mailbox isn't associated with a |
| 2063 // texture. |
| 2064 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 2065 |
| 2066 // Make sure the new client_id is associated with a texture ref even though |
| 2067 // CreateAndConsumeTexture failed. |
| 2068 TextureRef* texture_ref = |
| 2069 group().texture_manager()->GetTexture(new_texture_id); |
| 2070 ASSERT_TRUE(texture_ref != NULL); |
| 2071 Texture* texture = texture_ref->texture(); |
| 2072 // New texture should have the correct target type. |
| 2073 EXPECT_TRUE(texture->target() == GL_TEXTURE_2D); |
| 2074 // New texture should have a valid service_id. |
| 2075 EXPECT_EQ(kNewServiceId, texture->service_id()); |
| 2076 } |
| 2077 |
| 2078 TEST_P(GLES2DecoderTest, CreateAndConsumeTextureCHROMIUMInvalidTarget) { |
| 2079 Mailbox mailbox = Mailbox::Generate(); |
| 2080 |
| 2081 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 2082 TextureRef* texture_ref = |
| 2083 group().texture_manager()->GetTexture(client_texture_id_); |
| 2084 ASSERT_TRUE(texture_ref != NULL); |
| 2085 |
| 2086 ProduceTextureDirectCHROMIUMImmediate& produce_cmd = |
| 2087 *GetImmediateAs<ProduceTextureDirectCHROMIUMImmediate>(); |
| 2088 produce_cmd.Init(client_texture_id_, GL_TEXTURE_2D, mailbox.name); |
| 2089 EXPECT_EQ(error::kNoError, |
| 2090 ExecuteImmediateCmd(produce_cmd, sizeof(mailbox.name))); |
| 2091 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 2092 |
| 2093 EXPECT_CALL(*gl_, GenTextures(1, _)) |
| 2094 .WillOnce(SetArgumentPointee<1>(kNewServiceId)) |
| 2095 .RetiresOnSaturation(); |
| 2096 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_CUBE_MAP, _)) |
| 2097 .Times(2) |
| 2098 .RetiresOnSaturation(); |
| 2099 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)) |
| 2100 .Times(1) |
| 2101 .RetiresOnSaturation(); |
| 2102 |
| 2103 // Attempt to consume the mailbox with a different target. |
| 2104 GLuint new_texture_id = kNewClientId; |
| 2105 CreateAndConsumeTextureCHROMIUMImmediate& consume_cmd = |
| 2106 *GetImmediateAs<CreateAndConsumeTextureCHROMIUMImmediate>(); |
| 2107 consume_cmd.Init(GL_TEXTURE_CUBE_MAP, new_texture_id, mailbox.name); |
| 2108 EXPECT_EQ(error::kNoError, |
| 2109 ExecuteImmediateCmd(consume_cmd, sizeof(mailbox.name))); |
| 2110 |
| 2111 // CreateAndConsumeTexture should fail if the produced texture had a different |
| 2112 // target. |
| 2113 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 2114 |
| 2115 // Make sure the new client_id is associated with a texture ref even though |
| 2116 // CreateAndConsumeTexture failed. |
| 2117 texture_ref = group().texture_manager()->GetTexture(new_texture_id); |
| 2118 ASSERT_TRUE(texture_ref != NULL); |
| 2119 Texture* texture = texture_ref->texture(); |
| 2120 // New texture should have the correct target type. |
| 2121 EXPECT_TRUE(texture->target() == GL_TEXTURE_CUBE_MAP); |
| 2122 // New texture should have a valid service_id. |
| 2123 EXPECT_EQ(kNewServiceId, texture->service_id()); |
| 2124 |
| 2125 // Make sure the client_id did not become associated with the produced texture |
| 2126 // service_id. |
| 2127 EXPECT_NE(kServiceTextureId, texture->service_id()); |
| 2128 } |
| 2129 |
2042 TEST_P(GLES2DecoderManualInitTest, DepthTextureBadArgs) { | 2130 TEST_P(GLES2DecoderManualInitTest, DepthTextureBadArgs) { |
2043 InitState init; | 2131 InitState init; |
2044 init.extensions = "GL_ANGLE_depth_texture"; | 2132 init.extensions = "GL_ANGLE_depth_texture"; |
2045 init.gl_version = "opengl es 2.0"; | 2133 init.gl_version = "opengl es 2.0"; |
2046 init.has_depth = true; | 2134 init.has_depth = true; |
2047 init.has_stencil = true; | 2135 init.has_stencil = true; |
2048 init.request_depth = true; | 2136 init.request_depth = true; |
2049 init.request_stencil = true; | 2137 init.request_stencil = true; |
2050 init.bind_generates_resource = true; | 2138 init.bind_generates_resource = true; |
2051 InitDecoder(init); | 2139 InitDecoder(init); |
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2912 // TODO(gman): CompressedTexSubImage2DImmediate | 3000 // TODO(gman): CompressedTexSubImage2DImmediate |
2913 | 3001 |
2914 // TODO(gman): TexImage2D | 3002 // TODO(gman): TexImage2D |
2915 | 3003 |
2916 // TODO(gman): TexImage2DImmediate | 3004 // TODO(gman): TexImage2DImmediate |
2917 | 3005 |
2918 // TODO(gman): TexSubImage2DImmediate | 3006 // TODO(gman): TexSubImage2DImmediate |
2919 | 3007 |
2920 } // namespace gles2 | 3008 } // namespace gles2 |
2921 } // namespace gpu | 3009 } // namespace gpu |
OLD | NEW |