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

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

Issue 1058833004: Make CreateAndConsumeTexture always associate client_id with a service_id (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unit tests Created 5 years, 8 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') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2021 matching lines...) Expand 10 before | Expand all | Expand 10 after
2032 ProduceTextureDirectCHROMIUMImmediate& produce_cmd = 2032 ProduceTextureDirectCHROMIUMImmediate& produce_cmd =
2033 *GetImmediateAs<ProduceTextureDirectCHROMIUMImmediate>(); 2033 *GetImmediateAs<ProduceTextureDirectCHROMIUMImmediate>();
2034 produce_cmd.Init(client_texture_id_, GL_TEXTURE_2D, mailbox.name); 2034 produce_cmd.Init(client_texture_id_, GL_TEXTURE_2D, mailbox.name);
2035 EXPECT_EQ(error::kNoError, 2035 EXPECT_EQ(error::kNoError,
2036 ExecuteImmediateCmd(produce_cmd, sizeof(mailbox.name))); 2036 ExecuteImmediateCmd(produce_cmd, sizeof(mailbox.name)));
2037 2037
2038 // ProduceTexture should fail it the texture and produce targets don't match. 2038 // ProduceTexture should fail it the texture and produce targets don't match.
2039 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 2039 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
2040 } 2040 }
2041 2041
2042 TEST_P(GLES2DecoderTest, CreateAndConsumeTextureCHROMIUMInvalidMailbox) {
2043 // Attempt to consume the mailbox when no texture has been produced with it.
2044 Mailbox mailbox = Mailbox::Generate();
2045 GLuint new_texture_id = kNewClientId;
2046
2047 EXPECT_CALL(*gl_, GenTextures(1, _))
2048 .WillOnce(SetArgumentPointee<1>(kNewServiceId))
2049 .RetiresOnSaturation();
2050 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, _))
2051 .Times(2)
2052 .RetiresOnSaturation();
2053 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0))
2054 .Times(1)
2055 .RetiresOnSaturation();
2056
2057 CreateAndConsumeTextureCHROMIUMImmediate& consume_cmd =
2058 *GetImmediateAs<CreateAndConsumeTextureCHROMIUMImmediate>();
2059 consume_cmd.Init(GL_TEXTURE_2D, new_texture_id, mailbox.name);
2060 EXPECT_EQ(error::kNoError,
2061 ExecuteImmediateCmd(consume_cmd, sizeof(mailbox.name)));
2062
2063 // CreateAndConsumeTexture should fail if the mailbox isn't associated with a
2064 // texture.
2065 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
2066
2067 // Make sure the new client_id is associated with a texture ref even though
2068 // CreateAndConsumeTexture failed.
2069 TextureRef* texture_ref =
2070 group().texture_manager()->GetTexture(new_texture_id);
2071 ASSERT_TRUE(texture_ref != NULL);
2072 Texture* texture = texture_ref->texture();
2073 // New texture should have the correct target type.
2074 EXPECT_TRUE(texture->target() == GL_TEXTURE_2D);
2075 // New texture should have a valid service_id.
2076 EXPECT_EQ(kNewServiceId, texture->service_id());
2077 }
2078
2079 TEST_P(GLES2DecoderTest, CreateAndConsumeTextureCHROMIUMInvalidTarget) {
2080 Mailbox mailbox = Mailbox::Generate();
2081
2082 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
2083 TextureRef* texture_ref =
2084 group().texture_manager()->GetTexture(client_texture_id_);
2085 ASSERT_TRUE(texture_ref != NULL);
2086
2087 ProduceTextureDirectCHROMIUMImmediate& produce_cmd =
2088 *GetImmediateAs<ProduceTextureDirectCHROMIUMImmediate>();
2089 produce_cmd.Init(client_texture_id_, GL_TEXTURE_2D, mailbox.name);
2090 EXPECT_EQ(error::kNoError,
2091 ExecuteImmediateCmd(produce_cmd, sizeof(mailbox.name)));
2092 EXPECT_EQ(GL_NO_ERROR, GetGLError());
2093
2094 EXPECT_CALL(*gl_, GenTextures(1, _))
2095 .WillOnce(SetArgumentPointee<1>(kNewServiceId))
2096 .RetiresOnSaturation();
2097 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_CUBE_MAP, _))
2098 .Times(2)
2099 .RetiresOnSaturation();
2100 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0))
2101 .Times(1)
2102 .RetiresOnSaturation();
2103
2104 // Attempt to consume the mailbox with a different target.
2105 GLuint new_texture_id = kNewClientId;
2106 CreateAndConsumeTextureCHROMIUMImmediate& consume_cmd =
2107 *GetImmediateAs<CreateAndConsumeTextureCHROMIUMImmediate>();
2108 consume_cmd.Init(GL_TEXTURE_CUBE_MAP, new_texture_id, mailbox.name);
2109 EXPECT_EQ(error::kNoError,
2110 ExecuteImmediateCmd(consume_cmd, sizeof(mailbox.name)));
2111
2112 // CreateAndConsumeTexture should fail if the produced texture had a different
2113 // target.
2114 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
2115
2116 // Make sure the new client_id is associated with a texture ref even though
2117 // CreateAndConsumeTexture failed.
2118 texture_ref = group().texture_manager()->GetTexture(new_texture_id);
2119 ASSERT_TRUE(texture_ref != NULL);
2120 Texture* texture = texture_ref->texture();
2121 // New texture should have the correct target type.
2122 EXPECT_TRUE(texture->target() == GL_TEXTURE_CUBE_MAP);
2123 // New texture should have a valid service_id.
2124 EXPECT_EQ(kNewServiceId, texture->service_id());
2125
2126 // Make sure the client_id did not become associated with the produced texture
2127 // service_id.
2128 EXPECT_NE(kServiceTextureId, texture->service_id());
2129 }
2130
2042 TEST_P(GLES2DecoderManualInitTest, DepthTextureBadArgs) { 2131 TEST_P(GLES2DecoderManualInitTest, DepthTextureBadArgs) {
2043 InitState init; 2132 InitState init;
2044 init.extensions = "GL_ANGLE_depth_texture"; 2133 init.extensions = "GL_ANGLE_depth_texture";
2045 init.gl_version = "opengl es 2.0"; 2134 init.gl_version = "opengl es 2.0";
2046 init.has_depth = true; 2135 init.has_depth = true;
2047 init.has_stencil = true; 2136 init.has_stencil = true;
2048 init.request_depth = true; 2137 init.request_depth = true;
2049 init.request_stencil = true; 2138 init.request_stencil = true;
2050 init.bind_generates_resource = true; 2139 init.bind_generates_resource = true;
2051 InitDecoder(init); 2140 InitDecoder(init);
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after
2912 // TODO(gman): CompressedTexSubImage2DImmediate 3001 // TODO(gman): CompressedTexSubImage2DImmediate
2913 3002
2914 // TODO(gman): TexImage2D 3003 // TODO(gman): TexImage2D
2915 3004
2916 // TODO(gman): TexImage2DImmediate 3005 // TODO(gman): TexImage2DImmediate
2917 3006
2918 // TODO(gman): TexSubImage2DImmediate 3007 // TODO(gman): TexSubImage2DImmediate
2919 3008
2920 } // namespace gles2 3009 } // namespace gles2
2921 } // namespace gpu 3010 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698