-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] Store Buffer/Texture bindings in vector instead of map. #48719
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -120,10 +120,9 @@ struct {{camel_case(shader_name)}}{{camel_case(shader_stage)}}Shader { | |
|
|
||
| static constexpr auto kResource{{camel_case(sampled_image.name)}} = SampledImageSlot { // {{sampled_image.name}} | ||
| "{{sampled_image.name}}", // name | ||
| {{sampled_image.ext_res_0}}u, // texture | ||
| {{sampled_image.ext_res_1}}u, // sampler | ||
| {{sampled_image.binding}}u, // binding | ||
| {{sampled_image.ext_res_0}}u, // ext_res_0 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we have a better name for this? This represents which texture unit this will be bound to right?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Back to texture_index, with a note that this is ext_res_0 |
||
| {{sampled_image.set}}u, // set | ||
| {{sampled_image.binding}}u, // binding | ||
| }; | ||
| static ShaderMetadata kMetadata{{camel_case(sampled_image.name)}}; | ||
| {% endfor %} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,26 +11,34 @@ namespace impeller { | |
| /// @brief Retrieve the [VertInfo] struct data from the provided [command]. | ||
| template <typename T> | ||
| typename T::VertInfo* GetVertInfo(const Command& command) { | ||
| auto resource = command.vertex_bindings.buffers.find(0u); | ||
| auto resource = std::find_if(command.vertex_bindings.buffers.begin(), | ||
| command.vertex_bindings.buffers.end(), | ||
| [](const BufferAndUniformSlot& data) { | ||
| return data.slot.ext_res_0 == 0u; | ||
| }); | ||
| if (resource == command.vertex_bindings.buffers.end()) { | ||
| return nullptr; | ||
| } | ||
|
|
||
| auto data = (resource->second.view.resource.contents + | ||
| resource->second.view.resource.range.offset); | ||
| auto data = | ||
| (resource->view.resource.contents + resource->view.resource.range.offset); | ||
| return reinterpret_cast<typename T::VertInfo*>(data); | ||
| } | ||
|
|
||
| /// @brief Retrieve the [FragInfo] struct data from the provided [command]. | ||
| template <typename T> | ||
| typename T::FragInfo* GetFragInfo(const Command& command) { | ||
| auto resource = command.fragment_bindings.buffers.find(0u); | ||
| auto resource = std::find_if(command.fragment_bindings.buffers.begin(), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So we are getting linear search here hopefully? This should be faster for the small sizes we have.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just for testing, so performance doesnt matter as much
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We dont ever have to look up particular bindings, we just iterate through the set of bindings and bind each one. |
||
| command.fragment_bindings.buffers.end(), | ||
| [](const BufferAndUniformSlot& data) { | ||
| return data.slot.ext_res_0 == 0u; | ||
| }); | ||
| if (resource == command.fragment_bindings.buffers.end()) { | ||
| return nullptr; | ||
| } | ||
|
|
||
| auto data = (resource->second.view.resource.contents + | ||
| resource->second.view.resource.range.offset); | ||
| auto data = | ||
| (resource->view.resource.contents + resource->view.resource.range.offset); | ||
| return reinterpret_cast<typename T::FragInfo*>(data); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was unused