Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit f331e0a

Browse files
Reverts "[Impeller] pass const ref to binding helpers." (#48330)
Reverts #48318 Initiated by: jonahwilliams This change reverts the following previous change: Original Description: No point in passing by value and moving, just pass a const ref through. Trivial performance improvement. # Before ```cpp /// Bind uniform buffer for resource named FragInfo. static bool BindFragInfo(ResourceBinder& command, BufferView view) { return command.BindResource(ShaderStage::kFragment, kResourceFragInfo, kMetadataFragInfo, std::move(view)); } /// Bind combined image sampler for resource named texture_sampler. static bool BindTextureSampler(ResourceBinder& command, std::shared_ptr<const Texture> texture, std::shared_ptr<const Sampler> sampler) { return command.BindResource(ShaderStage::kFragment, kResourceTextureSampler, kMetadataTextureSampler, std::move(texture), std::move(sampler)); } ``` # After ```cpp /// Bind uniform buffer for resource named FragInfo. static bool BindFragInfo(ResourceBinder& command, const BufferView& view) { return command.BindResource(ShaderStage::kFragment, kResourceFragInfo, kMetadataFragInfo, view); } /// Bind combined image sampler for resource named texture_sampler. static bool BindTextureSampler(ResourceBinder& command, const std::shared_ptr<const Texture>& texture, const std::shared_ptr<const Sampler>& sampler) { return command.BindResource(ShaderStage::kFragment, kResourceTextureSampler, kMetadataTextureSampler, texture, sampler); } ```
1 parent 32a6383 commit f331e0a

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

impeller/compiler/code_gen_template.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ struct {{camel_case(shader_name)}}{{camel_case(shader_stage)}}Shader {
163163
return {{ proto.args.0.argument_name }}.BindResource({% for arg in proto.args %}
164164
{% if loop.is_first %}
165165
{{to_shader_stage(shader_stage)}}, kResource{{ proto.name }}, kMetadata{{ proto.name }}, {% else %}
166-
{{ arg.argument_name }}{% if not loop.is_last %}, {% endif %}
166+
std::move({{ arg.argument_name }}){% if not loop.is_last %}, {% endif %}
167167
{% endif %}
168168
{% endfor %});
169169
}

impeller/compiler/reflector.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,7 @@ std::vector<Reflector::BindPrototype> Reflector::ReflectBindPrototypes(
11371137
.argument_name = "command",
11381138
});
11391139
proto.args.push_back(BindPrototypeArgument{
1140-
.type_name = "const BufferView&",
1140+
.type_name = "BufferView",
11411141
.argument_name = "view",
11421142
});
11431143
}
@@ -1156,7 +1156,7 @@ std::vector<Reflector::BindPrototype> Reflector::ReflectBindPrototypes(
11561156
.argument_name = "command",
11571157
});
11581158
proto.args.push_back(BindPrototypeArgument{
1159-
.type_name = "const BufferView&",
1159+
.type_name = "BufferView",
11601160
.argument_name = "view",
11611161
});
11621162
}
@@ -1175,11 +1175,11 @@ std::vector<Reflector::BindPrototype> Reflector::ReflectBindPrototypes(
11751175
.argument_name = "command",
11761176
});
11771177
proto.args.push_back(BindPrototypeArgument{
1178-
.type_name = "const std::shared_ptr<const Texture>&",
1178+
.type_name = "std::shared_ptr<const Texture>",
11791179
.argument_name = "texture",
11801180
});
11811181
proto.args.push_back(BindPrototypeArgument{
1182-
.type_name = "const std::shared_ptr<const Sampler>&",
1182+
.type_name = "std::shared_ptr<const Sampler>",
11831183
.argument_name = "sampler",
11841184
});
11851185
}
@@ -1198,7 +1198,7 @@ std::vector<Reflector::BindPrototype> Reflector::ReflectBindPrototypes(
11981198
.argument_name = "command",
11991199
});
12001200
proto.args.push_back(BindPrototypeArgument{
1201-
.type_name = "const std::shared_ptr<const Texture>&",
1201+
.type_name = "std::shared_ptr<const Texture>",
12021202
.argument_name = "texture",
12031203
});
12041204
}
@@ -1217,7 +1217,7 @@ std::vector<Reflector::BindPrototype> Reflector::ReflectBindPrototypes(
12171217
.argument_name = "command",
12181218
});
12191219
proto.args.push_back(BindPrototypeArgument{
1220-
.type_name = "const std::shared_ptr<const Sampler>&",
1220+
.type_name = "std::shared_ptr<const Sampler>",
12211221
.argument_name = "sampler",
12221222
});
12231223
}

0 commit comments

Comments
 (0)