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

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

Issue 2181193002: Revert of current program can be null in ES2/ES3 contexts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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) 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/service/program_manager.h" 5 #include "gpu/command_buffer/service/program_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 service_id_(service_id), 303 service_id_(service_id),
304 deleted_(false), 304 deleted_(false),
305 valid_(false), 305 valid_(false),
306 link_status_(false), 306 link_status_(false),
307 uniforms_cleared_(false), 307 uniforms_cleared_(false),
308 transform_feedback_buffer_mode_(GL_NONE), 308 transform_feedback_buffer_mode_(GL_NONE),
309 fragment_output_type_mask_(0u), 309 fragment_output_type_mask_(0u),
310 fragment_output_written_mask_(0u) { 310 fragment_output_written_mask_(0u) {
311 DCHECK(manager_); 311 DCHECK(manager_);
312 manager_->StartTracking(this); 312 manager_->StartTracking(this);
313 uint32_t packed_size = (manager_->max_vertex_attribs() + 15) / 16;
314 vertex_input_base_type_mask_.resize(packed_size);
315 vertex_input_active_mask_.resize(packed_size);
316 ClearVertexInputMasks();
317 } 313 }
318 314
319 void Program::Reset() { 315 void Program::Reset() {
320 valid_ = false; 316 valid_ = false;
321 link_status_ = false; 317 link_status_ = false;
322 max_uniform_name_length_ = 0; 318 max_uniform_name_length_ = 0;
323 max_attrib_name_length_ = 0; 319 max_attrib_name_length_ = 0;
324 attrib_infos_.clear(); 320 attrib_infos_.clear();
325 uniform_infos_.clear(); 321 uniform_infos_.clear();
326 uniform_locations_.clear(); 322 uniform_locations_.clear();
327 fragment_input_infos_.clear(); 323 fragment_input_infos_.clear();
328 fragment_input_locations_.clear(); 324 fragment_input_locations_.clear();
329 program_output_infos_.clear(); 325 program_output_infos_.clear();
330 sampler_indices_.clear(); 326 sampler_indices_.clear();
331 attrib_location_to_index_map_.clear(); 327 attrib_location_to_index_map_.clear();
332 fragment_output_type_mask_ = 0u; 328 fragment_output_type_mask_ = 0u;
333 fragment_output_written_mask_ = 0u; 329 fragment_output_written_mask_ = 0u;
334 ClearVertexInputMasks(); 330 vertex_input_base_type_mask_.clear();
335 } 331 vertex_input_type_written_mask_.clear();
336
337 void Program::ClearVertexInputMasks() {
338 for (uint32_t ii = 0; ii < vertex_input_base_type_mask_.size(); ++ii) {
339 vertex_input_base_type_mask_[ii] = 0u;
340 vertex_input_active_mask_[ii] = 0u;
341 }
342 } 332 }
343 333
344 void Program::UpdateFragmentOutputBaseTypes() { 334 void Program::UpdateFragmentOutputBaseTypes() {
345 fragment_output_type_mask_ = 0u; 335 fragment_output_type_mask_ = 0u;
346 fragment_output_written_mask_ = 0u; 336 fragment_output_written_mask_ = 0u;
347 Shader* fragment_shader = 337 Shader* fragment_shader =
348 attached_shaders_[ShaderTypeToIndex(GL_FRAGMENT_SHADER)].get(); 338 attached_shaders_[ShaderTypeToIndex(GL_FRAGMENT_SHADER)].get();
349 DCHECK(fragment_shader); 339 DCHECK(fragment_shader);
350 for (auto const& output : fragment_shader->output_variable_list()) { 340 for (auto const& output : fragment_shader->output_variable_list()) {
351 int location = output.location; 341 int location = output.location;
(...skipping 21 matching lines...) Expand all
373 // "FragData0" and "FragData1" returns 0. 363 // "FragData0" and "FragData1" returns 0.
374 int shift_bits = ii * 2; 364 int shift_bits = ii * 2;
375 fragment_output_written_mask_ |= 0x3 << shift_bits; 365 fragment_output_written_mask_ |= 0x3 << shift_bits;
376 fragment_output_type_mask_ |= 366 fragment_output_type_mask_ |=
377 InputOutputTypeToBaseType(false, output.type) << shift_bits; 367 InputOutputTypeToBaseType(false, output.type) << shift_bits;
378 } 368 }
379 } 369 }
380 } 370 }
381 371
382 void Program::UpdateVertexInputBaseTypes() { 372 void Program::UpdateVertexInputBaseTypes() {
383 ClearVertexInputMasks(); 373 max_vertex_attribs_ = manager_->max_vertex_attribs();
384 DCHECK_LE(attrib_infos_.size(), manager_->max_vertex_attribs()); 374 uint32_t packed_size = max_vertex_attribs_ / 16;
375 packed_size += (max_vertex_attribs_ % 16 == 0) ? 0 : 1;
376 vertex_input_base_type_mask_.resize(packed_size);
377 vertex_input_type_written_mask_.resize(packed_size);
378
379 for (uint32_t ii = 0; ii < packed_size; ++ii) {
380 vertex_input_type_written_mask_[ii] = 0u;
381 vertex_input_base_type_mask_[ii] = 0u;
382 }
383
385 for (size_t ii = 0; ii < attrib_infos_.size(); ++ii) { 384 for (size_t ii = 0; ii < attrib_infos_.size(); ++ii) {
385 DCHECK(ii < max_vertex_attribs_);
386 const VertexAttrib& input = attrib_infos_[ii]; 386 const VertexAttrib& input = attrib_infos_[ii];
387 if (ProgramManager::HasBuiltInPrefix(input.name)) { 387 if (ProgramManager::HasBuiltInPrefix(input.name)) {
388 continue; 388 continue;
389 } 389 }
390 int shift_bits = (input.location % 16) * 2; 390 int shift_bits = (input.location % 16) * 2;
391 vertex_input_active_mask_[ii / 16] |= 0x3 << shift_bits; 391 vertex_input_type_written_mask_[ii / 16] |= 0x3 << shift_bits;
392 vertex_input_base_type_mask_[ii / 16] |= 392 vertex_input_base_type_mask_[ii / 16] |=
393 InputOutputTypeToBaseType(true, input.type) << shift_bits; 393 InputOutputTypeToBaseType(true, input.type) << shift_bits;
394 } 394 }
395 } 395 }
396 396
397 void Program::UpdateUniformBlockSizeInfo() { 397 void Program::UpdateUniformBlockSizeInfo() {
398 switch (feature_info().context_type()) { 398 switch (feature_info().context_type()) {
399 case CONTEXT_TYPE_OPENGLES2: 399 case CONTEXT_TYPE_OPENGLES2:
400 case CONTEXT_TYPE_WEBGL1: 400 case CONTEXT_TYPE_WEBGL1:
401 // Uniform blocks do not exist in ES2. 401 // Uniform blocks do not exist in ES2.
402 return; 402 return;
403 default: 403 default:
(...skipping 2129 matching lines...) Expand 10 before | Expand all | Expand 10 after
2533 DCHECK(program); 2533 DCHECK(program);
2534 program->ClearUniforms(&zero_); 2534 program->ClearUniforms(&zero_);
2535 } 2535 }
2536 2536
2537 int32_t ProgramManager::MakeFakeLocation(int32_t index, int32_t element) { 2537 int32_t ProgramManager::MakeFakeLocation(int32_t index, int32_t element) {
2538 return index + element * 0x10000; 2538 return index + element * 0x10000;
2539 } 2539 }
2540 2540
2541 } // namespace gles2 2541 } // namespace gles2
2542 } // namespace gpu 2542 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/program_manager.h ('k') | gpu/command_buffer/service/vertex_attrib_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698