hecl/Compilers: Make name strings constexpr

Same behavior (as of C++17), without the need to duplicate the variable
name.
This commit is contained in:
Lioncash 2019-08-23 11:40:12 -04:00
parent e691b95cbf
commit 3b60cee576
2 changed files with 11 additions and 28 deletions

View File

@ -12,35 +12,35 @@ using PlatformEnum = boo::IGraphicsDataFactory::Platform;
struct Null {}; struct Null {};
struct OpenGL { struct OpenGL {
static constexpr PlatformEnum Enum = PlatformEnum::OpenGL; static constexpr PlatformEnum Enum = PlatformEnum::OpenGL;
static const char* Name; static constexpr char Name[] = "OpenGL";
#if BOO_HAS_GL #if BOO_HAS_GL
using Context = boo::GLDataFactory::Context; using Context = boo::GLDataFactory::Context;
#endif #endif
}; };
struct D3D11 { struct D3D11 {
static constexpr PlatformEnum Enum = PlatformEnum::D3D11; static constexpr PlatformEnum Enum = PlatformEnum::D3D11;
static const char* Name; static constexpr char Name[] = "D3D11";
#if _WIN32 #if _WIN32
using Context = boo::D3D11DataFactory::Context; using Context = boo::D3D11DataFactory::Context;
#endif #endif
}; };
struct Metal { struct Metal {
static constexpr PlatformEnum Enum = PlatformEnum::Metal; static constexpr PlatformEnum Enum = PlatformEnum::Metal;
static const char* Name; static constexpr char Name[] = "Metal";
#if BOO_HAS_METAL #if BOO_HAS_METAL
using Context = boo::MetalDataFactory::Context; using Context = boo::MetalDataFactory::Context;
#endif #endif
}; };
struct Vulkan { struct Vulkan {
static constexpr PlatformEnum Enum = PlatformEnum::Vulkan; static constexpr PlatformEnum Enum = PlatformEnum::Vulkan;
static const char* Name; static constexpr char Name[] = "Vulkan";
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
using Context = boo::VulkanDataFactory::Context; using Context = boo::VulkanDataFactory::Context;
#endif #endif
}; };
struct NX { struct NX {
static constexpr PlatformEnum Enum = PlatformEnum::NX; static constexpr PlatformEnum Enum = PlatformEnum::NX;
static const char* Name; static constexpr char Name[] = "NX";
#if BOO_HAS_NX #if BOO_HAS_NX
using Context = boo::NXDataFactory::Context; using Context = boo::NXDataFactory::Context;
#endif #endif
@ -51,27 +51,27 @@ namespace PipelineStage {
using StageEnum = boo::PipelineStage; using StageEnum = boo::PipelineStage;
struct Null { struct Null {
static constexpr StageEnum Enum = StageEnum::Null; static constexpr StageEnum Enum = StageEnum::Null;
static const char* Name; static constexpr char Name[] = "Null";
}; };
struct Vertex { struct Vertex {
static constexpr StageEnum Enum = StageEnum::Vertex; static constexpr StageEnum Enum = StageEnum::Vertex;
static const char* Name; static constexpr char Name[] = "Vertex";
}; };
struct Fragment { struct Fragment {
static constexpr StageEnum Enum = StageEnum::Fragment; static constexpr StageEnum Enum = StageEnum::Fragment;
static const char* Name; static constexpr char Name[] = "Fragment";
}; };
struct Geometry { struct Geometry {
static constexpr StageEnum Enum = StageEnum::Geometry; static constexpr StageEnum Enum = StageEnum::Geometry;
static const char* Name; static constexpr char Name[] = "Geometry";
}; };
struct Control { struct Control {
static constexpr StageEnum Enum = StageEnum::Control; static constexpr StageEnum Enum = StageEnum::Control;
static const char* Name; static constexpr char Name[] = "Control";
}; };
struct Evaluation { struct Evaluation {
static constexpr StageEnum Enum = StageEnum::Evaluation; static constexpr StageEnum Enum = StageEnum::Evaluation;
static const char* Name; static constexpr char Name[] = "Evaluation";
}; };
} // namespace PipelineStage } // namespace PipelineStage

View File

@ -17,23 +17,6 @@ extern pD3DCompile D3DCompilePROC;
namespace hecl { namespace hecl {
logvisor::Module Log("hecl::Compilers"); logvisor::Module Log("hecl::Compilers");
namespace PlatformType {
const char* OpenGL::Name = "OpenGL";
const char* Vulkan::Name = "Vulkan";
const char* D3D11::Name = "D3D11";
const char* Metal::Name = "Metal";
const char* NX::Name = "NX";
} // namespace PlatformType
namespace PipelineStage {
const char* Null::Name = "Null";
const char* Vertex::Name = "Vertex";
const char* Fragment::Name = "Fragment";
const char* Geometry::Name = "Geometry";
const char* Control::Name = "Control";
const char* Evaluation::Name = "Evaluation";
} // namespace PipelineStage
template <typename P> template <typename P>
struct ShaderCompiler {}; struct ShaderCompiler {};