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

Side by Side Diff: gpu/command_buffer/client/program_info_manager_unittest.cc

Issue 894373004: Add glGetActiveUniformBlockiv to GPU command buffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix win bots Created 5 years, 10 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
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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/client/program_info_manager.h" 5 #include "gpu/command_buffer/client/program_info_manager.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 7
8 namespace { 8 namespace {
9 9
10 uint32 ComputeOffset(const void* start, const void* position) { 10 uint32 ComputeOffset(const void* start, const void* position) {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 EXPECT_EQ(0, length); 172 EXPECT_EQ(0, length);
173 173
174 // Test buf_size smaller than string size. 174 // Test buf_size smaller than string size.
175 buf_size = strlen(data.name0); 175 buf_size = strlen(data.name0);
176 EXPECT_EQ(true, program_info_manager_->GetActiveUniformBlockName( 176 EXPECT_EQ(true, program_info_manager_->GetActiveUniformBlockName(
177 NULL, kClientProgramId, 0, buf_size, &length, &buffer[0])); 177 NULL, kClientProgramId, 0, buf_size, &length, &buffer[0]));
178 EXPECT_EQ(buf_size, length + 1); 178 EXPECT_EQ(buf_size, length + 1);
179 EXPECT_STREQ(std::string(data.name0).substr(0, length).c_str(), &buffer[0]); 179 EXPECT_STREQ(std::string(data.name0).substr(0, length).c_str(), &buffer[0]);
180 } 180 }
181 181
182 TEST_F(ProgramInfoManagerTest, GetActiveUniformBlockivCached) {
183 UniformBlocksData data;
184 SetupUniformBlocksData(&data);
185 std::vector<int8> result(sizeof(data));
186 memcpy(&result[0], &data, sizeof(data));
187 program_->UpdateES3UniformBlocks(result);
188 const char* kName[] = { data.name0, data.name1 };
189 const uint32_t* kIndices[] = { data.indices0, data.indices1 };
190
191 for (uint32_t ii = 0; ii < data.header.num_uniform_blocks; ++ii) {
192 ASSERT_GE(2u, data.entry[ii].active_uniforms);
193 GLint params[2];
194 EXPECT_EQ(true, program_info_manager_->GetActiveUniformBlockiv(
195 NULL, kClientProgramId, ii, GL_UNIFORM_BLOCK_BINDING, params));
196 EXPECT_EQ(data.entry[ii].binding, static_cast<uint32_t>(params[0]));
197
198 EXPECT_EQ(true, program_info_manager_->GetActiveUniformBlockiv(
199 NULL, kClientProgramId, ii, GL_UNIFORM_BLOCK_DATA_SIZE, params));
200 EXPECT_EQ(data.entry[ii].data_size, static_cast<uint32_t>(params[0]));
201
202 EXPECT_EQ(true, program_info_manager_->GetActiveUniformBlockiv(
203 NULL, kClientProgramId, ii, GL_UNIFORM_BLOCK_NAME_LENGTH, params));
204 EXPECT_EQ(strlen(kName[ii]) + 1, static_cast<uint32_t>(params[0]));
205
206 EXPECT_EQ(true, program_info_manager_->GetActiveUniformBlockiv(
207 NULL, kClientProgramId, ii, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, params));
208 EXPECT_EQ(data.entry[ii].active_uniforms, static_cast<uint32_t>(params[0]));
209
210 EXPECT_EQ(true, program_info_manager_->GetActiveUniformBlockiv(
211 NULL, kClientProgramId, ii,
212 GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES, params));
213 for (uint32_t uu = 0; uu < data.entry[ii].active_uniforms; ++uu) {
214 EXPECT_EQ(kIndices[ii][uu], static_cast<uint32_t>(params[uu]));
215 }
216
217 EXPECT_EQ(true, program_info_manager_->GetActiveUniformBlockiv(
218 NULL, kClientProgramId, ii,
219 GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER, params));
220 EXPECT_EQ(data.entry[ii].referenced_by_vertex_shader,
221 static_cast<uint32_t>(params[0]));
222
223 EXPECT_EQ(true, program_info_manager_->GetActiveUniformBlockiv(
224 NULL, kClientProgramId, ii,
225 GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER, params));
226 EXPECT_EQ(data.entry[ii].referenced_by_fragment_shader,
227 static_cast<uint32_t>(params[0]));
228 }
229 }
230
182 } // namespace gles2 231 } // namespace gles2
183 } // namespace gpu 232 } // namespace gpu
184 233
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/program_info_manager.cc ('k') | gpu/command_buffer/cmd_buffer_functions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698