mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-18 17:35:30 +00:00
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:
committed by
Tint LUCI CQ
parent
e5919ac115
commit
65112dc77c
71
src/sem/sampler_texture_pair.h
Normal file
71
src/sem/sampler_texture_pair.h
Normal file
@@ -0,0 +1,71 @@
|
||||
// Copyright 2021 The Tint Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef SRC_SEM_SAMPLER_TEXTURE_PAIR_H_
|
||||
#define SRC_SEM_SAMPLER_TEXTURE_PAIR_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
|
||||
#include "src/sem/binding_point.h"
|
||||
|
||||
namespace tint {
|
||||
namespace sem {
|
||||
|
||||
/// Mapping of a sampler to a texture it samples.
|
||||
struct SamplerTexturePair {
|
||||
/// group & binding values for a sampler.
|
||||
BindingPoint sampler_binding_point;
|
||||
/// group & binding values for a texture samepled by the sampler.
|
||||
BindingPoint texture_binding_point;
|
||||
|
||||
/// Equality operator
|
||||
/// @param rhs the SamplerTexturePair to compare against
|
||||
/// @returns true if this SamplerTexturePair is equal to `rhs`
|
||||
inline bool operator==(const SamplerTexturePair& rhs) const {
|
||||
return sampler_binding_point == rhs.sampler_binding_point &&
|
||||
texture_binding_point == rhs.texture_binding_point;
|
||||
}
|
||||
|
||||
/// Inequality operator
|
||||
/// @param rhs the SamplerTexturePair to compare against
|
||||
/// @returns true if this SamplerTexturePair is not equal to `rhs`
|
||||
inline bool operator!=(const SamplerTexturePair& rhs) const {
|
||||
return !(*this == rhs);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace sem
|
||||
} // namespace tint
|
||||
|
||||
namespace std {
|
||||
|
||||
/// 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::sem::SamplerTexturePair> {
|
||||
public:
|
||||
/// @param stp the texture pair to create a hash for
|
||||
/// @return the hash value
|
||||
inline std::size_t operator()(
|
||||
const tint::sem::SamplerTexturePair& stp) const {
|
||||
return tint::utils::Hash(stp.sampler_binding_point,
|
||||
stp.texture_binding_point);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace std
|
||||
|
||||
#endif // SRC_SEM_SAMPLER_TEXTURE_PAIR_H_
|
||||
Reference in New Issue
Block a user