yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
6104a5554
master
1// slang-glslang.h 2#ifndef SLANG_GLSLANG_H_INCLUDED 3#define SLANG_GLSLANG_H_INCLUDED 4 5#include <cstdint> 6#include <cstring> 7#include <memory> 8#include <stddef.h> 9 10typedef void (* glslang_OutputFunc )(void const * data ,size_t size ,void * userData ); 11 12enum 13{ 14GLSLANG_ACTION_COMPILE_GLSL_TO_SPIRV , 15GLSLANG_ACTION_DISSASSEMBLE_SPIRV , 16GLSLANG_ACTION_OPTIMIZE_SPIRV , 17}; 18 19struct glsl_SPIRVVersion 20{ 21int major ,minor ,patch ; 22}; 23 24// clang-format off 25 26#define SLANG_GLSLANG_COMPILE_REQUEST_1_0 (x ) \ 27 x(sourcePath) \ 28 x(inputBegin) \ 29 x(inputEnd) \ 30 x(diagnosticFunc) \ 31 x(diagnosticUserData) \ 32 x(outputFunc) \ 33 x(outputUserData) \ 34 x(slangStage) \ 35 x(action) \ 36 x(optimizationLevel) \ 37 x(debugInfoType) 38 39#define SLANG_GLSLANG_FIELD_COPY (name ) name = in.name; 40 41// clang-format on 42 43// Pre-declare 44struct glslang_CompileRequest_1_1 ; 45 46// 1.0 version 47struct glslang_CompileRequest_1_0 48{ 49void set (const glslang_CompileRequest_1_1 & in ); 50 51char const * sourcePath ; 52 53void const * inputBegin ; 54void const * inputEnd ; 55 56glslang_OutputFunc diagnosticFunc ; 57void * diagnosticUserData ; 58 59glslang_OutputFunc outputFunc ; 60void * outputUserData ; 61 62int slangStage ; 63 64unsigned action ; 65 66unsigned optimizationLevel ; 67unsigned debugInfoType ; 68}; 69 70// 1.1 version 71struct glslang_CompileRequest_1_1 72{ 73/// Set from 1.0 74void set (const glslang_CompileRequest_1_0 & in ); 75 76size_t sizeInBytes ;///< Size in bytes of this structure 77 78// START! Embed the glslang_CompileRequest_1_0 fields 79char const * sourcePath ; 80 81void const * inputBegin ; 82void const * inputEnd ; 83 84glslang_OutputFunc diagnosticFunc ; 85void * diagnosticUserData ; 86 87glslang_OutputFunc outputFunc ; 88void * outputUserData ; 89 90int slangStage ; 91 92unsigned action ; 93 94unsigned optimizationLevel ; 95unsigned debugInfoType ; 96// END! Embed the glslang_CompileRequest_1_0 fields 97 98const char * spirvTargetName ;/// A valid TargetName. If null will use universal based on the 99/// spirVersion. 100glsl_SPIRVVersion spirvVersion ;///< The SPIR-V version. If all are 0 will use the default which 101///< is 1.2 currently 102}; 103 104// 1.2 version 105struct glslang_CompileRequest_1_2 106{ 107/// Set from 1.1 108void set (const glslang_CompileRequest_1_1 & in ); 109 110size_t sizeInBytes ;///< Size in bytes of this structure 111 112// START! Embed the glslang_CompileRequest_1_0 fields 113char const * sourcePath ; 114 115void const * inputBegin ; 116void const * inputEnd ; 117 118glslang_OutputFunc diagnosticFunc ; 119void * diagnosticUserData ; 120 121glslang_OutputFunc outputFunc ; 122void * outputUserData ; 123 124int slangStage ; 125 126unsigned action ; 127 128unsigned optimizationLevel ; 129unsigned debugInfoType ; 130// END! Embed the glslang_CompileRequest_1_0 fields 131 132const char * spirvTargetName ;/// A valid TargetName. If null will use universal based on the 133/// spirVersion. 134glsl_SPIRVVersion spirvVersion ;///< The SPIR-V version. If all are 0 will use the default which 135///< is 1.2 currently 136 137// glslang_CompileRequest_1_2 fields 138const char * entryPointName ;// The name of the entrypoint that will appear in output spirv. 139}; 140 141inline void glslang_CompileRequest_1_0 ::set (const glslang_CompileRequest_1_1 & in ) 142{ 143SLANG_GLSLANG_COMPILE_REQUEST_1_0 (SLANG_GLSLANG_FIELD_COPY ) 144} 145 146inline void glslang_CompileRequest_1_1 ::set (const glslang_CompileRequest_1_0 & in ) 147{ 148SLANG_GLSLANG_COMPILE_REQUEST_1_0 (SLANG_GLSLANG_FIELD_COPY ) 149} 150 151inline void glslang_CompileRequest_1_2 ::set (const glslang_CompileRequest_1_1 & in ) 152{ 153memcpy (this ,& in ,sizeof (in )); 154} 155 156typedef struct glslang_LinkRequest_t 157{ 158const uint32_t ** modules ;// Input: array of pointers to SPIR-V modules 159const uint32_t * moduleSizes ;// Input: array of sizes of SPIR-V modules in 32-bit words 160int moduleCount ;// Input: number of modules in the array 161const uint32_t * linkResult ;// Output: pointer to linked SPIR-V module 162size_t linkResultSize ;// Output: size of the linked SPIR-V module in 32-bit words 163}glslang_LinkRequest ; 164 165typedef int (* glslang_CompileFunc_1_0 )(glslang_CompileRequest_1_0 * request ); 166typedef int (* glslang_CompileFunc_1_1 )(glslang_CompileRequest_1_1 * request ); 167typedef int (* glslang_CompileFunc_1_2 )(glslang_CompileRequest_1_2 * request ); 168typedef bool (* glslang_ValidateSPIRVFunc )(const uint32_t * contents ,int contentsSize ); 169typedef bool (* glslang_DisassembleSPIRVFunc )(const uint32_t * contents ,int contentsSize ); 170typedef bool (* glslang_DisassembleSPIRVWithResultFunc )( 171const uint32_t * contents , 172int contentsSize , 173char ** outString ); 174typedef bool (* glslang_LinkSPIRVFunc )(glslang_LinkRequest * request ); 175#endif