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

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

Issue 1309743005: command_buffer: Implement EXT_blend_func_extended (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@new-05-path-fragment-input-gen
Patch Set: ~ Created 5 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 side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/memory_program_cache.cc
diff --git a/gpu/command_buffer/service/memory_program_cache.cc b/gpu/command_buffer/service/memory_program_cache.cc
index 74809a98d7399f79df3c81402583ad43365e9df5..bd918c8ec6965e01d03712ff322dfe69f65b6aa0 100644
--- a/gpu/command_buffer/service/memory_program_cache.cc
+++ b/gpu/command_buffer/service/memory_program_cache.cc
@@ -40,12 +40,6 @@ namespace gles2 {
namespace {
-enum ShaderMapType {
- ATTRIB_MAP = 0,
- UNIFORM_MAP,
- VARYING_MAP
Mark Kilgard 2015/08/28 19:53:24 agreed, never used later
-};
-
void FillShaderVariableProto(
ShaderVariableProto* proto, const sh::ShaderVariable& variable) {
proto->set_type(variable.type);
@@ -97,6 +91,11 @@ void FillShaderProto(ShaderProto* proto, const char* sha,
ShaderVaryingProto* info = proto->add_varyings();
FillShaderVaryingProto(info, iter->second);
}
+ for (auto iter = shader->output_variable_list().begin();
+ iter != shader->output_variable_list().end(); ++iter) {
+ ShaderAttributeProto* info = proto->add_output_variables();
+ FillShaderAttributeProto(info, *iter);
+ }
}
void RetrieveShaderVariableInfo(
@@ -121,6 +120,14 @@ void RetrieveShaderAttributeInfo(
(*map)[proto.basic().mapped_name()] = attrib;
}
+void RetrieveShaderOutputVariableInfo(const ShaderAttributeProto& proto,
+ AttributeList* list) {
+ sh::Attribute attrib;
+ RetrieveShaderVariableInfo(proto.basic(), &attrib);
+ attrib.location = proto.location();
+ list->push_back(attrib);
+}
+
void RetrieveShaderUniformInfo(
const ShaderUniformProto& proto, UniformMap* map) {
sh::Uniform uniform;
@@ -213,9 +220,11 @@ ProgramCache::ProgramLoadResult MemoryProgramCache::LoadLinkedProgram(
shader_a->set_attrib_map(value->attrib_map_0());
shader_a->set_uniform_map(value->uniform_map_0());
shader_a->set_varying_map(value->varying_map_0());
+ shader_a->set_output_variable_list(value->output_variable_list_0());
shader_b->set_attrib_map(value->attrib_map_1());
shader_b->set_uniform_map(value->uniform_map_1());
shader_b->set_varying_map(value->varying_map_1());
+ shader_b->set_output_variable_list(value->output_variable_list_1());
if (!shader_callback.is_null() &&
!base::CommandLine::ForCurrentProcess()->HasSwitch(
@@ -302,20 +311,14 @@ void MemoryProgramCache::SaveLinkedProgram(
RunShaderCallback(shader_callback, proto.get(), sha_string);
}
- store_.Put(sha_string,
- new ProgramCacheValue(length,
- format,
- binary.release(),
- sha_string,
- a_sha,
- shader_a->attrib_map(),
- shader_a->uniform_map(),
- shader_a->varying_map(),
- b_sha,
- shader_b->attrib_map(),
- shader_b->uniform_map(),
- shader_b->varying_map(),
- this));
+ store_.Put(
+ sha_string,
+ new ProgramCacheValue(
+ length, format, binary.release(), sha_string, a_sha,
+ shader_a->attrib_map(), shader_a->uniform_map(),
+ shader_a->varying_map(), shader_a->output_variable_list(), b_sha,
+ shader_b->attrib_map(), shader_b->uniform_map(),
+ shader_b->varying_map(), shader_b->output_variable_list(), this));
UMA_HISTOGRAM_COUNTS("GPU.ProgramCache.MemorySizeAfterKb",
curr_size_bytes_ / 1024);
@@ -327,6 +330,7 @@ void MemoryProgramCache::LoadProgram(const std::string& program) {
AttributeMap vertex_attribs;
UniformMap vertex_uniforms;
VaryingMap vertex_varyings;
+ AttributeList vertex_output_variables;
for (int i = 0; i < proto->vertex_shader().attribs_size(); i++) {
RetrieveShaderAttributeInfo(proto->vertex_shader().attribs(i),
&vertex_attribs);
@@ -339,10 +343,15 @@ void MemoryProgramCache::LoadProgram(const std::string& program) {
RetrieveShaderVaryingInfo(proto->vertex_shader().varyings(i),
&vertex_varyings);
}
+ for (int i = 0; i < proto->vertex_shader().output_variables_size(); i++) {
+ RetrieveShaderOutputVariableInfo(
+ proto->vertex_shader().output_variables(i), &vertex_output_variables);
+ }
AttributeMap fragment_attribs;
UniformMap fragment_uniforms;
VaryingMap fragment_varyings;
+ AttributeList fragment_output_variables;
for (int i = 0; i < proto->fragment_shader().attribs_size(); i++) {
RetrieveShaderAttributeInfo(proto->fragment_shader().attribs(i),
&fragment_attribs);
@@ -355,24 +364,24 @@ void MemoryProgramCache::LoadProgram(const std::string& program) {
RetrieveShaderVaryingInfo(proto->fragment_shader().varyings(i),
&fragment_varyings);
}
+ for (int i = 0; i < proto->fragment_shader().output_variables_size(); i++) {
+ RetrieveShaderOutputVariableInfo(
+ proto->fragment_shader().output_variables(i),
+ &fragment_output_variables);
+ }
scoped_ptr<char[]> binary(new char[proto->program().length()]);
memcpy(binary.get(), proto->program().c_str(), proto->program().length());
- store_.Put(proto->sha(),
- new ProgramCacheValue(proto->program().length(),
- proto->format(),
- binary.release(),
- proto->sha(),
- proto->vertex_shader().sha().c_str(),
- vertex_attribs,
- vertex_uniforms,
- vertex_varyings,
- proto->fragment_shader().sha().c_str(),
- fragment_attribs,
- fragment_uniforms,
- fragment_varyings,
- this));
+ store_.Put(
+ proto->sha(),
+ new ProgramCacheValue(
+ proto->program().length(), proto->format(), binary.release(),
+ proto->sha(), proto->vertex_shader().sha().c_str(), vertex_attribs,
+ vertex_uniforms, vertex_varyings, vertex_output_variables,
+ proto->fragment_shader().sha().c_str(), fragment_attribs,
+ fragment_uniforms, fragment_varyings, fragment_output_variables,
+ this));
Mark Kilgard 2015/08/28 19:53:24 ignoring the code reformatting clean-up, the subst
UMA_HISTOGRAM_COUNTS("GPU.ProgramCache.MemorySizeAfterKb",
curr_size_bytes_ / 1024);
@@ -390,10 +399,12 @@ MemoryProgramCache::ProgramCacheValue::ProgramCacheValue(
const AttributeMap& attrib_map_0,
const UniformMap& uniform_map_0,
const VaryingMap& varying_map_0,
+ const AttributeList& output_variable_list_0,
const char* shader_1_hash,
const AttributeMap& attrib_map_1,
const UniformMap& uniform_map_1,
const VaryingMap& varying_map_1,
+ const AttributeList& output_variable_list_1,
MemoryProgramCache* program_cache)
: length_(length),
format_(format),
@@ -403,10 +414,12 @@ MemoryProgramCache::ProgramCacheValue::ProgramCacheValue(
attrib_map_0_(attrib_map_0),
uniform_map_0_(uniform_map_0),
varying_map_0_(varying_map_0),
+ output_variable_list_0_(output_variable_list_0),
shader_1_hash_(shader_1_hash, kHashLength),
attrib_map_1_(attrib_map_1),
uniform_map_1_(uniform_map_1),
varying_map_1_(varying_map_1),
+ output_variable_list_1_(output_variable_list_1),
program_cache_(program_cache) {
program_cache_->curr_size_bytes_ += length_;
program_cache_->LinkedProgramCacheSuccess(program_hash);

Powered by Google App Engine
This is Rietveld 408576698