ShaderLang.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. //
  2. // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
  3. // Use of this source code is governed by a BSD-style license that can be
  4. // found in the LICENSE file.
  5. //
  6. #ifndef GLSLANG_SHADERLANG_H_
  7. #define GLSLANG_SHADERLANG_H_
  8. #if defined(COMPONENT_BUILD) && !defined(ANGLE_TRANSLATOR_STATIC)
  9. #if defined(_WIN32) || defined(_WIN64)
  10. #if defined(ANGLE_TRANSLATOR_IMPLEMENTATION)
  11. #define COMPILER_EXPORT __declspec(dllexport)
  12. #else
  13. #define COMPILER_EXPORT __declspec(dllimport)
  14. #endif // defined(ANGLE_TRANSLATOR_IMPLEMENTATION)
  15. #else // defined(_WIN32) || defined(_WIN64)
  16. #define COMPILER_EXPORT __attribute__((visibility("default")))
  17. #endif
  18. #else // defined(COMPONENT_BUILD) && !defined(ANGLE_TRANSLATOR_STATIC)
  19. #define COMPILER_EXPORT
  20. #endif
  21. #include <stddef.h>
  22. #include "KHR/khrplatform.h"
  23. #include <array>
  24. #include <map>
  25. #include <string>
  26. #include <vector>
  27. //
  28. // This is the platform independent interface between an OGL driver
  29. // and the shading language compiler.
  30. //
  31. namespace sh
  32. {
  33. // GLenum alias
  34. typedef unsigned int GLenum;
  35. }
  36. // Must be included after GLenum proxy typedef
  37. // Note: make sure to increment ANGLE_SH_VERSION when changing ShaderVars.h
  38. #include "ShaderVars.h"
  39. // Version number for shader translation API.
  40. // It is incremented every time the API changes.
  41. #define ANGLE_SH_VERSION 155
  42. typedef enum {
  43. SH_GLES2_SPEC,
  44. SH_WEBGL_SPEC,
  45. SH_GLES3_SPEC,
  46. SH_WEBGL2_SPEC,
  47. SH_GLES3_1_SPEC,
  48. SH_WEBGL3_SPEC,
  49. // The CSS Shaders spec is a subset of the WebGL spec.
  50. //
  51. // In both CSS vertex and fragment shaders, ANGLE:
  52. // (1) Reserves the "css_" prefix.
  53. // (2) Renames the main function to css_main.
  54. // (3) Disables the gl_MaxDrawBuffers built-in.
  55. //
  56. // In CSS fragment shaders, ANGLE:
  57. // (1) Disables the gl_FragColor built-in.
  58. // (2) Disables the gl_FragData built-in.
  59. // (3) Enables the css_MixColor built-in.
  60. // (4) Enables the css_ColorMatrix built-in.
  61. //
  62. // After passing a CSS shader through ANGLE, the browser is expected to append
  63. // a new main function to it.
  64. // This new main function will call the css_main function.
  65. // It may also perform additional operations like varying assignment, texture
  66. // access, and gl_FragColor assignment in order to implement the CSS Shaders
  67. // blend modes.
  68. //
  69. SH_CSS_SHADERS_SPEC
  70. } ShShaderSpec;
  71. typedef enum
  72. {
  73. // ESSL output only supported in some configurations.
  74. SH_ESSL_OUTPUT = 0x8B45,
  75. // GLSL output only supported in some configurations.
  76. SH_GLSL_COMPATIBILITY_OUTPUT = 0x8B46,
  77. // Note: GL introduced core profiles in 1.5.
  78. SH_GLSL_130_OUTPUT = 0x8B47,
  79. SH_GLSL_140_OUTPUT = 0x8B80,
  80. SH_GLSL_150_CORE_OUTPUT = 0x8B81,
  81. SH_GLSL_330_CORE_OUTPUT = 0x8B82,
  82. SH_GLSL_400_CORE_OUTPUT = 0x8B83,
  83. SH_GLSL_410_CORE_OUTPUT = 0x8B84,
  84. SH_GLSL_420_CORE_OUTPUT = 0x8B85,
  85. SH_GLSL_430_CORE_OUTPUT = 0x8B86,
  86. SH_GLSL_440_CORE_OUTPUT = 0x8B87,
  87. SH_GLSL_450_CORE_OUTPUT = 0x8B88,
  88. // HLSL output only supported in some configurations.
  89. // Deprecated:
  90. SH_HLSL_OUTPUT = 0x8B48,
  91. SH_HLSL9_OUTPUT = 0x8B48,
  92. SH_HLSL11_OUTPUT = 0x8B49,
  93. // Prefer using these to specify HLSL output type:
  94. SH_HLSL_3_0_OUTPUT = 0x8B48, // D3D 9
  95. SH_HLSL_4_1_OUTPUT = 0x8B49, // D3D 11
  96. SH_HLSL_4_0_FL9_3_OUTPUT = 0x8B4A // D3D 11 feature level 9_3
  97. } ShShaderOutput;
  98. // Compile options.
  99. typedef enum {
  100. SH_VALIDATE = 0,
  101. SH_VALIDATE_LOOP_INDEXING = 0x0001,
  102. SH_INTERMEDIATE_TREE = 0x0002,
  103. SH_OBJECT_CODE = 0x0004,
  104. SH_VARIABLES = 0x0008,
  105. SH_LINE_DIRECTIVES = 0x0010,
  106. SH_SOURCE_PATH = 0x0020,
  107. SH_UNROLL_FOR_LOOP_WITH_INTEGER_INDEX = 0x0040,
  108. // If a sampler array index happens to be a loop index,
  109. // 1) if its type is integer, unroll the loop.
  110. // 2) if its type is float, fail the shader compile.
  111. // This is to work around a mac driver bug.
  112. SH_UNROLL_FOR_LOOP_WITH_SAMPLER_ARRAY_INDEX = 0x0080,
  113. // This is needed only as a workaround for certain OpenGL driver bugs.
  114. SH_EMULATE_BUILT_IN_FUNCTIONS = 0x0100,
  115. // This is an experimental flag to enforce restrictions that aim to prevent
  116. // timing attacks.
  117. // It generates compilation errors for shaders that could expose sensitive
  118. // texture information via the timing channel.
  119. // To use this flag, you must compile the shader under the WebGL spec
  120. // (using the SH_WEBGL_SPEC flag).
  121. SH_TIMING_RESTRICTIONS = 0x0200,
  122. // This flag prints the dependency graph that is used to enforce timing
  123. // restrictions on fragment shaders.
  124. // This flag only has an effect if all of the following are true:
  125. // - The shader spec is SH_WEBGL_SPEC.
  126. // - The compile options contain the SH_TIMING_RESTRICTIONS flag.
  127. // - The shader type is GL_FRAGMENT_SHADER.
  128. SH_DEPENDENCY_GRAPH = 0x0400,
  129. // Enforce the GLSL 1.017 Appendix A section 7 packing restrictions.
  130. // This flag only enforces (and can only enforce) the packing
  131. // restrictions for uniform variables in both vertex and fragment
  132. // shaders. ShCheckVariablesWithinPackingLimits() lets embedders
  133. // enforce the packing restrictions for varying variables during
  134. // program link time.
  135. SH_ENFORCE_PACKING_RESTRICTIONS = 0x0800,
  136. // This flag ensures all indirect (expression-based) array indexing
  137. // is clamped to the bounds of the array. This ensures, for example,
  138. // that you cannot read off the end of a uniform, whether an array
  139. // vec234, or mat234 type. The ShArrayIndexClampingStrategy enum,
  140. // specified in the ShBuiltInResources when constructing the
  141. // compiler, selects the strategy for the clamping implementation.
  142. SH_CLAMP_INDIRECT_ARRAY_BOUNDS = 0x1000,
  143. // This flag limits the complexity of an expression.
  144. SH_LIMIT_EXPRESSION_COMPLEXITY = 0x2000,
  145. // This flag limits the depth of the call stack.
  146. SH_LIMIT_CALL_STACK_DEPTH = 0x4000,
  147. // This flag initializes gl_Position to vec4(0,0,0,0) at the
  148. // beginning of the vertex shader's main(), and has no effect in the
  149. // fragment shader. It is intended as a workaround for drivers which
  150. // incorrectly fail to link programs if gl_Position is not written.
  151. SH_INIT_GL_POSITION = 0x8000,
  152. // This flag replaces
  153. // "a && b" with "a ? b : false",
  154. // "a || b" with "a ? true : b".
  155. // This is to work around a MacOSX driver bug that |b| is executed
  156. // independent of |a|'s value.
  157. SH_UNFOLD_SHORT_CIRCUIT = 0x10000,
  158. // This flag initializes output variables to 0 at the beginning of main().
  159. // It is to avoid undefined behaviors.
  160. SH_INIT_OUTPUT_VARIABLES = 0x20000,
  161. // TODO(zmo): obsolete, remove after ANGLE roll into Chromium.
  162. SH_INIT_VARYINGS_WITHOUT_STATIC_USE = 0x20000,
  163. // This flag scalarizes vec/ivec/bvec/mat constructor args.
  164. // It is intended as a workaround for Linux/Mac driver bugs.
  165. SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS = 0x40000,
  166. // This flag overwrites a struct name with a unique prefix.
  167. // It is intended as a workaround for drivers that do not handle
  168. // struct scopes correctly, including all Mac drivers and Linux AMD.
  169. SH_REGENERATE_STRUCT_NAMES = 0x80000,
  170. // This flag makes the compiler not prune unused function early in the
  171. // compilation process. Pruning coupled with SH_LIMIT_CALL_STACK_DEPTH
  172. // helps avoid bad shaders causing stack overflows.
  173. SH_DONT_PRUNE_UNUSED_FUNCTIONS = 0x100000,
  174. // This flag works around a bug in NVIDIA 331 series drivers related
  175. // to pow(x, y) where y is a constant vector.
  176. SH_REMOVE_POW_WITH_CONSTANT_EXPONENT = 0x200000,
  177. // This flag works around bugs in Mac drivers related to do-while by
  178. // transforming them into an other construct.
  179. SH_REWRITE_DO_WHILE_LOOPS = 0x400000,
  180. // This flag works around a bug in the HLSL compiler optimizer that folds certain
  181. // constant pow expressions incorrectly. Only applies to the HLSL back-end. It works
  182. // by expanding the integer pow expressions into a series of multiplies.
  183. SH_EXPAND_SELECT_HLSL_INTEGER_POW_EXPRESSIONS = 0x800000,
  184. // Flatten "#pragma STDGL invariant(all)" into the declarations of
  185. // varying variables and built-in GLSL variables. This compiler
  186. // option is enabled automatically when needed.
  187. SH_FLATTEN_PRAGMA_STDGL_INVARIANT_ALL = 0x1000000,
  188. // Some drivers do not take into account the base level of the texture in the results of the
  189. // HLSL GetDimensions builtin. This flag instructs the compiler to manually add the base level
  190. // offsetting.
  191. SH_HLSL_GET_DIMENSIONS_IGNORES_BASE_LEVEL = 0x2000000,
  192. // This flag works around an issue in translating GLSL function texelFetchOffset on
  193. // INTEL drivers. It works by translating texelFetchOffset into texelFetch.
  194. SH_REWRITE_TEXELFETCHOFFSET_TO_TEXELFETCH = 0x4000000,
  195. } ShCompileOptions;
  196. // Defines alternate strategies for implementing array index clamping.
  197. typedef enum {
  198. // Use the clamp intrinsic for array index clamping.
  199. SH_CLAMP_WITH_CLAMP_INTRINSIC = 1,
  200. // Use a user-defined function for array index clamping.
  201. SH_CLAMP_WITH_USER_DEFINED_INT_CLAMP_FUNCTION
  202. } ShArrayIndexClampingStrategy;
  203. //
  204. // Driver must call this first, once, before doing any other
  205. // compiler operations.
  206. // If the function succeeds, the return value is true, else false.
  207. //
  208. COMPILER_EXPORT bool ShInitialize();
  209. //
  210. // Driver should call this at shutdown.
  211. // If the function succeeds, the return value is true, else false.
  212. //
  213. COMPILER_EXPORT bool ShFinalize();
  214. // The 64 bits hash function. The first parameter is the input string; the
  215. // second parameter is the string length.
  216. typedef khronos_uint64_t (*ShHashFunction64)(const char*, size_t);
  217. //
  218. // Implementation dependent built-in resources (constants and extensions).
  219. // The names for these resources has been obtained by stripping gl_/GL_.
  220. //
  221. typedef struct
  222. {
  223. // Constants.
  224. int MaxVertexAttribs;
  225. int MaxVertexUniformVectors;
  226. int MaxVaryingVectors;
  227. int MaxVertexTextureImageUnits;
  228. int MaxCombinedTextureImageUnits;
  229. int MaxTextureImageUnits;
  230. int MaxFragmentUniformVectors;
  231. int MaxDrawBuffers;
  232. // Extensions.
  233. // Set to 1 to enable the extension, else 0.
  234. int OES_standard_derivatives;
  235. int OES_EGL_image_external;
  236. int OES_EGL_image_external_essl3;
  237. int NV_EGL_stream_consumer_external;
  238. int ARB_texture_rectangle;
  239. int EXT_blend_func_extended;
  240. int EXT_draw_buffers;
  241. int EXT_frag_depth;
  242. int EXT_shader_texture_lod;
  243. int WEBGL_debug_shader_precision;
  244. int EXT_shader_framebuffer_fetch;
  245. int NV_shader_framebuffer_fetch;
  246. int ARM_shader_framebuffer_fetch;
  247. // Set to 1 to enable replacing GL_EXT_draw_buffers #extension directives
  248. // with GL_NV_draw_buffers in ESSL output. This flag can be used to emulate
  249. // EXT_draw_buffers by using it in combination with GLES3.0 glDrawBuffers
  250. // function. This applies to Tegra K1 devices.
  251. int NV_draw_buffers;
  252. // Set to 1 if highp precision is supported in the ESSL 1.00 version of the
  253. // fragment language. Does not affect versions of the language where highp
  254. // support is mandatory.
  255. // Default is 0.
  256. int FragmentPrecisionHigh;
  257. // GLSL ES 3.0 constants.
  258. int MaxVertexOutputVectors;
  259. int MaxFragmentInputVectors;
  260. int MinProgramTexelOffset;
  261. int MaxProgramTexelOffset;
  262. // Extension constants.
  263. // Value of GL_MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT for OpenGL ES output context.
  264. // Value of GL_MAX_DUAL_SOURCE_DRAW_BUFFERS for OpenGL output context.
  265. // GLES SL version 100 gl_MaxDualSourceDrawBuffersEXT value for EXT_blend_func_extended.
  266. int MaxDualSourceDrawBuffers;
  267. // Name Hashing.
  268. // Set a 64 bit hash function to enable user-defined name hashing.
  269. // Default is NULL.
  270. ShHashFunction64 HashFunction;
  271. // Selects a strategy to use when implementing array index clamping.
  272. // Default is SH_CLAMP_WITH_CLAMP_INTRINSIC.
  273. ShArrayIndexClampingStrategy ArrayIndexClampingStrategy;
  274. // The maximum complexity an expression can be when SH_LIMIT_EXPRESSION_COMPLEXITY is turned on.
  275. int MaxExpressionComplexity;
  276. // The maximum depth a call stack can be.
  277. int MaxCallStackDepth;
  278. // The maximum number of parameters a function can have when SH_LIMIT_EXPRESSION_COMPLEXITY is
  279. // turned on.
  280. int MaxFunctionParameters;
  281. // GLES 3.1 constants
  282. // maximum number of available image units
  283. int MaxImageUnits;
  284. // maximum number of image uniforms in a vertex shader
  285. int MaxVertexImageUniforms;
  286. // maximum number of image uniforms in a fragment shader
  287. int MaxFragmentImageUniforms;
  288. // maximum number of image uniforms in a compute shader
  289. int MaxComputeImageUniforms;
  290. // maximum total number of image uniforms in a program
  291. int MaxCombinedImageUniforms;
  292. // maximum number of ssbos and images in a shader
  293. int MaxCombinedShaderOutputResources;
  294. // maximum number of groups in each dimension
  295. std::array<int, 3> MaxComputeWorkGroupCount;
  296. // maximum number of threads per work group in each dimension
  297. std::array<int, 3> MaxComputeWorkGroupSize;
  298. // maximum number of total uniform components
  299. int MaxComputeUniformComponents;
  300. // maximum number of texture image units in a compute shader
  301. int MaxComputeTextureImageUnits;
  302. // maximum number of atomic counters in a compute shader
  303. int MaxComputeAtomicCounters;
  304. // maximum number of atomic counter buffers in a compute shader
  305. int MaxComputeAtomicCounterBuffers;
  306. // maximum number of atomic counters in a vertex shader
  307. int MaxVertexAtomicCounters;
  308. // maximum number of atomic counters in a fragment shader
  309. int MaxFragmentAtomicCounters;
  310. // maximum number of atomic counters in a program
  311. int MaxCombinedAtomicCounters;
  312. // maximum binding for an atomic counter
  313. int MaxAtomicCounterBindings;
  314. // maximum number of atomic counter buffers in a vertex shader
  315. int MaxVertexAtomicCounterBuffers;
  316. // maximum number of atomic counter buffers in a fragment shader
  317. int MaxFragmentAtomicCounterBuffers;
  318. // maximum number of atomic counter buffers in a program
  319. int MaxCombinedAtomicCounterBuffers;
  320. // maximum number of buffer object storage in machine units
  321. int MaxAtomicCounterBufferSize;
  322. } ShBuiltInResources;
  323. //
  324. // Initialize built-in resources with minimum expected values.
  325. // Parameters:
  326. // resources: The object to initialize. Will be comparable with memcmp.
  327. //
  328. COMPILER_EXPORT void ShInitBuiltInResources(ShBuiltInResources *resources);
  329. //
  330. // ShHandle held by but opaque to the driver. It is allocated,
  331. // managed, and de-allocated by the compiler. Its contents
  332. // are defined by and used by the compiler.
  333. //
  334. // If handle creation fails, 0 will be returned.
  335. //
  336. typedef void *ShHandle;
  337. //
  338. // Returns the a concatenated list of the items in ShBuiltInResources as a
  339. // null-terminated string.
  340. // This function must be updated whenever ShBuiltInResources is changed.
  341. // Parameters:
  342. // handle: Specifies the handle of the compiler to be used.
  343. COMPILER_EXPORT const std::string &ShGetBuiltInResourcesString(const ShHandle handle);
  344. //
  345. // Driver calls these to create and destroy compiler objects.
  346. //
  347. // Returns the handle of constructed compiler, null if the requested compiler is
  348. // not supported.
  349. // Parameters:
  350. // type: Specifies the type of shader - GL_FRAGMENT_SHADER or GL_VERTEX_SHADER.
  351. // spec: Specifies the language spec the compiler must conform to -
  352. // SH_GLES2_SPEC or SH_WEBGL_SPEC.
  353. // output: Specifies the output code type - for example SH_ESSL_OUTPUT, SH_GLSL_OUTPUT,
  354. // SH_HLSL_3_0_OUTPUT or SH_HLSL_4_1_OUTPUT. Note: Each output type may only
  355. // be supported in some configurations.
  356. // resources: Specifies the built-in resources.
  357. COMPILER_EXPORT ShHandle ShConstructCompiler(
  358. sh::GLenum type,
  359. ShShaderSpec spec,
  360. ShShaderOutput output,
  361. const ShBuiltInResources *resources);
  362. COMPILER_EXPORT void ShDestruct(ShHandle handle);
  363. //
  364. // Compiles the given shader source.
  365. // If the function succeeds, the return value is true, else false.
  366. // Parameters:
  367. // handle: Specifies the handle of compiler to be used.
  368. // shaderStrings: Specifies an array of pointers to null-terminated strings
  369. // containing the shader source code.
  370. // numStrings: Specifies the number of elements in shaderStrings array.
  371. // compileOptions: A mask containing the following parameters:
  372. // SH_VALIDATE: Validates shader to ensure that it conforms to the spec
  373. // specified during compiler construction.
  374. // SH_VALIDATE_LOOP_INDEXING: Validates loop and indexing in the shader to
  375. // ensure that they do not exceed the minimum
  376. // functionality mandated in GLSL 1.0 spec,
  377. // Appendix A, Section 4 and 5.
  378. // There is no need to specify this parameter when
  379. // compiling for WebGL - it is implied.
  380. // SH_INTERMEDIATE_TREE: Writes intermediate tree to info log.
  381. // Can be queried by calling ShGetInfoLog().
  382. // SH_OBJECT_CODE: Translates intermediate tree to glsl or hlsl shader.
  383. // Can be queried by calling ShGetObjectCode().
  384. // SH_VARIABLES: Extracts attributes, uniforms, and varyings.
  385. // Can be queried by calling ShGetVariableInfo().
  386. //
  387. COMPILER_EXPORT bool ShCompile(
  388. const ShHandle handle,
  389. const char * const shaderStrings[],
  390. size_t numStrings,
  391. int compileOptions);
  392. // Clears the results from the previous compilation.
  393. COMPILER_EXPORT void ShClearResults(const ShHandle handle);
  394. // Return the version of the shader language.
  395. COMPILER_EXPORT int ShGetShaderVersion(const ShHandle handle);
  396. // Return the currently set language output type.
  397. COMPILER_EXPORT ShShaderOutput ShGetShaderOutputType(
  398. const ShHandle handle);
  399. // Returns null-terminated information log for a compiled shader.
  400. // Parameters:
  401. // handle: Specifies the compiler
  402. COMPILER_EXPORT const std::string &ShGetInfoLog(const ShHandle handle);
  403. // Returns null-terminated object code for a compiled shader.
  404. // Parameters:
  405. // handle: Specifies the compiler
  406. COMPILER_EXPORT const std::string &ShGetObjectCode(const ShHandle handle);
  407. // Returns a (original_name, hash) map containing all the user defined
  408. // names in the shader, including variable names, function names, struct
  409. // names, and struct field names.
  410. // Parameters:
  411. // handle: Specifies the compiler
  412. COMPILER_EXPORT const std::map<std::string, std::string> *ShGetNameHashingMap(
  413. const ShHandle handle);
  414. // Shader variable inspection.
  415. // Returns a pointer to a list of variables of the designated type.
  416. // (See ShaderVars.h for type definitions, included above)
  417. // Returns NULL on failure.
  418. // Parameters:
  419. // handle: Specifies the compiler
  420. COMPILER_EXPORT const std::vector<sh::Uniform> *ShGetUniforms(const ShHandle handle);
  421. COMPILER_EXPORT const std::vector<sh::Varying> *ShGetVaryings(const ShHandle handle);
  422. COMPILER_EXPORT const std::vector<sh::Attribute> *ShGetAttributes(const ShHandle handle);
  423. COMPILER_EXPORT const std::vector<sh::OutputVariable> *ShGetOutputVariables(const ShHandle handle);
  424. COMPILER_EXPORT const std::vector<sh::InterfaceBlock> *ShGetInterfaceBlocks(const ShHandle handle);
  425. COMPILER_EXPORT sh::WorkGroupSize ShGetComputeShaderLocalGroupSize(const ShHandle handle);
  426. typedef struct
  427. {
  428. sh::GLenum type;
  429. int size;
  430. } ShVariableInfo;
  431. // Returns true if the passed in variables pack in maxVectors following
  432. // the packing rules from the GLSL 1.017 spec, Appendix A, section 7.
  433. // Returns false otherwise. Also look at the SH_ENFORCE_PACKING_RESTRICTIONS
  434. // flag above.
  435. // Parameters:
  436. // maxVectors: the available rows of registers.
  437. // variables: an array of variables.
  438. COMPILER_EXPORT bool ShCheckVariablesWithinPackingLimits(
  439. int maxVectors,
  440. const std::vector<sh::ShaderVariable> &variables);
  441. // Gives the compiler-assigned register for an interface block.
  442. // The method writes the value to the output variable "indexOut".
  443. // Returns true if it found a valid interface block, false otherwise.
  444. // Parameters:
  445. // handle: Specifies the compiler
  446. // interfaceBlockName: Specifies the interface block
  447. // indexOut: output variable that stores the assigned register
  448. COMPILER_EXPORT bool ShGetInterfaceBlockRegister(const ShHandle handle,
  449. const std::string &interfaceBlockName,
  450. unsigned int *indexOut);
  451. // Gives a map from uniform names to compiler-assigned registers in the default
  452. // interface block. Note that the map contains also registers of samplers that
  453. // have been extracted from structs.
  454. COMPILER_EXPORT const std::map<std::string, unsigned int> *ShGetUniformRegisterMap(
  455. const ShHandle handle);
  456. #endif // GLSLANG_SHADERLANG_H_