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

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

Issue 7866006: Revert 100453 - Revert "Revert 100384 - Fix bug in SimulateAttrib0 that did not check for out of ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 3 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 | Annotate | Revision Log
« 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/atomicops.h" 7 #include "base/atomicops.h"
8 #include "gpu/command_buffer/common/gles2_cmd_format.h" 8 #include "gpu/command_buffer/common/gles2_cmd_format.h"
9 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 9 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
10 #include "gpu/command_buffer/common/gl_mock.h" 10 #include "gpu/command_buffer/common/gl_mock.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 GLsizei in_read_width, GLsizei in_read_height, 48 GLsizei in_read_width, GLsizei in_read_height,
49 bool init); 49 bool init);
50 }; 50 };
51 51
52 class GLES2DecoderWithShaderTest : public GLES2DecoderWithShaderTestBase { 52 class GLES2DecoderWithShaderTest : public GLES2DecoderWithShaderTestBase {
53 public: 53 public:
54 GLES2DecoderWithShaderTest() 54 GLES2DecoderWithShaderTest()
55 : GLES2DecoderWithShaderTestBase() { 55 : GLES2DecoderWithShaderTestBase() {
56 } 56 }
57 57
58 58 void AddExpectationsForSimulatedAttrib0(
59 void AddExpectationsForSimulatedAttrib0WithError( 59 GLsizei num_vertices, GLuint buffer_id) {
60 GLsizei num_vertices, GLuint buffer_id, GLenum error) {
61 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) {
62 return;
63 }
64
65 EXPECT_CALL(*gl_, GetError())
66 .WillOnce(Return(GL_NO_ERROR))
67 .WillOnce(Return(error))
68 .RetiresOnSaturation();
69 EXPECT_CALL(*gl_, BindBuffer(GL_ARRAY_BUFFER, kServiceAttrib0BufferId)) 60 EXPECT_CALL(*gl_, BindBuffer(GL_ARRAY_BUFFER, kServiceAttrib0BufferId))
70 .Times(1) 61 .Times(1)
71 .RetiresOnSaturation(); 62 .RetiresOnSaturation();
72 EXPECT_CALL(*gl_, BufferData(GL_ARRAY_BUFFER, 63 EXPECT_CALL(*gl_, BufferData(GL_ARRAY_BUFFER,
73 num_vertices * sizeof(GLfloat) * 4, 64 num_vertices * sizeof(GLfloat) * 4,
74 _, GL_DYNAMIC_DRAW)) 65 _, GL_DYNAMIC_DRAW))
75 .Times(1) 66 .Times(1)
76 .RetiresOnSaturation(); 67 .RetiresOnSaturation();
77 if (error == GL_NO_ERROR) { 68 EXPECT_CALL(*gl_, BufferSubData(
78 EXPECT_CALL(*gl_, BufferSubData( 69 GL_ARRAY_BUFFER, 0, num_vertices * sizeof(GLfloat) * 4, _))
79 GL_ARRAY_BUFFER, 0, num_vertices * sizeof(GLfloat) * 4, _)) 70 .Times(1)
80 .Times(1) 71 .RetiresOnSaturation();
81 .RetiresOnSaturation(); 72 EXPECT_CALL(*gl_, VertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, NULL))
82 EXPECT_CALL(*gl_, VertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, NULL)) 73 .Times(1)
83 .Times(1) 74 .RetiresOnSaturation();
84 .RetiresOnSaturation(); 75 EXPECT_CALL(*gl_, BindBuffer(GL_ARRAY_BUFFER, 0))
85 EXPECT_CALL(*gl_, BindBuffer(GL_ARRAY_BUFFER, 0)) 76 .Times(1)
86 .Times(1) 77 .RetiresOnSaturation();
87 .RetiresOnSaturation(); 78 EXPECT_CALL(*gl_, VertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, NULL))
88 EXPECT_CALL(*gl_, VertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, NULL)) 79 .Times(1)
89 .Times(1) 80 .RetiresOnSaturation();
90 .RetiresOnSaturation(); 81 EXPECT_CALL(*gl_, BindBuffer(GL_ARRAY_BUFFER, buffer_id))
91 EXPECT_CALL(*gl_, BindBuffer(GL_ARRAY_BUFFER, buffer_id)) 82 .Times(1)
92 .Times(1) 83 .RetiresOnSaturation();
93 .RetiresOnSaturation();
94 }
95 }
96
97 void AddExpectationsForSimulatedAttrib0(
98 GLsizei num_vertices, GLuint buffer_id) {
99 AddExpectationsForSimulatedAttrib0WithError(
100 num_vertices, buffer_id, GL_NO_ERROR);
101 } 84 }
102 }; 85 };
103 86
104 class GLES2DecoderRGBBackbufferTest : public GLES2DecoderWithShaderTest { 87 class GLES2DecoderRGBBackbufferTest : public GLES2DecoderWithShaderTest {
105 public: 88 public:
106 GLES2DecoderRGBBackbufferTest() { } 89 GLES2DecoderRGBBackbufferTest() { }
107 90
108 virtual void SetUp() { 91 virtual void SetUp() {
109 InitDecoder( 92 InitDecoder(
110 "", // extensions 93 "", // extensions
(...skipping 24 matching lines...) Expand all
135 118
136 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) 119 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
137 .Times(1) 120 .Times(1)
138 .RetiresOnSaturation(); 121 .RetiresOnSaturation();
139 DrawArrays cmd; 122 DrawArrays cmd;
140 cmd.Init(GL_TRIANGLES, 0, kNumVertices); 123 cmd.Init(GL_TRIANGLES, 0, kNumVertices);
141 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 124 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
142 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 125 EXPECT_EQ(GL_NO_ERROR, GetGLError());
143 } 126 }
144 127
145 // Tests when the math overflows (0x40000000 * sizeof GLfloat)
146 TEST_F(GLES2DecoderWithShaderTest, DrawArraysSimulatedAttrib0OverflowFails) {
147 const GLsizei kLargeCount = 0x40000000;
148 SetupTexture();
149 EXPECT_CALL(*gl_, DrawArrays(_, _, _))
150 .Times(0)
151 .RetiresOnSaturation();
152 DrawArrays cmd;
153 cmd.Init(GL_TRIANGLES, 0, kLargeCount);
154 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
155 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError());
156 }
157
158 // Tests when the math overflows (0x7FFFFFFF + 1 = 0x8000000 verts)
159 TEST_F(GLES2DecoderWithShaderTest, DrawArraysSimulatedAttrib0PosToNegFails) {
160 const GLsizei kLargeCount = 0x7FFFFFFF;
161 SetupTexture();
162 EXPECT_CALL(*gl_, DrawArrays(_, _, _))
163 .Times(0)
164 .RetiresOnSaturation();
165 DrawArrays cmd;
166 cmd.Init(GL_TRIANGLES, 0, kLargeCount);
167 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
168 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError());
169 }
170
171 // Tests when the driver returns an error
172 TEST_F(GLES2DecoderWithShaderTest, DrawArraysSimulatedAttrib0OOMFails) {
173 const GLsizei kFakeLargeCount = 0x1234;
174 SetupTexture();
175 AddExpectationsForSimulatedAttrib0WithError(
176 kFakeLargeCount, 0, GL_OUT_OF_MEMORY);
177 EXPECT_CALL(*gl_, DrawArrays(_, _, _))
178 .Times(0)
179 .RetiresOnSaturation();
180 DrawArrays cmd;
181 cmd.Init(GL_TRIANGLES, 0, kFakeLargeCount);
182 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
183 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError());
184 }
185
186 TEST_F(GLES2DecoderWithShaderTest, DrawArraysBadTextureUsesBlack) { 128 TEST_F(GLES2DecoderWithShaderTest, DrawArraysBadTextureUsesBlack) {
187 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 129 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
188 // This is an NPOT texture. As the default filtering requires mips 130 // This is an NPOT texture. As the default filtering requires mips
189 // this should trigger replacing with black textures before rendering. 131 // this should trigger replacing with black textures before rendering.
190 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 132 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
191 0, 0); 133 0, 0);
192 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); 134 AddExpectationsForSimulatedAttrib0(kNumVertices, 0);
193 { 135 {
194 InSequence sequence; 136 InSequence sequence;
195 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)) 137 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0))
(...skipping 4428 matching lines...) Expand 10 before | Expand all | Expand 10 after
4624 // TODO(gman): TexImage2DImmediate 4566 // TODO(gman): TexImage2DImmediate
4625 4567
4626 // TODO(gman): TexSubImage2DImmediate 4568 // TODO(gman): TexSubImage2DImmediate
4627 4569
4628 // TODO(gman): UseProgram 4570 // TODO(gman): UseProgram
4629 4571
4630 // TODO(gman): SwapBuffers 4572 // TODO(gman): SwapBuffers
4631 4573
4632 } // namespace gles2 4574 } // namespace gles2
4633 } // namespace gpu 4575 } // 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