| 1 | /*
|
| 2 | * Targets.h
|
| 3 | *
|
| 4 | * This file is part of the XShaderCompiler project (Copyright (c) 2014-2017 by Lukas Hermanns)
|
| 5 | * See "LICENSE.txt" for license information.
|
| 6 | */
|
| 7 |
|
| 8 | #ifndef XSC_TARGETS_H
|
| 9 | #define XSC_TARGETS_H
|
| 10 |
|
| 11 |
|
| 12 | #include "Export.h"
|
| 13 | #include <string>
|
| 14 | #include <map>
|
| 15 |
|
| 16 |
|
| 17 | namespace Xsc
|
| 18 | {
|
| 19 |
|
| 20 |
|
| 21 | /* ===== Public enumerations ===== */
|
| 22 |
|
| 23 | //! Shader target enumeration.
|
| 24 | enum class ShaderTarget
|
| 25 | {
|
| 26 | Undefined, //!< Undefined shader target.
|
| 27 |
|
| 28 | VertexShader, //!< Vertex shader.
|
| 29 | TessellationControlShader, //!< Tessellation-control (also Hull-) shader.
|
| 30 | TessellationEvaluationShader, //!< Tessellation-evaluation (also Domain-) shader.
|
| 31 | GeometryShader, //!< Geometry shader.
|
| 32 | FragmentShader, //!< Fragment (also Pixel-) shader.
|
| 33 | ComputeShader, //!< Compute shader.
|
| 34 | };
|
| 35 |
|
| 36 | //! Input shader version enumeration.
|
| 37 | enum class InputShaderVersion
|
| 38 | {
|
| 39 | Cg = 2, //!< Cg (C for graphics) is a slightly extended HLSL3.
|
| 40 |
|
| 41 | HLSL3 = 3, //!< HLSL Shader Model 3.0 (DirectX 9).
|
| 42 | HLSL4 = 4, //!< HLSL Shader Model 4.0 (DirectX 10).
|
| 43 | HLSL5 = 5, //!< HLSL Shader Model 5.0 (DirectX 11).
|
| 44 | HLSL6 = 6, //!< HLSL Shader Model 6.0 (DirectX 12).
|
| 45 |
|
| 46 | GLSL = 0x0000ffff, //!< GLSL (OpenGL).
|
| 47 | ESSL = 0x0001ffff, //!< GLSL (OpenGL ES).
|
| 48 | VKSL = 0x0002ffff, //!< GLSL (Vulkan).
|
| 49 | };
|
| 50 |
|
| 51 | //! Output shader version enumeration.
|
| 52 | enum class OutputShaderVersion
|
| 53 | {
|
| 54 | GLSL110 = 110, //!< GLSL 1.10 (OpenGL 2.0).
|
| 55 | GLSL120 = 120, //!< GLSL 1.20 (OpenGL 2.1).
|
| 56 | GLSL130 = 130, //!< GLSL 1.30 (OpenGL 3.0).
|
| 57 | GLSL140 = 140, //!< GLSL 1.40 (OpenGL 3.1).
|
| 58 | GLSL150 = 150, //!< GLSL 1.50 (OpenGL 3.2).
|
| 59 | GLSL330 = 330, //!< GLSL 3.30 (OpenGL 3.3).
|
| 60 | GLSL400 = 400, //!< GLSL 4.00 (OpenGL 4.0).
|
| 61 | GLSL410 = 410, //!< GLSL 4.10 (OpenGL 4.1).
|
| 62 | GLSL420 = 420, //!< GLSL 4.20 (OpenGL 4.2).
|
| 63 | GLSL430 = 430, //!< GLSL 4.30 (OpenGL 4.3).
|
| 64 | GLSL440 = 440, //!< GLSL 4.40 (OpenGL 4.4).
|
| 65 | GLSL450 = 450, //!< GLSL 4.50 (OpenGL 4.5).
|
| 66 | GLSL = 0x0000ffff, //!< Auto-detect minimal required GLSL version (for OpenGL 2+).
|
| 67 |
|
| 68 | ESSL100 = (0x00010000 + 100), //!< ESSL 1.00 (OpenGL ES 2.0). \note Currently not supported!
|
| 69 | ESSL300 = (0x00010000 + 300), //!< ESSL 3.00 (OpenGL ES 3.0). \note Currently not supported!
|
| 70 | ESSL310 = (0x00010000 + 310), //!< ESSL 3.10 (OpenGL ES 3.1). \note Currently not supported!
|
| 71 | ESSL320 = (0x00010000 + 320), //!< ESSL 3.20 (OpenGL ES 3.2). \note Currently not supported!
|
| 72 | ESSL = 0x0001ffff, //!< Auto-detect minimum required ESSL version (for OpenGL ES 2+). \note Currently not supported!
|
| 73 |
|
| 74 | VKSL450 = (0x00020000 + 450), //!< VKSL 4.50 (Vulkan 1.0).
|
| 75 | VKSL = 0x0002ffff, //!< Auto-detect minimum required VKSL version (for Vulkan/SPIR-V).
|
| 76 | };
|
| 77 |
|
| 78 | //! Intermediate language enumeration.
|
| 79 | enum class IntermediateLanguage
|
| 80 | {
|
| 81 | SPIRV, //!< SPIR-V.
|
| 82 | };
|
| 83 |
|
| 84 |
|
| 85 | /* ===== Public functions ===== */
|
| 86 |
|
| 87 | //! Returns the specified shader target as string.
|
| 88 | XSC_EXPORT std::string ToString(const ShaderTarget target);
|
| 89 |
|
| 90 | //! Returns the specified shader input version as string.
|
| 91 | XSC_EXPORT std::string ToString(const InputShaderVersion shaderVersion);
|
| 92 |
|
| 93 | //! Returns the specified shader output version as string.
|
| 94 | XSC_EXPORT std::string ToString(const OutputShaderVersion shaderVersion);
|
| 95 |
|
| 96 | //! Returns the specified intermediate language as string.
|
| 97 | XSC_EXPORT std::string ToString(const IntermediateLanguage language);
|
| 98 |
|
| 99 | //! Returns true if the shader input version specifies HLSL (for DirectX) or Cg (handled as dialect or HLSL).
|
| 100 | XSC_EXPORT bool IsLanguageHLSL(const InputShaderVersion shaderVersion);
|
| 101 |
|
| 102 | //! Returns true if the shader input version specifies GLSL (for OpenGL, OpenGL ES, and Vulkan).
|
| 103 | XSC_EXPORT bool IsLanguageGLSL(const InputShaderVersion shaderVersion);
|
| 104 |
|
| 105 | //! Returns true if the shader output version specifies GLSL (for OpenGL 2+).
|
| 106 | XSC_EXPORT bool IsLanguageGLSL(const OutputShaderVersion shaderVersion);
|
| 107 |
|
| 108 | //! Returns true if the shader output version specifies ESSL (for OpenGL ES 2+).
|
| 109 | XSC_EXPORT bool IsLanguageESSL(const OutputShaderVersion shaderVersion);
|
| 110 |
|
| 111 | //! Returns true if the shader output version specifies VKSL (for Vulkan).
|
| 112 | XSC_EXPORT bool IsLanguageVKSL(const OutputShaderVersion shaderVersion);
|
| 113 |
|
| 114 | //! Returns the enumeration of all supported GLSL extensions as a map of extension name and version number.
|
| 115 | XSC_EXPORT const std::map<std::string, int>& GetGLSLExtensionEnumeration();
|
| 116 |
|
| 117 |
|
| 118 | } // /namespace Xsc
|
| 119 |
|
| 120 |
|
| 121 | #endif
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 | // ================================================================================ |