Overte C++ Documentation
GpuHelpers.h
1 //
2 // Copyright 2018 High Fidelity, Inc.
3 //
4 // Distributed under the Apache License, Version 2.0.
5 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
6 //
7 #pragma once
8 
9 #include <QtCore>
10 #include <gpu/Format.h>
11 #include <gpu/Stream.h>
12 #include "Geometry.h"
13 
14 template <typename T>
15 using DebugEnums = QMap<T, QString>;
16 
17 namespace graphics {
18  extern DebugEnums<Mesh::Topology> TOPOLOGIES;
19  inline QDebug operator<<(QDebug dbg, Mesh::Topology type) { return dbg << TOPOLOGIES.value(type);}
20  inline const QString toString(Mesh::Topology v) { return TOPOLOGIES.value(v); }
21 }
22 
23 namespace gpu {
24  extern DebugEnums<Type> TYPES;
25  extern DebugEnums<Dimension> DIMENSIONS;
26  extern DebugEnums<Semantic> SEMANTICS;
27  extern DebugEnums<Stream::InputSlot> SLOTS;
28  inline QDebug operator<<(QDebug dbg, gpu::Type type) { return dbg << TYPES.value(type); }
29  inline QDebug operator<<(QDebug dbg, gpu::Dimension type) { return dbg << DIMENSIONS.value(type); }
30  inline QDebug operator<<(QDebug dbg, gpu::Semantic type) { return dbg << SEMANTICS.value(type); }
31  inline QDebug operator<<(QDebug dbg, gpu::Stream::InputSlot type) { return dbg << SLOTS.value(type); }
32  inline const QString toString(gpu::Type v) { return TYPES.value(v); }
33  inline const QString toString(gpu::Dimension v) { return DIMENSIONS.value(v); }
34  inline const QString toString(gpu::Semantic v) { return SEMANTICS.value(v); }
35  inline const QString toString(gpu::Stream::InputSlot v) { return SLOTS.value(v); }
36  inline const QString toString(gpu::Element v) {
37  return QString("[Element semantic=%1 type=%1 dimension=%2]")
38  .arg(toString(v.getSemantic()))
39  .arg(toString(v.getType()))
40  .arg(toString(v.getDimension()));
41  }
42 }
43 
44 Q_DECLARE_METATYPE(gpu::Type)
45 Q_DECLARE_METATYPE(gpu::Dimension)
46 Q_DECLARE_METATYPE(gpu::Semantic)
47 Q_DECLARE_METATYPE(graphics::Mesh::Topology)