14f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.com// 2b73964e328243021db10ecd98e3e124e82522c43shannon.woods@transgaming.com// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. 34f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.com// Use of this source code is governed by a BSD-style license that can be 44f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.com// found in the LICENSE file. 54f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.com// 64f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.com#ifndef _COMPILER_INTERFACE_INCLUDED_ 74f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.com#define _COMPILER_INTERFACE_INCLUDED_ 84f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.com 931f0dc0a09b1ea6ff03d235080d561840de8eb66Geoff Lang#if defined(COMPONENT_BUILD) && !defined(ANGLE_TRANSLATOR_STATIC) 1022eab922e7cf9d47f1aa69ebd8cc17306656f9c7apatrick@chromium.org#if defined(_WIN32) || defined(_WIN64) 1122eab922e7cf9d47f1aa69ebd8cc17306656f9c7apatrick@chromium.org 1231f0dc0a09b1ea6ff03d235080d561840de8eb66Geoff Lang#if defined(ANGLE_TRANSLATOR_IMPLEMENTATION) 1322eab922e7cf9d47f1aa69ebd8cc17306656f9c7apatrick@chromium.org#define COMPILER_EXPORT __declspec(dllexport) 1422eab922e7cf9d47f1aa69ebd8cc17306656f9c7apatrick@chromium.org#else 1522eab922e7cf9d47f1aa69ebd8cc17306656f9c7apatrick@chromium.org#define COMPILER_EXPORT __declspec(dllimport) 1631f0dc0a09b1ea6ff03d235080d561840de8eb66Geoff Lang#endif // defined(ANGLE_TRANSLATOR_IMPLEMENTATION) 1722eab922e7cf9d47f1aa69ebd8cc17306656f9c7apatrick@chromium.org 1831f0dc0a09b1ea6ff03d235080d561840de8eb66Geoff Lang#else // defined(_WIN32) || defined(_WIN64) 1922eab922e7cf9d47f1aa69ebd8cc17306656f9c7apatrick@chromium.org#define COMPILER_EXPORT __attribute__((visibility("default"))) 2022eab922e7cf9d47f1aa69ebd8cc17306656f9c7apatrick@chromium.org#endif 2122eab922e7cf9d47f1aa69ebd8cc17306656f9c7apatrick@chromium.org 2231f0dc0a09b1ea6ff03d235080d561840de8eb66Geoff Lang#else // defined(COMPONENT_BUILD) && !defined(ANGLE_TRANSLATOR_STATIC) 2322eab922e7cf9d47f1aa69ebd8cc17306656f9c7apatrick@chromium.org#define COMPILER_EXPORT 2422eab922e7cf9d47f1aa69ebd8cc17306656f9c7apatrick@chromium.org#endif 2522eab922e7cf9d47f1aa69ebd8cc17306656f9c7apatrick@chromium.org 26d64b3dab06c30da1e5dd9ba12667ff86388540e2shannon.woods@transgaming.com#include <stddef.h> 27c23f4611be61bccdbfe2a5c43f63c4d98537ef9fdaniel@transgaming.com 28e294bb8741ec02fdb814ef3a3999c2d61c1e798fJamie Madill#include "KHR/khrplatform.h" 29e294bb8741ec02fdb814ef3a3999c2d61c1e798fJamie Madill 304f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.com// 314f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.com// This is the platform independent interface between an OGL driver 32774d70630a690b2449afdccfb29612393c65f212alokp@chromium.org// and the shading language compiler. 334f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.com// 344f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.com 35183bde5527317fa2208401e5e6b803ef51a0fdcbJamie Madillnamespace sh 36183bde5527317fa2208401e5e6b803ef51a0fdcbJamie Madill{ 37183bde5527317fa2208401e5e6b803ef51a0fdcbJamie Madill// GLenum alias 38183bde5527317fa2208401e5e6b803ef51a0fdcbJamie Madilltypedef unsigned int GLenum; 39183bde5527317fa2208401e5e6b803ef51a0fdcbJamie Madill} 40183bde5527317fa2208401e5e6b803ef51a0fdcbJamie Madill 41e294bb8741ec02fdb814ef3a3999c2d61c1e798fJamie Madill// Must be included after GLenum proxy typedef 4242bcf32e9d61f877b8e6bd089ab86382a3b7c9fdJamie Madill// Note: make sure to increment ANGLE_SH_VERSION when changing ShaderVars.h 43e294bb8741ec02fdb814ef3a3999c2d61c1e798fJamie Madill#include "ShaderVars.h" 44e294bb8741ec02fdb814ef3a3999c2d61c1e798fJamie Madill 454f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.com#ifdef __cplusplus 46774d70630a690b2449afdccfb29612393c65f212alokp@chromium.orgextern "C" { 474f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.com#endif 482fa73694ed9cb7ae617eec7cfb7d33728fe4928falokp@chromium.org 492fa73694ed9cb7ae617eec7cfb7d33728fe4928falokp@chromium.org// Version number for shader translation API. 50344e7142ed4cfd230840352990c331c3b2de7adfNicolas Capens// It is incremented every time the API changes. 5142bcf32e9d61f877b8e6bd089ab86382a3b7c9fdJamie Madill#define ANGLE_SH_VERSION 130 524888ceb6681c3668d3afcbdafdbe2b7efdaa3d04alokp@chromium.org 534888ceb6681c3668d3afcbdafdbe2b7efdaa3d04alokp@chromium.orgtypedef enum { 544888ceb6681c3668d3afcbdafdbe2b7efdaa3d04alokp@chromium.org SH_GLES2_SPEC = 0x8B40, 55430f5e0c75ade69935befb55d2592635f70255cemaxvujovic@gmail.com SH_WEBGL_SPEC = 0x8B41, 56430f5e0c75ade69935befb55d2592635f70255cemaxvujovic@gmail.com 57430f5e0c75ade69935befb55d2592635f70255cemaxvujovic@gmail.com // The CSS Shaders spec is a subset of the WebGL spec. 58430f5e0c75ade69935befb55d2592635f70255cemaxvujovic@gmail.com // 59430f5e0c75ade69935befb55d2592635f70255cemaxvujovic@gmail.com // In both CSS vertex and fragment shaders, ANGLE: 60430f5e0c75ade69935befb55d2592635f70255cemaxvujovic@gmail.com // (1) Reserves the "css_" prefix. 61430f5e0c75ade69935befb55d2592635f70255cemaxvujovic@gmail.com // (2) Renames the main function to css_main. 62430f5e0c75ade69935befb55d2592635f70255cemaxvujovic@gmail.com // (3) Disables the gl_MaxDrawBuffers built-in. 63430f5e0c75ade69935befb55d2592635f70255cemaxvujovic@gmail.com // 64430f5e0c75ade69935befb55d2592635f70255cemaxvujovic@gmail.com // In CSS fragment shaders, ANGLE: 65430f5e0c75ade69935befb55d2592635f70255cemaxvujovic@gmail.com // (1) Disables the gl_FragColor built-in. 66430f5e0c75ade69935befb55d2592635f70255cemaxvujovic@gmail.com // (2) Disables the gl_FragData built-in. 67430f5e0c75ade69935befb55d2592635f70255cemaxvujovic@gmail.com // (3) Enables the css_MixColor built-in. 68430f5e0c75ade69935befb55d2592635f70255cemaxvujovic@gmail.com // (4) Enables the css_ColorMatrix built-in. 69430f5e0c75ade69935befb55d2592635f70255cemaxvujovic@gmail.com // 70430f5e0c75ade69935befb55d2592635f70255cemaxvujovic@gmail.com // After passing a CSS shader through ANGLE, the browser is expected to append 71430f5e0c75ade69935befb55d2592635f70255cemaxvujovic@gmail.com // a new main function to it. 72430f5e0c75ade69935befb55d2592635f70255cemaxvujovic@gmail.com // This new main function will call the css_main function. 73430f5e0c75ade69935befb55d2592635f70255cemaxvujovic@gmail.com // It may also perform additional operations like varying assignment, texture 74430f5e0c75ade69935befb55d2592635f70255cemaxvujovic@gmail.com // access, and gl_FragColor assignment in order to implement the CSS Shaders 75430f5e0c75ade69935befb55d2592635f70255cemaxvujovic@gmail.com // blend modes. 76430f5e0c75ade69935befb55d2592635f70255cemaxvujovic@gmail.com // 77430f5e0c75ade69935befb55d2592635f70255cemaxvujovic@gmail.com SH_CSS_SHADERS_SPEC = 0x8B42 784888ceb6681c3668d3afcbdafdbe2b7efdaa3d04alokp@chromium.org} ShShaderSpec; 794888ceb6681c3668d3afcbdafdbe2b7efdaa3d04alokp@chromium.org 804888ceb6681c3668d3afcbdafdbe2b7efdaa3d04alokp@chromium.orgtypedef enum { 81b73964e328243021db10ecd98e3e124e82522c43shannon.woods@transgaming.com SH_ESSL_OUTPUT = 0x8B45, 82b73964e328243021db10ecd98e3e124e82522c43shannon.woods@transgaming.com SH_GLSL_OUTPUT = 0x8B46, 838204334b61162ce1b575e179265b90fbe8d23ef1shannon.woods@transgaming.com SH_HLSL_OUTPUT = 0x8B47, 84b73964e328243021db10ecd98e3e124e82522c43shannon.woods@transgaming.com SH_HLSL9_OUTPUT = 0x8B47, 85b73964e328243021db10ecd98e3e124e82522c43shannon.woods@transgaming.com SH_HLSL11_OUTPUT = 0x8B48 865601ea0d66442518d4745bb02b7619485b9d305bzmo@google.com} ShShaderOutput; 875601ea0d66442518d4745bb02b7619485b9d305bzmo@google.com 885601ea0d66442518d4745bb02b7619485b9d305bzmo@google.comtypedef enum { 89fa3c346fe9d832b163cfcff29bba5965bcaff08eZhenyao Mo SH_PRECISION_HIGHP = 0x5001, 90fa3c346fe9d832b163cfcff29bba5965bcaff08eZhenyao Mo SH_PRECISION_MEDIUMP = 0x5002, 91fa3c346fe9d832b163cfcff29bba5965bcaff08eZhenyao Mo SH_PRECISION_LOWP = 0x5003, 92fa3c346fe9d832b163cfcff29bba5965bcaff08eZhenyao Mo SH_PRECISION_UNDEFINED = 0 9374da9f2f24093e828b30071cebc09f99088fc13cZhenyao Mo} ShPrecisionType; 9474da9f2f24093e828b30071cebc09f99088fc13cZhenyao Mo 9574da9f2f24093e828b30071cebc09f99088fc13cZhenyao Motypedef enum { 9647fdd13e7c0ffa0a9c452a8659392b882ffbacccJamie Madill SH_INFO_LOG_LENGTH = 0x8B84, 9747fdd13e7c0ffa0a9c452a8659392b882ffbacccJamie Madill SH_OBJECT_CODE_LENGTH = 0x8B88, // GL_SHADER_SOURCE_LENGTH 9847fdd13e7c0ffa0a9c452a8659392b882ffbacccJamie Madill SH_ACTIVE_UNIFORMS = 0x8B86, 9947fdd13e7c0ffa0a9c452a8659392b882ffbacccJamie Madill SH_ACTIVE_UNIFORM_MAX_LENGTH = 0x8B87, 10047fdd13e7c0ffa0a9c452a8659392b882ffbacccJamie Madill SH_ACTIVE_ATTRIBUTES = 0x8B89, 10147fdd13e7c0ffa0a9c452a8659392b882ffbacccJamie Madill SH_ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8B8A, 10274da9f2f24093e828b30071cebc09f99088fc13cZhenyao Mo SH_VARYINGS = 0x8BBB, 10374da9f2f24093e828b30071cebc09f99088fc13cZhenyao Mo SH_VARYING_MAX_LENGTH = 0x8BBC, 10447fdd13e7c0ffa0a9c452a8659392b882ffbacccJamie Madill SH_MAPPED_NAME_MAX_LENGTH = 0x6000, 10547fdd13e7c0ffa0a9c452a8659392b882ffbacccJamie Madill SH_NAME_MAX_LENGTH = 0x6001, 10647fdd13e7c0ffa0a9c452a8659392b882ffbacccJamie Madill SH_HASHED_NAME_MAX_LENGTH = 0x6002, 10747fdd13e7c0ffa0a9c452a8659392b882ffbacccJamie Madill SH_HASHED_NAMES_COUNT = 0x6003, 108e294bb8741ec02fdb814ef3a3999c2d61c1e798fJamie Madill SH_SHADER_VERSION = 0x6004, 109e294bb8741ec02fdb814ef3a3999c2d61c1e798fJamie Madill SH_RESOURCES_STRING_LENGTH = 0x6005, 110e294bb8741ec02fdb814ef3a3999c2d61c1e798fJamie Madill SH_OUTPUT_TYPE = 0x6006 1114888ceb6681c3668d3afcbdafdbe2b7efdaa3d04alokp@chromium.org} ShShaderInfo; 1124888ceb6681c3668d3afcbdafdbe2b7efdaa3d04alokp@chromium.org 1134888ceb6681c3668d3afcbdafdbe2b7efdaa3d04alokp@chromium.org// Compile options. 1144888ceb6681c3668d3afcbdafdbe2b7efdaa3d04alokp@chromium.orgtypedef enum { 115fd747b861195a03df634a722a9cf3505dcd41253zmo@google.com SH_VALIDATE = 0, 116fd747b861195a03df634a722a9cf3505dcd41253zmo@google.com SH_VALIDATE_LOOP_INDEXING = 0x0001, 117fd747b861195a03df634a722a9cf3505dcd41253zmo@google.com SH_INTERMEDIATE_TREE = 0x0002, 118fd747b861195a03df634a722a9cf3505dcd41253zmo@google.com SH_OBJECT_CODE = 0x0004, 11974da9f2f24093e828b30071cebc09f99088fc13cZhenyao Mo SH_VARIABLES = 0x0008, 120fd747b861195a03df634a722a9cf3505dcd41253zmo@google.com SH_LINE_DIRECTIVES = 0x0010, 121fd747b861195a03df634a722a9cf3505dcd41253zmo@google.com SH_SOURCE_PATH = 0x0020, 1223cdfcce86b38ef31a0afd71855887193a7924468Zhenyao Mo SH_UNROLL_FOR_LOOP_WITH_INTEGER_INDEX = 0x0040, 123550c600b99d7ee2463e5878d0a9f66ea24c1414aZhenyao Mo // If a sampler array index happens to be a loop index, 124550c600b99d7ee2463e5878d0a9f66ea24c1414aZhenyao Mo // 1) if its type is integer, unroll the loop. 125550c600b99d7ee2463e5878d0a9f66ea24c1414aZhenyao Mo // 2) if its type is float, fail the shader compile. 126550c600b99d7ee2463e5878d0a9f66ea24c1414aZhenyao Mo // This is to work around a mac driver bug. 1273cdfcce86b38ef31a0afd71855887193a7924468Zhenyao Mo SH_UNROLL_FOR_LOOP_WITH_SAMPLER_ARRAY_INDEX = 0x0080, 12832e97315e2a55557ad7c372239e0823a81243221zmo@google.com 12932e97315e2a55557ad7c372239e0823a81243221zmo@google.com // This is needed only as a workaround for certain OpenGL driver bugs. 1303cdfcce86b38ef31a0afd71855887193a7924468Zhenyao Mo SH_EMULATE_BUILT_IN_FUNCTIONS = 0x0100, 13166ebd0143ea40a9beb83eab5d86e24f52825b3famaxvujovic@gmail.com 13266ebd0143ea40a9beb83eab5d86e24f52825b3famaxvujovic@gmail.com // This is an experimental flag to enforce restrictions that aim to prevent 13366ebd0143ea40a9beb83eab5d86e24f52825b3famaxvujovic@gmail.com // timing attacks. 13466ebd0143ea40a9beb83eab5d86e24f52825b3famaxvujovic@gmail.com // It generates compilation errors for shaders that could expose sensitive 13566ebd0143ea40a9beb83eab5d86e24f52825b3famaxvujovic@gmail.com // texture information via the timing channel. 13666ebd0143ea40a9beb83eab5d86e24f52825b3famaxvujovic@gmail.com // To use this flag, you must compile the shader under the WebGL spec 13766ebd0143ea40a9beb83eab5d86e24f52825b3famaxvujovic@gmail.com // (using the SH_WEBGL_SPEC flag). 1383cdfcce86b38ef31a0afd71855887193a7924468Zhenyao Mo SH_TIMING_RESTRICTIONS = 0x0200, 139550c600b99d7ee2463e5878d0a9f66ea24c1414aZhenyao Mo 14066ebd0143ea40a9beb83eab5d86e24f52825b3famaxvujovic@gmail.com // This flag prints the dependency graph that is used to enforce timing 14166ebd0143ea40a9beb83eab5d86e24f52825b3famaxvujovic@gmail.com // restrictions on fragment shaders. 14266ebd0143ea40a9beb83eab5d86e24f52825b3famaxvujovic@gmail.com // This flag only has an effect if all of the following are true: 14366ebd0143ea40a9beb83eab5d86e24f52825b3famaxvujovic@gmail.com // - The shader spec is SH_WEBGL_SPEC. 14466ebd0143ea40a9beb83eab5d86e24f52825b3famaxvujovic@gmail.com // - The compile options contain the SH_TIMING_RESTRICTIONS flag. 145183bde5527317fa2208401e5e6b803ef51a0fdcbJamie Madill // - The shader type is GL_FRAGMENT_SHADER. 1463cdfcce86b38ef31a0afd71855887193a7924468Zhenyao Mo SH_DEPENDENCY_GRAPH = 0x0400, 1478d8047995445882c73091578b889226323f38053gman@chromium.org 1488d8047995445882c73091578b889226323f38053gman@chromium.org // Enforce the GLSL 1.017 Appendix A section 7 packing restrictions. 149a15f3e84bfc96b9ef97dd10150f8811adcbbdebfZhenyao Mo // This flag only enforces (and can only enforce) the packing 150a15f3e84bfc96b9ef97dd10150f8811adcbbdebfZhenyao Mo // restrictions for uniform variables in both vertex and fragment 151a15f3e84bfc96b9ef97dd10150f8811adcbbdebfZhenyao Mo // shaders. ShCheckVariablesWithinPackingLimits() lets embedders 152a15f3e84bfc96b9ef97dd10150f8811adcbbdebfZhenyao Mo // enforce the packing restrictions for varying variables during 153a15f3e84bfc96b9ef97dd10150f8811adcbbdebfZhenyao Mo // program link time. 1543cdfcce86b38ef31a0afd71855887193a7924468Zhenyao Mo SH_ENFORCE_PACKING_RESTRICTIONS = 0x0800, 1554167cc910276be723901f187dec45d04275abb7edaniel@transgaming.com 1564167cc910276be723901f187dec45d04275abb7edaniel@transgaming.com // This flag ensures all indirect (expression-based) array indexing 1574167cc910276be723901f187dec45d04275abb7edaniel@transgaming.com // is clamped to the bounds of the array. This ensures, for example, 1584167cc910276be723901f187dec45d04275abb7edaniel@transgaming.com // that you cannot read off the end of a uniform, whether an array 1591d432bb570bd175c3cdc51629a386e324e98b95bshannon.woods@transgaming.com // vec234, or mat234 type. The ShArrayIndexClampingStrategy enum, 1601d432bb570bd175c3cdc51629a386e324e98b95bshannon.woods@transgaming.com // specified in the ShBuiltInResources when constructing the 1611d432bb570bd175c3cdc51629a386e324e98b95bshannon.woods@transgaming.com // compiler, selects the strategy for the clamping implementation. 1623cdfcce86b38ef31a0afd71855887193a7924468Zhenyao Mo SH_CLAMP_INDIRECT_ARRAY_BOUNDS = 0x1000, 163eb1a010f0f996b3742fd34b92ffaf9014c943528Jamie Madill 164eb1a010f0f996b3742fd34b92ffaf9014c943528Jamie Madill // This flag limits the complexity of an expression. 1653cdfcce86b38ef31a0afd71855887193a7924468Zhenyao Mo SH_LIMIT_EXPRESSION_COMPLEXITY = 0x2000, 166eb1a010f0f996b3742fd34b92ffaf9014c943528Jamie Madill 167eb1a010f0f996b3742fd34b92ffaf9014c943528Jamie Madill // This flag limits the depth of the call stack. 1683cdfcce86b38ef31a0afd71855887193a7924468Zhenyao Mo SH_LIMIT_CALL_STACK_DEPTH = 0x4000, 169ac44cd2b072916b83f079bbfda66636491279d2eZhenyao Mo 1704a667fe96e55df4713532e3830dd215ac7696f53Zhenyao Mo // This flag initializes gl_Position to vec4(0,0,0,0) at the 1714a667fe96e55df4713532e3830dd215ac7696f53Zhenyao Mo // beginning of the vertex shader's main(), and has no effect in the 172ac44cd2b072916b83f079bbfda66636491279d2eZhenyao Mo // fragment shader. It is intended as a workaround for drivers which 173ac44cd2b072916b83f079bbfda66636491279d2eZhenyao Mo // incorrectly fail to link programs if gl_Position is not written. 1743cdfcce86b38ef31a0afd71855887193a7924468Zhenyao Mo SH_INIT_GL_POSITION = 0x8000, 1757cab38b594213c7c80f70871b72d40d30e878035Zhenyao Mo 1767cab38b594213c7c80f70871b72d40d30e878035Zhenyao Mo // This flag replaces 1777cab38b594213c7c80f70871b72d40d30e878035Zhenyao Mo // "a && b" with "a ? b : false", 1787cab38b594213c7c80f70871b72d40d30e878035Zhenyao Mo // "a || b" with "a ? true : b". 1797cab38b594213c7c80f70871b72d40d30e878035Zhenyao Mo // This is to work around a MacOSX driver bug that |b| is executed 1807cab38b594213c7c80f70871b72d40d30e878035Zhenyao Mo // independent of |a|'s value. 1813cdfcce86b38ef31a0afd71855887193a7924468Zhenyao Mo SH_UNFOLD_SHORT_CIRCUIT = 0x10000, 1824a667fe96e55df4713532e3830dd215ac7696f53Zhenyao Mo 1834a667fe96e55df4713532e3830dd215ac7696f53Zhenyao Mo // This flag initializes varyings without static use in vertex shader 1844a667fe96e55df4713532e3830dd215ac7696f53Zhenyao Mo // at the beginning of main(), and has no effects in the fragment shader. 1854a667fe96e55df4713532e3830dd215ac7696f53Zhenyao Mo // It is intended as a workaround for drivers which incorrectly optimize 1864a667fe96e55df4713532e3830dd215ac7696f53Zhenyao Mo // out such varyings and cause a link failure. 1873cdfcce86b38ef31a0afd71855887193a7924468Zhenyao Mo SH_INIT_VARYINGS_WITHOUT_STATIC_USE = 0x20000, 188cd68fe7989afb5e5a9b1ae92ae1dae1478a9d1f6Zhenyao Mo 189cd68fe7989afb5e5a9b1ae92ae1dae1478a9d1f6Zhenyao Mo // This flag scalarizes vec/ivec/bvec/mat constructor args. 190cd68fe7989afb5e5a9b1ae92ae1dae1478a9d1f6Zhenyao Mo // It is intended as a workaround for Linux/Mac driver bugs. 191cd68fe7989afb5e5a9b1ae92ae1dae1478a9d1f6Zhenyao Mo SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS = 0x40000, 192e740addbc2ab1a7928775814115771c96848ac18Zhenyao Mo 193e740addbc2ab1a7928775814115771c96848ac18Zhenyao Mo // This flag overwrites a struct name with a unique prefix. 194e740addbc2ab1a7928775814115771c96848ac18Zhenyao Mo // It is intended as a workaround for drivers that do not handle 195e740addbc2ab1a7928775814115771c96848ac18Zhenyao Mo // struct scopes correctly, including all Mac drivers and Linux AMD. 196e740addbc2ab1a7928775814115771c96848ac18Zhenyao Mo SH_REGENERATE_STRUCT_NAMES = 0x80000, 1974888ceb6681c3668d3afcbdafdbe2b7efdaa3d04alokp@chromium.org} ShCompileOptions; 1982fa73694ed9cb7ae617eec7cfb7d33728fe4928falokp@chromium.org 1991d432bb570bd175c3cdc51629a386e324e98b95bshannon.woods@transgaming.com// Defines alternate strategies for implementing array index clamping. 2001d432bb570bd175c3cdc51629a386e324e98b95bshannon.woods@transgaming.comtypedef enum { 2011d432bb570bd175c3cdc51629a386e324e98b95bshannon.woods@transgaming.com // Use the clamp intrinsic for array index clamping. 2021d432bb570bd175c3cdc51629a386e324e98b95bshannon.woods@transgaming.com SH_CLAMP_WITH_CLAMP_INTRINSIC = 1, 2031d432bb570bd175c3cdc51629a386e324e98b95bshannon.woods@transgaming.com 2041d432bb570bd175c3cdc51629a386e324e98b95bshannon.woods@transgaming.com // Use a user-defined function for array index clamping. 2051d432bb570bd175c3cdc51629a386e324e98b95bshannon.woods@transgaming.com SH_CLAMP_WITH_USER_DEFINED_INT_CLAMP_FUNCTION 2061d432bb570bd175c3cdc51629a386e324e98b95bshannon.woods@transgaming.com} ShArrayIndexClampingStrategy; 2071d432bb570bd175c3cdc51629a386e324e98b95bshannon.woods@transgaming.com 2084f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.com// 2094f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.com// Driver must call this first, once, before doing any other 210774d70630a690b2449afdccfb29612393c65f212alokp@chromium.org// compiler operations. 211b3999348999ae86bfc8fd2d543eec2c51f6a2c8falokp@chromium.org// If the function succeeds, the return value is nonzero, else zero. 2124f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.com// 21322eab922e7cf9d47f1aa69ebd8cc17306656f9c7apatrick@chromium.orgCOMPILER_EXPORT int ShInitialize(); 2144f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.com// 2154f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.com// Driver should call this at shutdown. 216b3999348999ae86bfc8fd2d543eec2c51f6a2c8falokp@chromium.org// If the function succeeds, the return value is nonzero, else zero. 2174f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.com// 21822eab922e7cf9d47f1aa69ebd8cc17306656f9c7apatrick@chromium.orgCOMPILER_EXPORT int ShFinalize(); 21929cd91af30e76623b2c12a90b43378a9b97bb6d1alokp@chromium.org 220c23f4611be61bccdbfe2a5c43f63c4d98537ef9fdaniel@transgaming.com// The 64 bits hash function. The first parameter is the input string; the 221c23f4611be61bccdbfe2a5c43f63c4d98537ef9fdaniel@transgaming.com// second parameter is the string length. 222d64b3dab06c30da1e5dd9ba12667ff86388540e2shannon.woods@transgaming.comtypedef khronos_uint64_t (*ShHashFunction64)(const char*, size_t); 223c23f4611be61bccdbfe2a5c43f63c4d98537ef9fdaniel@transgaming.com 22429cd91af30e76623b2c12a90b43378a9b97bb6d1alokp@chromium.org// 22594a86ad8f1ace86e9dc08088cd2e85d0b9f842f0alokp@chromium.org// Implementation dependent built-in resources (constants and extensions). 22694a86ad8f1ace86e9dc08088cd2e85d0b9f842f0alokp@chromium.org// The names for these resources has been obtained by stripping gl_/GL_. 22794a86ad8f1ace86e9dc08088cd2e85d0b9f842f0alokp@chromium.org// 22894a86ad8f1ace86e9dc08088cd2e85d0b9f842f0alokp@chromium.orgtypedef struct 22994a86ad8f1ace86e9dc08088cd2e85d0b9f842f0alokp@chromium.org{ 23094a86ad8f1ace86e9dc08088cd2e85d0b9f842f0alokp@chromium.org // Constants. 23194a86ad8f1ace86e9dc08088cd2e85d0b9f842f0alokp@chromium.org int MaxVertexAttribs; 23294a86ad8f1ace86e9dc08088cd2e85d0b9f842f0alokp@chromium.org int MaxVertexUniformVectors; 23394a86ad8f1ace86e9dc08088cd2e85d0b9f842f0alokp@chromium.org int MaxVaryingVectors; 23494a86ad8f1ace86e9dc08088cd2e85d0b9f842f0alokp@chromium.org int MaxVertexTextureImageUnits; 23594a86ad8f1ace86e9dc08088cd2e85d0b9f842f0alokp@chromium.org int MaxCombinedTextureImageUnits; 23694a86ad8f1ace86e9dc08088cd2e85d0b9f842f0alokp@chromium.org int MaxTextureImageUnits; 23794a86ad8f1ace86e9dc08088cd2e85d0b9f842f0alokp@chromium.org int MaxFragmentUniformVectors; 23894a86ad8f1ace86e9dc08088cd2e85d0b9f842f0alokp@chromium.org int MaxDrawBuffers; 23994a86ad8f1ace86e9dc08088cd2e85d0b9f842f0alokp@chromium.org 24094a86ad8f1ace86e9dc08088cd2e85d0b9f842f0alokp@chromium.org // Extensions. 24194a86ad8f1ace86e9dc08088cd2e85d0b9f842f0alokp@chromium.org // Set to 1 to enable the extension, else 0. 24294a86ad8f1ace86e9dc08088cd2e85d0b9f842f0alokp@chromium.org int OES_standard_derivatives; 24309c323a40ad0de489eee946bfe171d337616e09czmo@google.com int OES_EGL_image_external; 244205fef3389c81637f689585431273cf83af02e94kbr@chromium.org int ARB_texture_rectangle; 245550cd0988989cc3e117fb300c919504f7bd99c48shannon.woods@transgaming.com int EXT_draw_buffers; 2462aeb26a4f6e21a923415eb00499795b63a17ef76Jamie Madill int EXT_frag_depth; 247464850868307005a1287d79f7a640f05372358bbNicolas Capens int EXT_shader_texture_lod; 248c23f4611be61bccdbfe2a5c43f63c4d98537ef9fdaniel@transgaming.com 249cbb6b6a0416552b5e3fa8589194288532558ccb8shannon.woods%transgaming.com@gtempaccount.com // Set to 1 if highp precision is supported in the fragment language. 250cbb6b6a0416552b5e3fa8589194288532558ccb8shannon.woods%transgaming.com@gtempaccount.com // Default is 0. 251cbb6b6a0416552b5e3fa8589194288532558ccb8shannon.woods%transgaming.com@gtempaccount.com int FragmentPrecisionHigh; 252cbb6b6a0416552b5e3fa8589194288532558ccb8shannon.woods%transgaming.com@gtempaccount.com 25374b86cffade4b3dbfddd3c601b35b87ef28a82a6shannonwoods@chromium.org // GLSL ES 3.0 constants. 25474b86cffade4b3dbfddd3c601b35b87ef28a82a6shannonwoods@chromium.org int MaxVertexOutputVectors; 25574b86cffade4b3dbfddd3c601b35b87ef28a82a6shannonwoods@chromium.org int MaxFragmentInputVectors; 25674b86cffade4b3dbfddd3c601b35b87ef28a82a6shannonwoods@chromium.org int MinProgramTexelOffset; 25774b86cffade4b3dbfddd3c601b35b87ef28a82a6shannonwoods@chromium.org int MaxProgramTexelOffset; 25874b86cffade4b3dbfddd3c601b35b87ef28a82a6shannonwoods@chromium.org 259c23f4611be61bccdbfe2a5c43f63c4d98537ef9fdaniel@transgaming.com // Name Hashing. 260c23f4611be61bccdbfe2a5c43f63c4d98537ef9fdaniel@transgaming.com // Set a 64 bit hash function to enable user-defined name hashing. 261c23f4611be61bccdbfe2a5c43f63c4d98537ef9fdaniel@transgaming.com // Default is NULL. 262c23f4611be61bccdbfe2a5c43f63c4d98537ef9fdaniel@transgaming.com ShHashFunction64 HashFunction; 2631d432bb570bd175c3cdc51629a386e324e98b95bshannon.woods@transgaming.com 2641d432bb570bd175c3cdc51629a386e324e98b95bshannon.woods@transgaming.com // Selects a strategy to use when implementing array index clamping. 2651d432bb570bd175c3cdc51629a386e324e98b95bshannon.woods@transgaming.com // Default is SH_CLAMP_WITH_CLAMP_INTRINSIC. 2661d432bb570bd175c3cdc51629a386e324e98b95bshannon.woods@transgaming.com ShArrayIndexClampingStrategy ArrayIndexClampingStrategy; 267eb1a010f0f996b3742fd34b92ffaf9014c943528Jamie Madill 268eb1a010f0f996b3742fd34b92ffaf9014c943528Jamie Madill // The maximum complexity an expression can be. 269eb1a010f0f996b3742fd34b92ffaf9014c943528Jamie Madill int MaxExpressionComplexity; 270eb1a010f0f996b3742fd34b92ffaf9014c943528Jamie Madill 271eb1a010f0f996b3742fd34b92ffaf9014c943528Jamie Madill // The maximum depth a call stack can be. 272eb1a010f0f996b3742fd34b92ffaf9014c943528Jamie Madill int MaxCallStackDepth; 2734888ceb6681c3668d3afcbdafdbe2b7efdaa3d04alokp@chromium.org} ShBuiltInResources; 27494a86ad8f1ace86e9dc08088cd2e85d0b9f842f0alokp@chromium.org 27594a86ad8f1ace86e9dc08088cd2e85d0b9f842f0alokp@chromium.org// 27694a86ad8f1ace86e9dc08088cd2e85d0b9f842f0alokp@chromium.org// Initialize built-in resources with minimum expected values. 27794a86ad8f1ace86e9dc08088cd2e85d0b9f842f0alokp@chromium.org// 27822eab922e7cf9d47f1aa69ebd8cc17306656f9c7apatrick@chromium.orgCOMPILER_EXPORT void ShInitBuiltInResources(ShBuiltInResources* resources); 27994a86ad8f1ace86e9dc08088cd2e85d0b9f842f0alokp@chromium.org 28094a86ad8f1ace86e9dc08088cd2e85d0b9f842f0alokp@chromium.org// 2814f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.com// ShHandle held by but opaque to the driver. It is allocated, 2822d76e5f66595e1cef04f4ad678deda0d0e4643d7Shannon Woods// managed, and de-allocated by the compiler. Its contents 283774d70630a690b2449afdccfb29612393c65f212alokp@chromium.org// are defined by and used by the compiler. 2844f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.com// 2854f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.com// If handle creation fails, 0 will be returned. 2864f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.com// 2874f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.comtypedef void* ShHandle; 2884f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.com 2894f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.com// 2902d76e5f66595e1cef04f4ad678deda0d0e4643d7Shannon Woods// Returns the a concatenated list of the items in ShBuiltInResources as a string. 2912d76e5f66595e1cef04f4ad678deda0d0e4643d7Shannon Woods// This function must be updated whenever ShBuiltInResources is changed. 2922d76e5f66595e1cef04f4ad678deda0d0e4643d7Shannon Woods// Parameters: 2932d76e5f66595e1cef04f4ad678deda0d0e4643d7Shannon Woods// handle: Specifies the handle of the compiler to be used. 2942d76e5f66595e1cef04f4ad678deda0d0e4643d7Shannon Woods// outStringLen: Specifies the size of the buffer, in number of characters. The size 2952d76e5f66595e1cef04f4ad678deda0d0e4643d7Shannon Woods// of the buffer required to store the resources string can be obtained 2962d76e5f66595e1cef04f4ad678deda0d0e4643d7Shannon Woods// by calling ShGetInfo with SH_RESOURCES_STRING_LENGTH. 2972d76e5f66595e1cef04f4ad678deda0d0e4643d7Shannon Woods// outStr: Returns a null-terminated string representing all the built-in resources. 2982d76e5f66595e1cef04f4ad678deda0d0e4643d7Shannon WoodsCOMPILER_EXPORT void ShGetBuiltInResourcesString(const ShHandle handle, size_t outStringLen, char *outStr); 2992d76e5f66595e1cef04f4ad678deda0d0e4643d7Shannon Woods 3002d76e5f66595e1cef04f4ad678deda0d0e4643d7Shannon Woods// 301774d70630a690b2449afdccfb29612393c65f212alokp@chromium.org// Driver calls these to create and destroy compiler objects. 3024f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.com// 3035601ea0d66442518d4745bb02b7619485b9d305bzmo@google.com// Returns the handle of constructed compiler, null if the requested compiler is 3045601ea0d66442518d4745bb02b7619485b9d305bzmo@google.com// not supported. 3054888ceb6681c3668d3afcbdafdbe2b7efdaa3d04alokp@chromium.org// Parameters: 306183bde5527317fa2208401e5e6b803ef51a0fdcbJamie Madill// type: Specifies the type of shader - GL_FRAGMENT_SHADER or GL_VERTEX_SHADER. 3074888ceb6681c3668d3afcbdafdbe2b7efdaa3d04alokp@chromium.org// spec: Specifies the language spec the compiler must conform to - 3084888ceb6681c3668d3afcbdafdbe2b7efdaa3d04alokp@chromium.org// SH_GLES2_SPEC or SH_WEBGL_SPEC. 3095601ea0d66442518d4745bb02b7619485b9d305bzmo@google.com// output: Specifies the output code type - SH_ESSL_OUTPUT, SH_GLSL_OUTPUT, 3108204334b61162ce1b575e179265b90fbe8d23ef1shannon.woods@transgaming.com// SH_HLSL9_OUTPUT or SH_HLSL11_OUTPUT. 3114888ceb6681c3668d3afcbdafdbe2b7efdaa3d04alokp@chromium.org// resources: Specifies the built-in resources. 31222eab922e7cf9d47f1aa69ebd8cc17306656f9c7apatrick@chromium.orgCOMPILER_EXPORT ShHandle ShConstructCompiler( 313183bde5527317fa2208401e5e6b803ef51a0fdcbJamie Madill sh::GLenum type, 31422eab922e7cf9d47f1aa69ebd8cc17306656f9c7apatrick@chromium.org ShShaderSpec spec, 31522eab922e7cf9d47f1aa69ebd8cc17306656f9c7apatrick@chromium.org ShShaderOutput output, 31622eab922e7cf9d47f1aa69ebd8cc17306656f9c7apatrick@chromium.org const ShBuiltInResources* resources); 31722eab922e7cf9d47f1aa69ebd8cc17306656f9c7apatrick@chromium.orgCOMPILER_EXPORT void ShDestruct(ShHandle handle); 3184f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.com 3194888ceb6681c3668d3afcbdafdbe2b7efdaa3d04alokp@chromium.org// 3204888ceb6681c3668d3afcbdafdbe2b7efdaa3d04alokp@chromium.org// Compiles the given shader source. 3214888ceb6681c3668d3afcbdafdbe2b7efdaa3d04alokp@chromium.org// If the function succeeds, the return value is nonzero, else zero. 3224888ceb6681c3668d3afcbdafdbe2b7efdaa3d04alokp@chromium.org// Parameters: 3234888ceb6681c3668d3afcbdafdbe2b7efdaa3d04alokp@chromium.org// handle: Specifies the handle of compiler to be used. 3244888ceb6681c3668d3afcbdafdbe2b7efdaa3d04alokp@chromium.org// shaderStrings: Specifies an array of pointers to null-terminated strings 3254888ceb6681c3668d3afcbdafdbe2b7efdaa3d04alokp@chromium.org// containing the shader source code. 3264888ceb6681c3668d3afcbdafdbe2b7efdaa3d04alokp@chromium.org// numStrings: Specifies the number of elements in shaderStrings array. 3274888ceb6681c3668d3afcbdafdbe2b7efdaa3d04alokp@chromium.org// compileOptions: A mask containing the following parameters: 3281f29954dc7d433d6a69c4ec7bd07b7153f8d4b99alokp@chromium.org// SH_VALIDATE: Validates shader to ensure that it conforms to the spec 3291f29954dc7d433d6a69c4ec7bd07b7153f8d4b99alokp@chromium.org// specified during compiler construction. 330b59a778cfe7e36dca41c2cc44198da511f447be8alokp@chromium.org// SH_VALIDATE_LOOP_INDEXING: Validates loop and indexing in the shader to 331b59a778cfe7e36dca41c2cc44198da511f447be8alokp@chromium.org// ensure that they do not exceed the minimum 332b59a778cfe7e36dca41c2cc44198da511f447be8alokp@chromium.org// functionality mandated in GLSL 1.0 spec, 333b59a778cfe7e36dca41c2cc44198da511f447be8alokp@chromium.org// Appendix A, Section 4 and 5. 334b59a778cfe7e36dca41c2cc44198da511f447be8alokp@chromium.org// There is no need to specify this parameter when 335b59a778cfe7e36dca41c2cc44198da511f447be8alokp@chromium.org// compiling for WebGL - it is implied. 3364888ceb6681c3668d3afcbdafdbe2b7efdaa3d04alokp@chromium.org// SH_INTERMEDIATE_TREE: Writes intermediate tree to info log. 3374888ceb6681c3668d3afcbdafdbe2b7efdaa3d04alokp@chromium.org// Can be queried by calling ShGetInfoLog(). 3384888ceb6681c3668d3afcbdafdbe2b7efdaa3d04alokp@chromium.org// SH_OBJECT_CODE: Translates intermediate tree to glsl or hlsl shader. 3394888ceb6681c3668d3afcbdafdbe2b7efdaa3d04alokp@chromium.org// Can be queried by calling ShGetObjectCode(). 34074da9f2f24093e828b30071cebc09f99088fc13cZhenyao Mo// SH_VARIABLES: Extracts attributes, uniforms, and varyings. 34174da9f2f24093e828b30071cebc09f99088fc13cZhenyao Mo// Can be queried by calling ShGetVariableInfo(). 3424f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.com// 34322eab922e7cf9d47f1aa69ebd8cc17306656f9c7apatrick@chromium.orgCOMPILER_EXPORT int ShCompile( 3444888ceb6681c3668d3afcbdafdbe2b7efdaa3d04alokp@chromium.org const ShHandle handle, 345774d70630a690b2449afdccfb29612393c65f212alokp@chromium.org const char* const shaderStrings[], 346d64b3dab06c30da1e5dd9ba12667ff86388540e2shannon.woods@transgaming.com size_t numStrings, 3477beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org int compileOptions 348774d70630a690b2449afdccfb29612393c65f212alokp@chromium.org ); 3494f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.com 3507beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// Returns a parameter from a compiled shader. 3517beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// Parameters: 3527beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// handle: Specifies the compiler 3537beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// pname: Specifies the parameter to query. 3547beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// The following parameters are defined: 3557beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// SH_INFO_LOG_LENGTH: the number of characters in the information log 3567beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// including the null termination character. 3577beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// SH_OBJECT_CODE_LENGTH: the number of characters in the object code 3587beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// including the null termination character. 3597beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// SH_ACTIVE_ATTRIBUTES: the number of active attribute variables. 3607beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// SH_ACTIVE_ATTRIBUTE_MAX_LENGTH: the length of the longest active attribute 3617beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// variable name including the null 3627beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// termination character. 3637beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// SH_ACTIVE_UNIFORMS: the number of active uniform variables. 3647beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// SH_ACTIVE_UNIFORM_MAX_LENGTH: the length of the longest active uniform 3657beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// variable name including the null 3667beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// termination character. 36774da9f2f24093e828b30071cebc09f99088fc13cZhenyao Mo// SH_VARYINGS: the number of varying variables. 36874da9f2f24093e828b30071cebc09f99088fc13cZhenyao Mo// SH_VARYING_MAX_LENGTH: the length of the longest varying variable name 36974da9f2f24093e828b30071cebc09f99088fc13cZhenyao Mo// including the null termination character. 370fd747b861195a03df634a722a9cf3505dcd41253zmo@google.com// SH_MAPPED_NAME_MAX_LENGTH: the length of the mapped variable name including 371fd747b861195a03df634a722a9cf3505dcd41253zmo@google.com// the null termination character. 372c23f4611be61bccdbfe2a5c43f63c4d98537ef9fdaniel@transgaming.com// SH_NAME_MAX_LENGTH: the max length of a user-defined name including the 373c23f4611be61bccdbfe2a5c43f63c4d98537ef9fdaniel@transgaming.com// null termination character. 374c23f4611be61bccdbfe2a5c43f63c4d98537ef9fdaniel@transgaming.com// SH_HASHED_NAME_MAX_LENGTH: the max length of a hashed name including the 375c23f4611be61bccdbfe2a5c43f63c4d98537ef9fdaniel@transgaming.com// null termination character. 376c23f4611be61bccdbfe2a5c43f63c4d98537ef9fdaniel@transgaming.com// SH_HASHED_NAMES_COUNT: the number of hashed names from the latest compile. 3770bbed38f417d490604909de5928d725fb39c5e3cshannon.woods%transgaming.com@gtempaccount.com// SH_SHADER_VERSION: the version of the shader language 37868fe74aabbb4d8ae08aadcf22705f0d85a16e0b5Jamie Madill// SH_OUTPUT_TYPE: the currently set language output type 379d64b3dab06c30da1e5dd9ba12667ff86388540e2shannon.woods@transgaming.com// 3807beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// params: Requested parameter 38122eab922e7cf9d47f1aa69ebd8cc17306656f9c7apatrick@chromium.orgCOMPILER_EXPORT void ShGetInfo(const ShHandle handle, 38222eab922e7cf9d47f1aa69ebd8cc17306656f9c7apatrick@chromium.org ShShaderInfo pname, 383d64b3dab06c30da1e5dd9ba12667ff86388540e2shannon.woods@transgaming.com size_t* params); 3847beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org 3857beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// Returns nul-terminated information log for a compiled shader. 3867beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// Parameters: 3877beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// handle: Specifies the compiler 3887beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// infoLog: Specifies an array of characters that is used to return 3897beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// the information log. It is assumed that infoLog has enough memory 3907beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// to accomodate the information log. The size of the buffer required 3917beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// to store the returned information log can be obtained by calling 3927beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// ShGetInfo with SH_INFO_LOG_LENGTH. 39322eab922e7cf9d47f1aa69ebd8cc17306656f9c7apatrick@chromium.orgCOMPILER_EXPORT void ShGetInfoLog(const ShHandle handle, char* infoLog); 3947beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org 3957beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// Returns null-terminated object code for a compiled shader. 3967beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// Parameters: 3977beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// handle: Specifies the compiler 3987beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// infoLog: Specifies an array of characters that is used to return 3997beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// the object code. It is assumed that infoLog has enough memory to 4007beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// accomodate the object code. The size of the buffer required to 4017beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// store the returned object code can be obtained by calling 4027beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// ShGetInfo with SH_OBJECT_CODE_LENGTH. 40322eab922e7cf9d47f1aa69ebd8cc17306656f9c7apatrick@chromium.orgCOMPILER_EXPORT void ShGetObjectCode(const ShHandle handle, char* objCode); 4047beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org 40574da9f2f24093e828b30071cebc09f99088fc13cZhenyao Mo// Returns information about a shader variable. 4067beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// Parameters: 4077beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// handle: Specifies the compiler 40874da9f2f24093e828b30071cebc09f99088fc13cZhenyao Mo// variableType: Specifies the variable type; options include 40974da9f2f24093e828b30071cebc09f99088fc13cZhenyao Mo// SH_ACTIVE_ATTRIBUTES, SH_ACTIVE_UNIFORMS, SH_VARYINGS. 41074da9f2f24093e828b30071cebc09f99088fc13cZhenyao Mo// index: Specifies the index of the variable to be queried. 4117beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// length: Returns the number of characters actually written in the string 4127beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// indicated by name (excluding the null terminator) if a value other 4137beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// than NULL is passed. 41474da9f2f24093e828b30071cebc09f99088fc13cZhenyao Mo// size: Returns the size of the variable. 41574da9f2f24093e828b30071cebc09f99088fc13cZhenyao Mo// type: Returns the data type of the variable. 41674da9f2f24093e828b30071cebc09f99088fc13cZhenyao Mo// precision: Returns the precision of the variable. 417d2d340b0da87296b1ec04799ef4c811966bfb7aeZhenyao Mo// staticUse: Returns 1 if the variable is accessed in a statement after 418d2d340b0da87296b1ec04799ef4c811966bfb7aeZhenyao Mo// pre-processing, whether or not run-time flow of control will 419d2d340b0da87296b1ec04799ef4c811966bfb7aeZhenyao Mo// cause that statement to be executed. 420d2d340b0da87296b1ec04799ef4c811966bfb7aeZhenyao Mo// Returns 0 otherwise. 4217beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org// name: Returns a null terminated string containing the name of the 42274da9f2f24093e828b30071cebc09f99088fc13cZhenyao Mo// variable. It is assumed that name has enough memory to accormodate 42374da9f2f24093e828b30071cebc09f99088fc13cZhenyao Mo// the variable name. The size of the buffer required to store the 42474da9f2f24093e828b30071cebc09f99088fc13cZhenyao Mo// variable name can be obtained by calling ShGetInfo with 42574da9f2f24093e828b30071cebc09f99088fc13cZhenyao Mo// SH_ACTIVE_ATTRIBUTE_MAX_LENGTH, SH_ACTIVE_UNIFORM_MAX_LENGTH, 42674da9f2f24093e828b30071cebc09f99088fc13cZhenyao Mo// SH_VARYING_MAX_LENGTH. 427fd747b861195a03df634a722a9cf3505dcd41253zmo@google.com// mappedName: Returns a null terminated string containing the mapped name of 42874da9f2f24093e828b30071cebc09f99088fc13cZhenyao Mo// the variable, It is assumed that mappedName has enough memory 42974da9f2f24093e828b30071cebc09f99088fc13cZhenyao Mo// (SH_MAPPED_NAME_MAX_LENGTH), or NULL if don't care about the 43074da9f2f24093e828b30071cebc09f99088fc13cZhenyao Mo// mapped name. If the name is not mapped, then name and mappedName 43174da9f2f24093e828b30071cebc09f99088fc13cZhenyao Mo// are the same. 43274da9f2f24093e828b30071cebc09f99088fc13cZhenyao MoCOMPILER_EXPORT void ShGetVariableInfo(const ShHandle handle, 43374da9f2f24093e828b30071cebc09f99088fc13cZhenyao Mo ShShaderInfo variableType, 43422eab922e7cf9d47f1aa69ebd8cc17306656f9c7apatrick@chromium.org int index, 435d64b3dab06c30da1e5dd9ba12667ff86388540e2shannon.woods@transgaming.com size_t* length, 43622eab922e7cf9d47f1aa69ebd8cc17306656f9c7apatrick@chromium.org int* size, 437183bde5527317fa2208401e5e6b803ef51a0fdcbJamie Madill sh::GLenum* type, 43874da9f2f24093e828b30071cebc09f99088fc13cZhenyao Mo ShPrecisionType* precision, 439d2d340b0da87296b1ec04799ef4c811966bfb7aeZhenyao Mo int* staticUse, 44022eab922e7cf9d47f1aa69ebd8cc17306656f9c7apatrick@chromium.org char* name, 44122eab922e7cf9d47f1aa69ebd8cc17306656f9c7apatrick@chromium.org char* mappedName); 4427beea4084f47ae019b5a93b03a5136c9265dc444alokp@chromium.org 443c23f4611be61bccdbfe2a5c43f63c4d98537ef9fdaniel@transgaming.com// Returns information about a name hashing entry from the latest compile. 444c23f4611be61bccdbfe2a5c43f63c4d98537ef9fdaniel@transgaming.com// Parameters: 445c23f4611be61bccdbfe2a5c43f63c4d98537ef9fdaniel@transgaming.com// handle: Specifies the compiler 446c23f4611be61bccdbfe2a5c43f63c4d98537ef9fdaniel@transgaming.com// index: Specifies the index of the name hashing entry to be queried. 447c23f4611be61bccdbfe2a5c43f63c4d98537ef9fdaniel@transgaming.com// name: Returns a null terminated string containing the user defined name. 448c23f4611be61bccdbfe2a5c43f63c4d98537ef9fdaniel@transgaming.com// It is assumed that name has enough memory to accomodate the name. 449c23f4611be61bccdbfe2a5c43f63c4d98537ef9fdaniel@transgaming.com// The size of the buffer required to store the user defined name can 450c23f4611be61bccdbfe2a5c43f63c4d98537ef9fdaniel@transgaming.com// be obtained by calling ShGetInfo with SH_NAME_MAX_LENGTH. 451c23f4611be61bccdbfe2a5c43f63c4d98537ef9fdaniel@transgaming.com// hashedName: Returns a null terminated string containing the hashed name of 452c23f4611be61bccdbfe2a5c43f63c4d98537ef9fdaniel@transgaming.com// the uniform variable, It is assumed that hashedName has enough 453c23f4611be61bccdbfe2a5c43f63c4d98537ef9fdaniel@transgaming.com// memory to accomodate the name. The size of the buffer required 454c23f4611be61bccdbfe2a5c43f63c4d98537ef9fdaniel@transgaming.com// to store the name can be obtained by calling ShGetInfo with 455c23f4611be61bccdbfe2a5c43f63c4d98537ef9fdaniel@transgaming.com// SH_HASHED_NAME_MAX_LENGTH. 456c23f4611be61bccdbfe2a5c43f63c4d98537ef9fdaniel@transgaming.comCOMPILER_EXPORT void ShGetNameHashingEntry(const ShHandle handle, 457c23f4611be61bccdbfe2a5c43f63c4d98537ef9fdaniel@transgaming.com int index, 458c23f4611be61bccdbfe2a5c43f63c4d98537ef9fdaniel@transgaming.com char* name, 459c23f4611be61bccdbfe2a5c43f63c4d98537ef9fdaniel@transgaming.com char* hashedName); 460c23f4611be61bccdbfe2a5c43f63c4d98537ef9fdaniel@transgaming.com 461e294bb8741ec02fdb814ef3a3999c2d61c1e798fJamie Madill// Shader variable inspection. 462e294bb8741ec02fdb814ef3a3999c2d61c1e798fJamie Madill// Returns a pointer to a list of variables of the designated type. 463e294bb8741ec02fdb814ef3a3999c2d61c1e798fJamie Madill// (See ShaderVars.h for type definitions, included above) 464e294bb8741ec02fdb814ef3a3999c2d61c1e798fJamie Madill// Returns NULL on failure. 465043da138a767ebdf9b4fff83b654f4bfb43ac4f2daniel@transgaming.com// Parameters: 466043da138a767ebdf9b4fff83b654f4bfb43ac4f2daniel@transgaming.com// handle: Specifies the compiler 467e294bb8741ec02fdb814ef3a3999c2d61c1e798fJamie MadillCOMPILER_EXPORT const std::vector<sh::Uniform> *ShGetUniforms(const ShHandle handle); 468e294bb8741ec02fdb814ef3a3999c2d61c1e798fJamie MadillCOMPILER_EXPORT const std::vector<sh::Varying> *ShGetVaryings(const ShHandle handle); 469e294bb8741ec02fdb814ef3a3999c2d61c1e798fJamie MadillCOMPILER_EXPORT const std::vector<sh::Attribute> *ShGetAttributes(const ShHandle handle); 470e294bb8741ec02fdb814ef3a3999c2d61c1e798fJamie MadillCOMPILER_EXPORT const std::vector<sh::Attribute> *ShGetOutputVariables(const ShHandle handle); 471e294bb8741ec02fdb814ef3a3999c2d61c1e798fJamie MadillCOMPILER_EXPORT const std::vector<sh::InterfaceBlock> *ShGetInterfaceBlocks(const ShHandle handle); 472043da138a767ebdf9b4fff83b654f4bfb43ac4f2daniel@transgaming.com 473a15f3e84bfc96b9ef97dd10150f8811adcbbdebfZhenyao Motypedef struct 474a15f3e84bfc96b9ef97dd10150f8811adcbbdebfZhenyao Mo{ 475183bde5527317fa2208401e5e6b803ef51a0fdcbJamie Madill sh::GLenum type; 476a15f3e84bfc96b9ef97dd10150f8811adcbbdebfZhenyao Mo int size; 477a15f3e84bfc96b9ef97dd10150f8811adcbbdebfZhenyao Mo} ShVariableInfo; 478a15f3e84bfc96b9ef97dd10150f8811adcbbdebfZhenyao Mo 479a15f3e84bfc96b9ef97dd10150f8811adcbbdebfZhenyao Mo// Returns 1 if the passed in variables pack in maxVectors following 480a15f3e84bfc96b9ef97dd10150f8811adcbbdebfZhenyao Mo// the packing rules from the GLSL 1.017 spec, Appendix A, section 7. 481a15f3e84bfc96b9ef97dd10150f8811adcbbdebfZhenyao Mo// Returns 0 otherwise. Also look at the SH_ENFORCE_PACKING_RESTRICTIONS 482a15f3e84bfc96b9ef97dd10150f8811adcbbdebfZhenyao Mo// flag above. 483a15f3e84bfc96b9ef97dd10150f8811adcbbdebfZhenyao Mo// Parameters: 484a15f3e84bfc96b9ef97dd10150f8811adcbbdebfZhenyao Mo// maxVectors: the available rows of registers. 485a15f3e84bfc96b9ef97dd10150f8811adcbbdebfZhenyao Mo// varInfoArray: an array of variable info (types and sizes). 486a15f3e84bfc96b9ef97dd10150f8811adcbbdebfZhenyao Mo// varInfoArraySize: the size of the variable array. 487a15f3e84bfc96b9ef97dd10150f8811adcbbdebfZhenyao MoCOMPILER_EXPORT int ShCheckVariablesWithinPackingLimits( 488a15f3e84bfc96b9ef97dd10150f8811adcbbdebfZhenyao Mo int maxVectors, 489a15f3e84bfc96b9ef97dd10150f8811adcbbdebfZhenyao Mo ShVariableInfo* varInfoArray, 490a15f3e84bfc96b9ef97dd10150f8811adcbbdebfZhenyao Mo size_t varInfoArraySize); 491a15f3e84bfc96b9ef97dd10150f8811adcbbdebfZhenyao Mo 4924e1fd41255ab4ce8b2cd745033f385c3e8bd9e7aJamie Madill// Gives the compiler-assigned register for an interface block. 4934e1fd41255ab4ce8b2cd745033f385c3e8bd9e7aJamie Madill// The method writes the value to the output variable "indexOut". 4944e1fd41255ab4ce8b2cd745033f385c3e8bd9e7aJamie Madill// Returns true if it found a valid interface block, false otherwise. 4954e1fd41255ab4ce8b2cd745033f385c3e8bd9e7aJamie Madill// Parameters: 4964e1fd41255ab4ce8b2cd745033f385c3e8bd9e7aJamie Madill// handle: Specifies the compiler 4974e1fd41255ab4ce8b2cd745033f385c3e8bd9e7aJamie Madill// interfaceBlockName: Specifies the interface block 4984e1fd41255ab4ce8b2cd745033f385c3e8bd9e7aJamie Madill// indexOut: output variable that stores the assigned register 4994e1fd41255ab4ce8b2cd745033f385c3e8bd9e7aJamie MadillCOMPILER_EXPORT bool ShGetInterfaceBlockRegister(const ShHandle handle, 5004e1fd41255ab4ce8b2cd745033f385c3e8bd9e7aJamie Madill const char *interfaceBlockName, 5014e1fd41255ab4ce8b2cd745033f385c3e8bd9e7aJamie Madill unsigned int *indexOut); 5024e1fd41255ab4ce8b2cd745033f385c3e8bd9e7aJamie Madill 5039fe25e9eaafd8de2e4890cfb926c678ab6e4abb8Jamie Madill// Gives the compiler-assigned register for uniforms in the default 5049fe25e9eaafd8de2e4890cfb926c678ab6e4abb8Jamie Madill// interface block. 5059fe25e9eaafd8de2e4890cfb926c678ab6e4abb8Jamie Madill// The method writes the value to the output variable "indexOut". 5069fe25e9eaafd8de2e4890cfb926c678ab6e4abb8Jamie Madill// Returns true if it found a valid default uniform, false otherwise. 5079fe25e9eaafd8de2e4890cfb926c678ab6e4abb8Jamie Madill// Parameters: 5089fe25e9eaafd8de2e4890cfb926c678ab6e4abb8Jamie Madill// handle: Specifies the compiler 5099fe25e9eaafd8de2e4890cfb926c678ab6e4abb8Jamie Madill// interfaceBlockName: Specifies the uniform 5109fe25e9eaafd8de2e4890cfb926c678ab6e4abb8Jamie Madill// indexOut: output variable that stores the assigned register 5119fe25e9eaafd8de2e4890cfb926c678ab6e4abb8Jamie MadillCOMPILER_EXPORT bool ShGetUniformRegister(const ShHandle handle, 5129fe25e9eaafd8de2e4890cfb926c678ab6e4abb8Jamie Madill const char *uniformName, 5139fe25e9eaafd8de2e4890cfb926c678ab6e4abb8Jamie Madill unsigned int *indexOut); 5149fe25e9eaafd8de2e4890cfb926c678ab6e4abb8Jamie Madill 5154f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.com#ifdef __cplusplus 516774d70630a690b2449afdccfb29612393c65f212alokp@chromium.org} 5174f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.com#endif 5184f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.com 5194f39fd99568ce175f04b5ed72062bfed0fa41803daniel@transgaming.com#endif // _COMPILER_INTERFACE_INCLUDED_ 520