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

Unified Diff: gpu/command_buffer/service/program_manager.cc

Issue 2174173002: 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, 5 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 side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/program_manager.cc
diff --git a/gpu/command_buffer/service/program_manager.cc b/gpu/command_buffer/service/program_manager.cc
index ca0725533b0a172b70f41b72dd2e2b2dc1f54fc2..632f93aaeb46dc1b39b9243e9ad2ccc92313b54b 100644
--- a/gpu/command_buffer/service/program_manager.cc
+++ b/gpu/command_buffer/service/program_manager.cc
@@ -310,6 +310,11 @@ Program::Program(ProgramManager* manager, GLuint service_id)
fragment_output_written_mask_(0u) {
DCHECK(manager_);
manager_->StartTracking(this);
+ uint32_t packed_size = manager_->max_vertex_attribs() / 16;
+ packed_size += (manager_->max_vertex_attribs() % 16 == 0) ? 0 : 1;
piman 2016/07/25 20:04:04 nit: uint32_t packed_size = (manager_->max_vertex_
+ vertex_input_base_type_mask_.resize(packed_size);
+ vertex_input_active_mask_.resize(packed_size);
+ ClearVertexInputMasks();
}
void Program::Reset() {
@@ -327,8 +332,14 @@ void Program::Reset() {
attrib_location_to_index_map_.clear();
fragment_output_type_mask_ = 0u;
fragment_output_written_mask_ = 0u;
- vertex_input_base_type_mask_.clear();
- vertex_input_type_written_mask_.clear();
+ ClearVertexInputMasks();
+}
+
+void Program::ClearVertexInputMasks() {
+ for (uint32_t ii = 0; ii < vertex_input_base_type_mask_.size(); ++ii) {
+ vertex_input_base_type_mask_[ii] = 0u;
+ vertex_input_active_mask_[ii] = 0u;
+ }
}
void Program::UpdateFragmentOutputBaseTypes() {
@@ -370,27 +381,17 @@ void Program::UpdateFragmentOutputBaseTypes() {
}
void Program::UpdateVertexInputBaseTypes() {
- max_vertex_attribs_ = manager_->max_vertex_attribs();
- uint32_t packed_size = max_vertex_attribs_ / 16;
- packed_size += (max_vertex_attribs_ % 16 == 0) ? 0 : 1;
- vertex_input_base_type_mask_.resize(packed_size);
- vertex_input_type_written_mask_.resize(packed_size);
Zhenyao Mo 2016/07/23 16:10:40 We don't need to resize every link because they ne
yunchao 2016/07/24 04:52:13 Acknowledged.
-
- for (uint32_t ii = 0; ii < packed_size; ++ii) {
- vertex_input_type_written_mask_[ii] = 0u;
- vertex_input_base_type_mask_[ii] = 0u;
- }
-
+ ClearVertexInputMasks();
+ DCHECK_LE(attrib_infos_.size(), manager_->max_vertex_attribs());
for (size_t ii = 0; ii < attrib_infos_.size(); ++ii) {
- DCHECK(ii < max_vertex_attribs_);
const VertexAttrib& input = attrib_infos_[ii];
if (ProgramManager::HasBuiltInPrefix(input.name)) {
continue;
}
int shift_bits = (input.location % 16) * 2;
- vertex_input_type_written_mask_[ii / 16] |= 0x3 << shift_bits;
- vertex_input_base_type_mask_[ii / 16] |=
- InputOutputTypeToBaseType(true, input.type) << shift_bits;
+ vertex_input_active_mask_[ii / 16] |= 0x3 << shift_bits;
+ vertex_input_base_type_mask_[ii / 16] |=
+ InputOutputTypeToBaseType(true, input.type) << shift_bits;
}
}

Powered by Google App Engine
This is Rietveld 408576698