32 template <
typename VectorType>
33 static inline bool AreVectorUniformsEqual(
const Uniform& u0,
35 return VectorType::AreValuesEqual(u0.GetValue<VectorType>(),
36 u1.GetValue<VectorType>());
41 static inline bool AreUniformArraysEqual(
const Uniform& u0,
44 bool equal = u0.GetCount() == u1.GetCount() && u1.IsArrayOf<
T>();
46 const size_t count = u0.GetCount();
47 for (
size_t i = 0; i < count; ++i)
48 if (u0.GetValueAt<
T>(i) != u1.GetValueAt<
T>(i)) {
58 static inline bool AreUniformVectorArraysEqual(
const Uniform& u0,
61 bool equal = u0.GetCount() == u1.GetCount() && u1.IsArrayOf<
T>();
63 const size_t count = u0.GetCount();
64 for (
size_t i = 0; i < count; ++i)
65 if (!T::AreValuesEqual(u0.GetValueAt<
T>(i), u1.GetValueAt<
T>(i))) {
97 default:
return "<UNKNOWN>";
103 CHECK(
false) <<
"Unspecialized uniform Uniform::GetTypeByValue() called.";
173 template <
typename T>
174 void Uniform::MergeValuesInternal(
const Uniform& replacement) {
177 const ArrayRange this_range = ArrayRange::BuildWithSize(
179 const ArrayRange replacement_range = ArrayRange::BuildWithSize(
180 replacement.GetArrayIndex(),
181 replacement.GetCount() == 0U ? 0U : replacement.GetCount() - 1U);
183 ArrayRange final_range = this_range;
184 final_range.ExtendByRange(replacement_range);
188 final_range.GetMinPoint(),
GetType(), NULL,
189 final_range.GetSize() + 1,
191 const T* values =
GetCount() ? &GetValueAt<T>(0) : &GetValue<T>();
192 const T* replacement_values = replacement.GetCount() ?
193 &replacement.GetValueAt<
T>(0) : &replacement.GetValue<
T>();
194 size_t final_index = 0U;
195 for (
size_t i = final_range.GetMinPoint();
196 i <= final_range.GetMaxPoint(); ++i) {
197 if (replacement_range.ContainsPoint(i)) {
199 u.SetValueAt<
T>(final_index, *replacement_values++);
200 if (this_range.ContainsPoint(i))
202 }
else if (this_range.ContainsPoint(i)) {
204 u.SetValueAt<
T>(final_index, *values++);
228 if (&base == &replacement || !base.
IsValid())
250 merged->MergeValuesInternal<
float>(replacement);
253 merged->MergeValuesInternal<
int>(replacement);
256 merged->MergeValuesInternal<uint32>(replacement);
262 merged->MergeValuesInternal<
TexturePtr>(replacement);
265 merged->MergeValuesInternal<math::VectorBase2f>(replacement);
268 merged->MergeValuesInternal<math::VectorBase3f>(replacement);
271 merged->MergeValuesInternal<math::VectorBase4f>(replacement);
274 merged->MergeValuesInternal<math::VectorBase2i>(replacement);
277 merged->MergeValuesInternal<math::VectorBase3i>(replacement);
280 merged->MergeValuesInternal<math::VectorBase4i>(replacement);
283 merged->MergeValuesInternal<math::VectorBase2ui>(replacement);
286 merged->MergeValuesInternal<math::VectorBase3ui>(replacement);
289 merged->MergeValuesInternal<math::VectorBase4ui>(replacement);
300 #if !defined(ION_COVERAGE) // COV_NF_START
310 #define CHECK_UNIFORMS_EQUAL(type) \
311 if (IsArrayOf<type>()) \
312 equal = AreUniformArraysEqual<type>(*this, other); \
314 equal = GetValue<type>() == other.GetValue<type>();
316 #define CHECK_VECTOR_UNIFORMS_EQUAL(type) \
317 if (IsArrayOf<type>()) \
318 equal = AreUniformVectorArraysEqual<type>(*this, other); \
320 equal = AreVectorUniformsEqual<type>(*this, other);
379 #if !defined(ION_COVERAGE) // COV_NF_START
390 #undef CHECK_UNIFORMS_EQUAL
391 #undef CHECK_VECTOR_UNIFORMS_EQUAL
The Range class defines an N-dimensional interval defined by minimum and maximum N-dimensional endpoi...
Matrix< 3, float > Matrix3f
The Matrix class defines a square N-dimensional matrix.
Copyright 2016 Google Inc.
A SharedPtr is a smart shared pointer to an instance of some class that implements reference counting...
UniformType
The UniformType enum defines all supported uniform shader argument types.