diff --git a/src/BUILD.gn b/src/BUILD.gn index f517b74f1d..c36f031317 100644 --- a/src/BUILD.gn +++ b/src/BUILD.gn @@ -357,7 +357,6 @@ libtint_source_set("libtint_core_all_src") { "inspector/inspector.h", "inspector/resource_binding.cc", "inspector/resource_binding.h", - "inspector/sampler_texture_pair.h", "inspector/scalar.cc", "inspector/scalar.h", "intrinsic_table.cc", @@ -406,6 +405,7 @@ libtint_source_set("libtint_core_all_src") { "sem/pointer_type.h", "sem/reference_type.h", "sem/sampled_texture_type.h", + "sem/sampler_texture_pair.h", "sem/sampler_type.h", "sem/storage_texture_type.h", "sem/switch_statement.h", diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9399b6b082..be42ae5ea9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -224,7 +224,6 @@ set(TINT_LIB_SRCS inspector/inspector.h inspector/resource_binding.cc inspector/resource_binding.h - inspector/sampler_texture_pair.h inspector/scalar.cc inspector/scalar.h intrinsic_table.cc @@ -277,6 +276,7 @@ set(TINT_LIB_SRCS sem/pipeline_stage_set.h sem/node.cc sem/node.h + sem/sampler_texture_pair.h sem/statement.cc sem/struct.cc sem/type_mappings.h diff --git a/src/inspector/inspector.cc b/src/inspector/inspector.cc index a9f2f65c6f..33c8449522 100644 --- a/src/inspector/inspector.cc +++ b/src/inspector/inspector.cc @@ -524,7 +524,7 @@ std::vector Inspector::GetExternalTextureResourceBindings( ResourceBinding::ResourceType::kExternalTexture); } -std::vector Inspector::GetSamplerTextureUses( +std::vector Inspector::GetSamplerTextureUses( const std::string& entry_point) { auto* func = FindEntryPointByName(entry_point); if (!func) { @@ -774,7 +774,7 @@ void Inspector::GenerateSamplerTargets() { } sampler_targets_ = std::make_unique>>(); + std::string, utils::UniqueVector>>(); auto& sem = program_->Sem(); diff --git a/src/inspector/inspector.h b/src/inspector/inspector.h index c84233b1c1..e8f573ff55 100644 --- a/src/inspector/inspector.h +++ b/src/inspector/inspector.h @@ -24,9 +24,9 @@ #include "src/inspector/entry_point.h" #include "src/inspector/resource_binding.h" -#include "src/inspector/sampler_texture_pair.h" #include "src/inspector/scalar.h" #include "src/program.h" +#include "src/sem/sampler_texture_pair.h" #include "src/utils/unique_vector.h" namespace tint { @@ -129,7 +129,7 @@ class Inspector { /// @param entry_point name of the entry point to get information about. /// @returns vector of all of the sampler/texture sampling pairs that are used /// by that entry point. - std::vector GetSamplerTextureUses( + std::vector GetSamplerTextureUses( const std::string& entry_point); /// @param entry_point name of the entry point to get information about. @@ -141,7 +141,8 @@ class Inspector { const Program* program_; diag::List diagnostics_; std::unique_ptr< - std::unordered_map>> + std::unordered_map>> sampler_targets_; /// @param name name of the entry point to find diff --git a/src/inspector/sampler_texture_pair.h b/src/sem/sampler_texture_pair.h similarity index 80% rename from src/inspector/sampler_texture_pair.h rename to src/sem/sampler_texture_pair.h index 2af9fbe1ae..9f0135b63a 100644 --- a/src/inspector/sampler_texture_pair.h +++ b/src/sem/sampler_texture_pair.h @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef SRC_INSPECTOR_SAMPLER_TEXTURE_PAIR_H_ -#define SRC_INSPECTOR_SAMPLER_TEXTURE_PAIR_H_ +#ifndef SRC_SEM_SAMPLER_TEXTURE_PAIR_H_ +#define SRC_SEM_SAMPLER_TEXTURE_PAIR_H_ #include #include @@ -21,14 +21,14 @@ #include "src/sem/binding_point.h" namespace tint { -namespace inspector { +namespace sem { /// Mapping of a sampler to a texture it samples. struct SamplerTexturePair { /// group & binding values for a sampler. - sem::BindingPoint sampler_binding_point; + BindingPoint sampler_binding_point; /// group & binding values for a texture samepled by the sampler. - sem::BindingPoint texture_binding_point; + BindingPoint texture_binding_point; /// Equality operator /// @param rhs the SamplerTexturePair to compare against @@ -46,21 +46,21 @@ struct SamplerTexturePair { } }; -} // namespace inspector +} // namespace sem } // namespace tint namespace std { -/// Custom std::hash specialization for tint::inspector::SamplerTexturePair so +/// Custom std::hash specialization for tint::sem::SamplerTexturePair so /// SamplerTexturePairs be used as keys for std::unordered_map and /// std::unordered_set. template <> -class hash { +class hash { public: /// @param stp the texture pair to create a hash for /// @return the hash value inline std::size_t operator()( - const tint::inspector::SamplerTexturePair& stp) const { + const tint::sem::SamplerTexturePair& stp) const { return tint::utils::Hash(stp.sampler_binding_point, stp.texture_binding_point); } @@ -68,4 +68,4 @@ class hash { } // namespace std -#endif // SRC_INSPECTOR_SAMPLER_TEXTURE_PAIR_H_ +#endif // SRC_SEM_SAMPLER_TEXTURE_PAIR_H_