struct BufferRamCreationDispatcher {
template <typename Result, typename T>
Result operator()(size_t size, BufferUsage usage, BufferTarget target) {
using F = typename T::type;
switch (target) {
case BufferTarget::Index:
return std::make_shared<BufferRAMPrecision<F, BufferTarget::Index>>(size, usage);
case BufferTarget::Data:
default:
return std::make_shared<BufferRAMPrecision<F, BufferTarget::Data>>(size, usage);
}
}
};
std::shared_ptr<BufferRAM>
createBufferRAM(
size_t size,
const DataFormatBase *format,
BufferUsage usage, BufferTarget target) {
BufferRamCreationDispatcher disp;
return dispatching::dispatch<std::shared_ptr<BufferRAM>, dispatching::filter::All>(
format->getId(), disp, size, usage, target);
}