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

Side by Side Diff: gpu/command_buffer/tests/gl_test_utils.cc

Issue 2410343002: [Reland] Add gl tests to make sure when a buffer is unmapped, all access path generates an INVALID_… (Closed)
Patch Set: Skip the test if context creation fails. Created 4 years, 2 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/tests/gl_test_utils.h ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/tests/gl_test_utils.h" 5 #include "gpu/command_buffer/tests/gl_test_utils.h"
6 6
7 #include <GLES2/gl2extchromium.h> 7 #include <GLES2/gl2extchromium.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <stdio.h> 9 #include <stdio.h>
10 10
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 if (!vertex_shader || !fragment_shader) { 154 if (!vertex_shader || !fragment_shader) {
155 return 0; 155 return 0;
156 } 156 }
157 return SetupProgram(vertex_shader, fragment_shader); 157 return SetupProgram(vertex_shader, fragment_shader);
158 } 158 }
159 159
160 GLuint GLTestHelper::SetupUnitQuad(GLint position_location) { 160 GLuint GLTestHelper::SetupUnitQuad(GLint position_location) {
161 GLuint vbo = 0; 161 GLuint vbo = 0;
162 glGenBuffers(1, &vbo); 162 glGenBuffers(1, &vbo);
163 glBindBuffer(GL_ARRAY_BUFFER, vbo); 163 glBindBuffer(GL_ARRAY_BUFFER, vbo);
164 static float vertices[] = { 164 static const float vertices[] = {
165 1.0f, 1.0f, 165 1.0f, 1.0f, -1.0f, 1.0f, -1.0f, -1.0f,
166 -1.0f, 1.0f, 166 1.0f, 1.0f, -1.0f, -1.0f, 1.0f, -1.0f,
167 -1.0f, -1.0f,
168 1.0f, 1.0f,
169 -1.0f, -1.0f,
170 1.0f, -1.0f,
171 }; 167 };
172 glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); 168 glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
173 glEnableVertexAttribArray(position_location); 169 glEnableVertexAttribArray(position_location);
174 glVertexAttribPointer(position_location, 2, GL_FLOAT, GL_FALSE, 0, 0); 170 glVertexAttribPointer(position_location, 2, GL_FLOAT, GL_FALSE, 0, 0);
175 171
176 return vbo; 172 return vbo;
177 } 173 }
178 174
175 std::vector<GLuint> GLTestHelper::SetupIndexedUnitQuad(
176 GLint position_location) {
177 GLuint array_buffer = SetupUnitQuad(position_location);
178 static const uint8_t indices[] = {0, 1, 2, 3, 4, 5};
179 GLuint index_buffer = 0;
180 glGenBuffers(1, &index_buffer);
181 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, index_buffer);
182 glBufferData(GL_ELEMENT_ARRAY_BUFFER, 6, indices, GL_STATIC_DRAW);
183 std::vector<GLuint> buffers(2);
184 buffers[0] = array_buffer;
185 buffers[1] = index_buffer;
186 return buffers;
187 }
188
179 GLuint GLTestHelper::SetupColorsForUnitQuad( 189 GLuint GLTestHelper::SetupColorsForUnitQuad(
180 GLint location, const GLfloat color[4], GLenum usage) { 190 GLint location, const GLfloat color[4], GLenum usage) {
181 GLuint vbo = 0; 191 GLuint vbo = 0;
182 glGenBuffers(1, &vbo); 192 glGenBuffers(1, &vbo);
183 glBindBuffer(GL_ARRAY_BUFFER, vbo); 193 glBindBuffer(GL_ARRAY_BUFFER, vbo);
184 GLfloat vertices[6 * 4]; 194 GLfloat vertices[6 * 4];
185 for (int ii = 0; ii < 6; ++ii) { 195 for (int ii = 0; ii < 6; ++ii) {
186 for (int jj = 0; jj < 4; ++jj) { 196 for (int jj = 0; jj < 4; ++jj) {
187 vertices[ii * 4 + jj] = color[jj]; 197 vertices[ii * 4 + jj] = color[jj];
188 } 198 }
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 ASSERT_NE(sampler_location, -1); 346 ASSERT_NE(sampler_location, -1);
337 347
338 GLuint vertex_buffer = GLTestHelper::SetupUnitQuad(sampler_location); 348 GLuint vertex_buffer = GLTestHelper::SetupUnitQuad(sampler_location);
339 glDrawArrays(GL_TRIANGLES, 0, 6); 349 glDrawArrays(GL_TRIANGLES, 0, 6);
340 350
341 glDeleteShader(vertex_shader); 351 glDeleteShader(vertex_shader);
342 glDeleteShader(fragment_shader); 352 glDeleteShader(fragment_shader);
343 glDeleteProgram(program); 353 glDeleteProgram(program);
344 glDeleteBuffers(1, &vertex_buffer); 354 glDeleteBuffers(1, &vertex_buffer);
345 } 355 }
OLDNEW
« no previous file with comments | « gpu/command_buffer/tests/gl_test_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698