Move SamplerTexturePair from inspector to sem.

The plan is to reuse this datatype for the combine-samplers transform.

Bug: tint:1366
Change-Id: Icd2f4bd45b662f32fe9803e3485f1a54a2c42265
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76320
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
This commit is contained in:
Stephen White 2022-01-14 20:08:42 +00:00 committed by Tint LUCI CQ
parent e5919ac115
commit 65112dc77c
5 changed files with 18 additions and 17 deletions

View File

@ -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",

View File

@ -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

View File

@ -524,7 +524,7 @@ std::vector<ResourceBinding> Inspector::GetExternalTextureResourceBindings(
ResourceBinding::ResourceType::kExternalTexture);
}
std::vector<SamplerTexturePair> Inspector::GetSamplerTextureUses(
std::vector<sem::SamplerTexturePair> 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::unordered_map<
std::string, utils::UniqueVector<SamplerTexturePair>>>();
std::string, utils::UniqueVector<sem::SamplerTexturePair>>>();
auto& sem = program_->Sem();

View File

@ -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<SamplerTexturePair> GetSamplerTextureUses(
std::vector<sem::SamplerTexturePair> 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::string, utils::UniqueVector<SamplerTexturePair>>>
std::unordered_map<std::string,
utils::UniqueVector<sem::SamplerTexturePair>>>
sampler_targets_;
/// @param name name of the entry point to find

View File

@ -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 <cstdint>
#include <functional>
@ -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<tint::inspector::SamplerTexturePair> {
class hash<tint::sem::SamplerTexturePair> {
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<tint::inspector::SamplerTexturePair> {
} // namespace std
#endif // SRC_INSPECTOR_SAMPLER_TEXTURE_PAIR_H_
#endif // SRC_SEM_SAMPLER_TEXTURE_PAIR_H_