29 "Input type must be subscriptable.");
32 "Output type must be subscriptable.");
36 using InputElement = std::remove_cvref_t<decltype(std::declval<InputT>()[std::declval<std::size_t>()])>;
37 using OutputElement = std::remove_cvref_t<decltype(std::declval<OutputT>()[std::declval<std::size_t>()])>;
39 static_assert(std::is_convertible_v<InputElement, OutputElement>,
40 "Array element of input type is not convertible to the array element of output type.");
48 std::array<uint8, OUTPUT_N> swizzleMap) :
52 m_inputTexture(
std::move(inputTexture)),
53 m_swizzleMap (
std::move(swizzleMap))
58 PH_ASSERT(m_inputTexture);
62 m_inputTexture->sample(sampleLocation, &inputValue);
64 *out_value = OutputT{};
65 for(std::size_t oi = 0; oi < OUTPUT_N; ++oi)
67 const std::size_t mappedIndex = m_swizzleMap[oi];
68 (*out_value)[oi] =
static_cast<OutputElement>(inputValue[mappedIndex]);
74 std::array<uint8, OUTPUT_N> m_swizzleMap;
Swizzle an array-like input type to the other array-like output type. Output type OutputT can have an...
Definition TSwizzledTexture.h:27
TSwizzledTexture(InputTexRes inputTexture, std::array< uint8, OUTPUT_N > swizzleMap)
Definition TSwizzledTexture.h:46
std::remove_cvref_t< decltype(std::declval< OutputT >()[std::declval< std::size_t >()])> OutputElement
Definition TSwizzledTexture.h:37
std::remove_cvref_t< decltype(std::declval< InputT >()[std::declval< std::size_t >()])> InputElement
Definition TSwizzledTexture.h:36
std::shared_ptr< TTexture< InputT > > InputTexRes
Definition TSwizzledTexture.h:35
void sample(const SampleLocation &sampleLocation, OutputT *const out_value) const override
Definition TSwizzledTexture.h:56